diff --git a/components/chantierSummary.tsx b/components/chantierSummary.tsx
index df1dbe3..5cea647 100644
--- a/components/chantierSummary.tsx
+++ b/components/chantierSummary.tsx
@@ -1,11 +1,8 @@
-import SelectChantier from '@/components/selectChantier';
-import SetStatus from '@/components/setStatus';
-import { ThemedView, } from '@/components/themed-view';
-import Constants from 'expo-constants'; //pour connaître la taille de la barre menu de l'OS en haut
-import React from 'react';
-import { StyleSheet, View, Image, ViewStyle, StyleProp } from 'react-native';
-import { ThemedText } from './themed-text';
import { Chantier } from '@/class/class';
+import { ThemedView, } from '@/components/themed-view';
+import React from 'react';
+import { Image, StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
+import { ThemedText } from './themed-text';
type Props = {
@@ -26,7 +23,6 @@ export default function ChantierSummary({data,style , ...otherProps }: Props) {
- {data.chantier.chef != null ? "true" : "false"}
Adresse: {data.chantier.adresse}
Chef de chantier: {data.chantier.chef.last_name}{" "}{data.chantier.chef.name}
État: {data.chantier.etat}
diff --git a/components/selectChantier.tsx b/components/selectChantier.tsx
index 69646a2..b60385c 100644
--- a/components/selectChantier.tsx
+++ b/components/selectChantier.tsx
@@ -113,6 +113,7 @@ const styles = StyleSheet.create({
width: "50%",
height: 60,
overflow: "hidden",
+ zIndex:1000,
},
windowOpean: {
//backgroundColor: '#00FF0040',
diff --git a/components/setStatus.tsx b/components/setStatus.tsx
index 00fd0bf..9c0b7fe 100644
--- a/components/setStatus.tsx
+++ b/components/setStatus.tsx
@@ -1,5 +1,6 @@
import { useChantier } from '@/app/ContextChantier';
-import { useCallback, useState } from 'react';
+import { changeChantierStatus } from "@/services/ressourcesService";
+import { useState } from 'react';
import { Dimensions, LayoutAnimation, Modal, Pressable, StyleSheet, View } from 'react-native';
import Animated, { LinearTransition } from 'react-native-reanimated';
import { ThemedButton } from './themed-button';
@@ -12,11 +13,11 @@ const { width, height } = Dimensions.get("window");
export default function SetStatus() {
const { chantier, setChantier} = useChantier();
- const [currentSatus, setCurrentSearch] = useState("En cours");
+ const [currentStatus, setCurrentStatus] = useState("En cours");
+ const [tempStatus, setTempStatus] = useState("");
const [isOpen,setIsOpen] = useState(false);
const [openConfirmation,setOpenConfirmation] = useState(false);
-
const AnimatedThemedView = Animated.createAnimatedComponent(ThemedView);
const choices = ["En cours","Interrompu","Terminé","Non réalisé"]
@@ -28,10 +29,24 @@ export default function SetStatus() {
setIsOpen(!isOpen);
}
+ function onConfirm(): void {
+ setOpenConfirmation(false);
+ setCurrentStatus(tempStatus);
+ setIsOpen(false);
+ if(chantier != null){
+ //TODO MAJ la BDD
+ changeChantierStatus(String(chantier.id),currentStatus)
+ }
+ }
+
+ function onCancel(): void {
+ setOpenConfirmation(false);
+ setIsOpen(false);
+ }
+
function selectSatus(status: string): void {
setOpenConfirmation(true);
- setCurrentSearch(status);
- setIsOpen(false);
+ setTempStatus(status);
}
@@ -46,6 +61,17 @@ export default function SetStatus() {
);
};
+ const confirmation = () => {
+ return(
+
+
+ onConfirm()}>Confirmer
+ onCancel()}>Annuler
+
+
+ )
+ }
+
return(
@@ -55,17 +81,18 @@ export default function SetStatus() {
onPressOpen()}>
- {currentSatus}
+ {currentStatus}
{isOpen && (
<>
+ {openConfirmation && confirmation()}
{//TODO : Modal pour confirmer la changement
}
{choices.map((str, index) => (
- str!==currentSatus && choice(str, index)
+ str!==currentStatus && choice(str, index)
))}
@@ -126,5 +153,9 @@ const styles = StyleSheet.create({
},
centeredText:{
textAlign: 'center',
- }
+ },
+ overlay:{
+ backgroundColor:'transparent',
+ padding:20,
+ },
});
diff --git a/services/ressourcesService.ts b/services/ressourcesService.ts
index 8b8dd3c..a4edfde 100644
--- a/services/ressourcesService.ts
+++ b/services/ressourcesService.ts
@@ -84,7 +84,7 @@ function convertReservation(res: any): Reservation {
export async function changeChantierStatus(chantierId: string, newStatus: string): Promise {
try {
const chantierRef = doc(db, "chantier", chantierId);
- await updateDoc(chantierRef, { status: newStatus });
+ await updateDoc(chantierRef, { etat: newStatus });
console.log(`Chantier ${chantierId} status updated to ${newStatus}`);
} catch (err) {
console.error("Error", err);