test chantier.chef

This commit is contained in:
tuanvu
2025-12-09 14:47:20 +01:00
parent 84df00230e
commit 6a619d71aa
2 changed files with 9 additions and 29 deletions

View File

@@ -83,7 +83,7 @@ export default function GestionnaireRessource() {
</ThemedView> </ThemedView>
} }
ListEmptyComponent={ ListEmptyComponent={
<ThemedText style={styles.empty}>Aucun résultat trouvé 😕</ThemedText> <ThemedText style={styles.empty}>Aucun résultat trouvé</ThemedText>
} }
/> />

View File

@@ -20,7 +20,6 @@ export async function getUsers(): Promise<User[]> {
} }
} }
export async function getRessources(): Promise<Ressources[]> { export async function getRessources(): Promise<Ressources[]> {
try { try {
const colRef = collection(db, "ressources"); const colRef = collection(db, "ressources");
@@ -38,7 +37,6 @@ export async function getRessources(): Promise<Ressources[]> {
} }
} }
export async function getChantiers(): Promise<Chantier[]> { export async function getChantiers(): Promise<Chantier[]> {
try { try {
const colRef = collection(db, "chantier"); const colRef = collection(db, "chantier");
@@ -47,26 +45,12 @@ export async function getChantiers(): Promise<Chantier[]> {
const data = doc.data() as any; const data = doc.data() as any;
return { return {
...data, ...data,
chef: { dateDep: data.dateDep.toDate(),
...data.chef, chef: { ...data.chef },
allocation: data.chef?.allocation?.map(convertReservation) || [], equipe: data.equipe ?? [],
}, materiel: data.materiel ?? [],
equipe: vehicules: data.vehicules ?? [],
data.equipe?.map((u: any) => ({ anomalies: data.anomalies ?? []
...u,
allocation: u.allocation?.map(convertReservation) || [],
})) || [],
materiel:
data.materiel?.map((m: any) => ({
...m,
allocation: m.allocation?.map(convertReservation) || [],
})) || [],
vehicules:
data.vehicules?.map((v: any) => ({
...v,
allocation: v.allocation?.map(convertReservation) || [],
})) || [],
anomalies: data.anomalies || [],
} as Chantier; } as Chantier;
}); });
} catch (err) { } catch (err) {
@@ -79,12 +63,8 @@ function convertReservation(res: any): Reservation {
return { return {
id: res.id, id: res.id,
dateChantier: dateChantier:
res.dateChantier instanceof Timestamp res.dateChantier instanceof Timestamp ? res.dateChantier.toDate() : new Date(res.dateChantier),
? res.dateChantier.toDate()
: new Date(res.dateChantier),
dateFin: dateFin:
res.dateFin instanceof Timestamp res.dateFin instanceof Timestamp ? res.dateFin.toDate() : new Date(res.dateFin),
? res.dateFin.toDate()
: new Date(res.dateFin),
}; };
} }