/products.service.ts
private products = [];
insertProduct(createProductDto: CreateProductDto) {
const newProduct = this.createProduct(createProductDto);
this.products = [...this.products, newProduct];
return newProduct;
}
private createProduct(product) {
const newProduct: ProductEntity = {
title: product.title,
description: product.description,
icon: product.icon,
active: true,
marketing: {
background_img: product.marketing.backgroundImg,
message: product.marketing.message,
},
id: uuidv4(),
};
return newProduct;
}
}
/create-product.entity.ts
export class ProductEntity {
id: string;
title: string;
description: string;
icon: string;
active: boolean;
marketing: {
background_img: string,
message: string
};
}
/create-product.dto.ts
export class CreateProductDto {
title: string;
description: string;
icon: string;
marketing: {
backgroundImg: string;
message: string;
};
}
./src/components/App/styles.scss (./node_modules/css-loader/dist/cjs.js??ref--5-oneOf-6-1!./node_modules/react-scripts/node_modules/postcss-loader/src??postcss!./node_modules/resolve-url-loader??ref--5-oneOf-6-3!./node_modules/sass-loader/dist/cjs.js??ref--5-oneOf-6-4!./src/components/App/styles.scss)
Error: Node Sass version 5.0.0 is incompatible with ^4.0.0.
const [loadingOperations, setLoadingOperations] = useState(false);
const [loadingLoan, setLoadingLoan] = useState(false);
const [loadingFinance, setLoadingFinance] = useState(false);
const [loadingServices, setLoadingServices] = useState(false);
const [loadingSystem, setLoadingSystem] = useState(false);
useEffect(() => {
setLoadingLoan(true);
setLoadingOperations(true);
setLoadingServices(true);
setLoadingSystem(true);
setLoadingFinance(true);
apiGetOperationsLoan()
.then((response) => {
setLoadingLoan(false);
setOperationsLoan(response.data);
});
apiGetOperationsFinance()
.then((response) => {
setLoadingFinance(false);
setOperationsFinance(response.data);
});
apiGetOperationsServices()
.then((response) => {
setLoadingServices(false);
setOperationsServices(response.data);
});
/// ну и так дальше..
}, []);
<TabBar>
<TabBarItem label="Операции">
<div className="loans-history">
{ loadingLoan ? <p>Loading...</p>
:
{operationsLoan.map((loan, index) => {
return <Loan loan={loan} key={index}/>;
})
}}
</div>
</TabBarItem>
<TabBarItem label="Финансовые">
<div className="finance-history">
{loadingOperations ? <p>Loading..</p>
:
operationsFinance.map((finance, index) => {
return <Finance finance={finance} key={index}/>;
})
}
FirebaseError: Invalid collection reference. Collection references must have an odd number of segments, but userBookmarks/LP5MVgne0LhEZv1TPHugIZ4kYbD3 has 2
const doc = db.collection('userBookmarks/' + uid);
firebase
.auth()
.createUserWithEmailAndPassword(email, password)
.then(({ user }) => {
console.log(user);
db.collection('userBookmarks')
.doc(user.uid)
.set({ bookmarks: [{ title: 'Avengers123213' }] });
});
const getBookmarks = () => {
db.collection(`userBookmarks`)
.doc(uniqueId)
.get()
.then(res => console.log(res.data()));
};
const addToBookmarks = data => {
const doc = db.collection('userBookmarks').doc(uniqueId);
const temp = doc.get().then(res => res.data());
const obj = { bookmarks: [...temp, ...data] };
doc.set(obj);
// получаю ошибку TypeError: temp is not iterable
//либо делал еще так:
const doc = db.collection('userBookmarks').doc(uniqueId);
doc.set(data);
//и это работает но перезаписывает предыдущий обьект..
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// match logged in user doc in users collection
match /users/{userId} {
allow create: if request.auth.uid != null;
allow read: if request.auth.uid == userId;
}
// match documents in the bookmarks collection
match /bookmarks/{bookmarkId} {
allow read, write: if request.auth.uid != null;
}
}
}
db.collection('bookmarks')
.get()
.then(({ docs }) => console.log(docs));