change in bdd work but need to change in list too
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
export type Chantier = {
|
export type Chantier = {
|
||||||
id: number;
|
id: string;
|
||||||
adresse: string;
|
adresse: string;
|
||||||
etat: string;
|
etat: string;
|
||||||
contact: string;
|
contact: string;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useChantier } from '@/app/ContextChantier';
|
import { useChantier } from '@/app/ContextChantier';
|
||||||
import { changeChantierStatus } from "@/services/ressourcesService";
|
import { changeChantierStatus, getChantiers } from "@/services/ressourcesService";
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { Dimensions, LayoutAnimation, Modal, Pressable, StyleSheet, View } from 'react-native';
|
import { Dimensions, LayoutAnimation, Modal, Pressable, StyleSheet, View } from 'react-native';
|
||||||
import Animated, { LinearTransition } from 'react-native-reanimated';
|
import Animated, { LinearTransition } from 'react-native-reanimated';
|
||||||
@@ -29,14 +29,19 @@ export default function SetStatus() {
|
|||||||
setIsOpen(!isOpen);
|
setIsOpen(!isOpen);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onConfirm(): void {
|
async function onConfirm(): Promise<void> {
|
||||||
|
if(chantier == null) return;
|
||||||
setOpenConfirmation(false);
|
setOpenConfirmation(false);
|
||||||
setCurrentStatus(tempStatus);
|
setCurrentStatus(tempStatus);
|
||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
if(chantier != null){
|
await changeChantierStatus(chantier.id,tempStatus)
|
||||||
//TODO MAJ la BDD
|
//Il faut changer le UX
|
||||||
changeChantierStatus(String(chantier.id),currentStatus)
|
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 {
|
function onCancel(): void {
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ export async function getChantiers(): Promise<Chantier[]> {
|
|||||||
|
|
||||||
chantiers.push({
|
chantiers.push({
|
||||||
...data,
|
...data,
|
||||||
|
id: docSnap.id,
|
||||||
dateDep,
|
dateDep,
|
||||||
chef,
|
chef,
|
||||||
equipe
|
equipe
|
||||||
|
|||||||
Reference in New Issue
Block a user