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