change in bdd work but need to change in list too

This commit is contained in:
tuanvu
2025-12-11 12:12:13 +01:00
parent e24ee56c27
commit 9a928a73e8
3 changed files with 13 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
export type Chantier = {
id: number;
id: string;
adresse: string;
etat: string;
contact: string;

View File

@@ -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<void> {
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 {

View File

@@ -63,6 +63,7 @@ export async function getChantiers(): Promise<Chantier[]> {
chantiers.push({
...data,
id: docSnap.id,
dateDep,
chef,
equipe