change in bdd work but need to change in list too
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
export type Chantier = {
|
||||
id: number;
|
||||
id: string;
|
||||
adresse: string;
|
||||
etat: string;
|
||||
contact: string;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -63,6 +63,7 @@ export async function getChantiers(): Promise<Chantier[]> {
|
||||
|
||||
chantiers.push({
|
||||
...data,
|
||||
id: docSnap.id,
|
||||
dateDep,
|
||||
chef,
|
||||
equipe
|
||||
|
||||
Reference in New Issue
Block a user