fix bug addRessource
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { addDoc, arrayUnion, collection, doc, Firestore, getDoc, getDocs, Timestamp, updateDoc, DocumentReference, query, where } from "firebase/firestore";
|
||||
import { addDoc, arrayUnion, collection, doc, DocumentReference, getDoc, getDocs, query, Timestamp, updateDoc, where } from "firebase/firestore";
|
||||
import { Chantier, Reservation, Ressources, User } from "../class/class";
|
||||
import { db } from "../firebase_config";
|
||||
|
||||
@@ -40,10 +40,15 @@ export async function getRessources(): Promise<Ressources[]> {
|
||||
}
|
||||
|
||||
//ADD RESSOURCES
|
||||
export async function addRessources(ressourceData: Omit<Ressources, 'id'>): Promise<string | null> {
|
||||
export async function addRessources(ressourceData: Ressources): Promise<string | null> {
|
||||
try {
|
||||
const colRef = collection(db, "ressources");
|
||||
const ressourcesRef = await addDoc(colRef, ressourceData);
|
||||
const ressourcesRef = await addDoc(collection(db, "ressources"), {
|
||||
name:ressourceData.name,
|
||||
type:ressourceData.type,
|
||||
Image: ressourceData.Image,
|
||||
quantity: ressourceData.quantity,
|
||||
});
|
||||
|
||||
console.log(`Ressource ajoutée avec ID: ${ressourcesRef.id}`);
|
||||
return ressourcesRef.id;
|
||||
} catch (err) {
|
||||
@@ -260,6 +265,10 @@ export async function sendNewChantier(chantier:Chantier): Promise<void> {
|
||||
}
|
||||
|
||||
export async function sendNewReservation(list: Reservation[],chantierId:string): Promise<void> {
|
||||
list.forEach(reservation => {
|
||||
console.log("log: " + reservation.ressource.id);
|
||||
});
|
||||
|
||||
const promises = list.map((reservation) =>
|
||||
addDoc(collection(db,"Reservation"),{
|
||||
chantier: doc(db, "chantier", chantierId),
|
||||
|
||||
Reference in New Issue
Block a user