From 9a928a73e86d6845d406a1e5199bea93418e187e Mon Sep 17 00:00:00 2001 From: tuanvu Date: Thu, 11 Dec 2025 12:12:13 +0100 Subject: [PATCH] change in bdd work but need to change in list too --- class/class.tsx | 2 +- components/setStatus.tsx | 17 +++++++++++------ services/ressourcesService.ts | 1 + 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/class/class.tsx b/class/class.tsx index 1fc585c..8233c12 100644 --- a/class/class.tsx +++ b/class/class.tsx @@ -1,5 +1,5 @@ export type Chantier = { - id: number; + id: string; adresse: string; etat: string; contact: string; diff --git a/components/setStatus.tsx b/components/setStatus.tsx index 5ac18d4..5ece895 100644 --- a/components/setStatus.tsx +++ b/components/setStatus.tsx @@ -1,5 +1,5 @@ import { useChantier } from '@/app/ContextChantier'; -import { changeChantierStatus } from "@/services/ressourcesService"; +import { changeChantierStatus, getChantiers } from "@/services/ressourcesService"; import { useState } from 'react'; import { Dimensions, LayoutAnimation, Modal, Pressable, StyleSheet, View } from 'react-native'; import Animated, { LinearTransition } from 'react-native-reanimated'; @@ -29,14 +29,19 @@ export default function SetStatus() { setIsOpen(!isOpen); } - function onConfirm(): void { + async function onConfirm(): Promise { + if(chantier == null) return; setOpenConfirmation(false); setCurrentStatus(tempStatus); setIsOpen(false); - if(chantier != null){ - //TODO MAJ la BDD - changeChantierStatus(String(chantier.id),currentStatus) - } + await changeChantierStatus(chantier.id,tempStatus) + //Il faut changer le UX + setChantier({...chantier,etat: tempStatus}) + + //Il faut charger la bdd + //const updatedChantiers = await getChantiers(); + //const updatedChantier = updatedChantiers.find(c=> c.id=== chantier.id); + //if (updatedChantier) setChantier(updatedChantier); } function onCancel(): void { diff --git a/services/ressourcesService.ts b/services/ressourcesService.ts index a4edfde..df9ba1a 100644 --- a/services/ressourcesService.ts +++ b/services/ressourcesService.ts @@ -63,6 +63,7 @@ export async function getChantiers(): Promise { chantiers.push({ ...data, + id: docSnap.id, dateDep, chef, equipe