From 29abc4289ec7d245a6fc37b426fd7c4b721fb4ae Mon Sep 17 00:00:00 2001 From: Rochas Date: Sat, 13 Dec 2025 20:51:19 +0100 Subject: [PATCH] correction addChantier --- app/(tabs)/addScreen.tsx | 25 ++-- components/add/addArtisant.tsx | 246 -------------------------------- components/add/addChantier.tsx | 5 +- components/add/addRessource.tsx | 5 +- components/selectChantier.tsx | 2 +- 5 files changed, 24 insertions(+), 259 deletions(-) delete mode 100644 components/add/addArtisant.tsx diff --git a/app/(tabs)/addScreen.tsx b/app/(tabs)/addScreen.tsx index 33cb8fa..a2ecf04 100644 --- a/app/(tabs)/addScreen.tsx +++ b/app/(tabs)/addScreen.tsx @@ -4,7 +4,6 @@ import { useState } from "react"; import { View,StyleSheet } from "react-native"; import AddChantier from "@/components/add/addChantier"; import AddRessource from "@/components/add/addRessource"; -import AddArtisant from "@/components/add/addArtisant"; import Constants from 'expo-constants'; //pour connaître la taille de la barre menu de l'OS en haut import { ThemedView } from "@/components/theme/themed-view"; @@ -40,11 +39,13 @@ export default function AddScreen() { ): - setTypeAdd("")}> - - Retour - - + + setTypeAdd("")}> + + Retour + + + {typeAdd==="Chantier"? ( @@ -68,14 +69,22 @@ const styles = StyleSheet.create({ }, container: { flex: 1, - marginTop: Constants.statusBarHeight, //pour la barre menu du haut + //marginTop: Constants.statusBarHeight, //pour la barre menu du haut }, button:{ padding:10, borderRadius:10, }, selectTypeAdd:{ + marginTop: Constants.statusBarHeight, //pour la barre menu du haut gap:30, padding:20 - } + }, + backButton:{ + marginTop: Constants.statusBarHeight, //pour la barre menu du haut + position: 'absolute', + padding: 20, + zIndex: 100, + //backgroundColor:"#FF0000", + }, }); \ No newline at end of file diff --git a/components/add/addArtisant.tsx b/components/add/addArtisant.tsx deleted file mode 100644 index 3bf8067..0000000 --- a/components/add/addArtisant.tsx +++ /dev/null @@ -1,246 +0,0 @@ -import ChantierSummary from '@/components/chantierSummary'; -import SelectChantier from '@/components/selectChantier'; -import SetStatus from '@/components/setStatus'; - - -import { ThemedView } from '@/components/theme/themed-view'; -import React, { useEffect, useState } from 'react'; -import { StyleSheet, ScrollView, Button, TextInput, Text, View, Modal } from 'react-native'; -import { useChantier } from '../../app/ContextChantier'; -import { useRessources } from '../../app/ContextRessource'; -import { useUser } from '../../app/ContextUser'; -import { getRessources, getUsers, addChantier } from '@/services/ressourcesService'; -import { Chantier, Ressources, User } from '@/class/class'; -import { ThemedText } from '@/components/theme/themed-text'; -import { ThemedButton } from '@/components/theme/themed-button'; -import { ThemedTextInput } from '@/components/theme/themed-textinput'; -import DateTimePicker, { DateTimePickerEvent } from '@react-native-community/datetimepicker'; - -import Constants from 'expo-constants'; //pour connaître la taille de la barre menu de l'OS en haut -import SelectChafChantier from '@/components/add/select/selectChefChantier'; -import SelectMachine from '@/components/selectMachine'; - -//Uniquement accessible par le RESPONSSABLE du chantier -//Pour créer ou modifier un chantier -export default function AddArtisant() { - const { chantier, setChantier } = useChantier(); - const { user, setUser } = useUser(); - const { ressources, setRessources } = useRessources(); - - const [editMode,setEditMode] = useState(false); - - const [loading, setLoading] = useState(false); - const [nom, setNom] = useState(''); - const [qualifications, setQualifications] = useState(''); - const [date, setDate] = useState(new Date()); - const [contact, setContact] = useState(''); - - const [showDateSelect,setSowDateSelect] = useState(false); - const [openConfirmation,setOpenConfirmation] = useState(false); - - const [userSelect, setUserSelect] = useState([]); - const [ressourcesSelect, setRessourcesSelect] = useState([]); - - async function handleAddArtisant() { - setLoading(true); - setOpenConfirmation(true); - } - - - const onSelectDate = (event: DateTimePickerEvent, selectedDate?: Date) => { - setSowDateSelect(false); - if (selectedDate) { - setDate(selectedDate); - } - }; - - async function onConfirm(): Promise { - //TODO - //await changeChantierStatus(chantier.id,tempStatus) - //Il faut changer le UX - //setChantier({...chantier,etat: tempStatus}) - if(isValidChantier()){ - setOpenConfirmation(false); - } - } - - function onCancel(): void { - setOpenConfirmation(false); - } - - function isValidChantier(): boolean { - return nom=="" && qualifications!=='' && contact!=='' - } - - const renderValidationScreen = () => { - return( - - - - Créer le nouveau chantier suivant ? : - - Nom: {nom===''?"NONE":nom} - Qualifications : {qualifications===''?"NONE":qualifications} - - Date: {date.toLocaleDateString()} - Contact {contact===''?"NONE":contact} - - - - onConfirm()}> - Confirmer - - - - onCancel()}> - Annuler - - - - - - ) - } - - const renderInutDate = (name : string) => { - return ( - - {name}: - - - - setSowDateSelect(true)} style = {{borderRadius:10}}>{date.toLocaleDateString()} - - - - {showDateSelect && ( - - )} - - - ); - }; - - const renderInut = (name : string, preFill : string, value : string, setValue : ((text:string) => void),numeric:boolean) => { - return ( - - {name}: - - - ); - }; - - - return ( - - - {editMode && - - - - } - - - - - {editMode? "Edition d'un chantier" - :"Ajouter un nouvel artisant"} - - {renderInut("Nom","Jean Dupont",nom,setNom,false)} - {//renderInut("Date de départ","TOTO : JOUR + Demi journé",date,setDate) - } - {renderInut("Qualifications","Plombier",qualifications,setQualifications,false)} - {renderInutDate("Date d'arrivée")} - {renderInut("Contact artisant","07 01 02 03 04 05",contact,setContact,true)} - handleAddArtisant()} - > - Valider - - - {openConfirmation && renderValidationScreen()} - - - - - - ); -} - -const styles = StyleSheet.create({ - back:{ - height:"100%", - width:"100%", - }, - container: { - flex: 1, - }, - header: { - marginTop:30, - alignItems: "center", - paddingHorizontal: 20, - }, - text: { - fontSize: 22, - fontWeight: "bold", - marginBottom: 10, - }, - inputBack: { - width: "100%", - borderRadius: 10, - backgroundColor: "transparent", - }, - inputLine:{ - width: "100%", - //flexDirection: 'row', - paddingVertical: 5, - //alignItems: "center", - }, - inputName: { - fontSize: 16, - }, - input: { - width: "100%", - borderRadius: 10, - padding: 10, - fontSize: 16, - }, - overlay:{ - backgroundColor:'#00000080', - padding:"5%", - paddingVertical:"20%", - width:"100%", - height:"100%", - }, - overlayView:{ - borderRadius: 20, - padding: 20, - alignItems: "center", - width: "100%", - gap:5, - //backgroundColor:'#ff0000', - }, - buttonValid:{ - //borderWidth: 2, - width:'100%', - margin: 0, - borderRadius: 15, - padding: 10, - height:60, - alignItems: "center", - justifyContent: 'center', - }, - summaryNewChantier:{ - width:'100%', - borderRadius: 15, - padding:10, - } -}); diff --git a/components/add/addChantier.tsx b/components/add/addChantier.tsx index 24cafb8..0bf458a 100644 --- a/components/add/addChantier.tsx +++ b/components/add/addChantier.tsx @@ -253,14 +253,15 @@ export default function AddChantier() { const styles = StyleSheet.create({ back:{ - height:"80%", + height:"100%", width:"100%", }, container: { flex: 1, + marginTop: Constants.statusBarHeight, //pour la barre menu du haut }, header: { - marginTop:30, + marginTop:80, alignItems: "center", paddingHorizontal: 20, }, diff --git a/components/add/addRessource.tsx b/components/add/addRessource.tsx index 7cbda9a..5db2a85 100644 --- a/components/add/addRessource.tsx +++ b/components/add/addRessource.tsx @@ -79,7 +79,7 @@ export default function AddRessource({ressourceType, ...otherProps }: Props) { - Créer la nouvelle {ressourceType} suivante ? : + Créer la nouvelle ressource {ressourceType} suivante ? : Nom: {nom===''?"NONE":nom} Quantité Total: {quantite===''?"0":quantite} @@ -152,9 +152,10 @@ const styles = StyleSheet.create({ }, container: { flex: 1, + marginTop: Constants.statusBarHeight, //pour la barre menu du haut }, header: { - marginTop:30, + marginTop:80, alignItems: "center", paddingHorizontal: 20, }, diff --git a/components/selectChantier.tsx b/components/selectChantier.tsx index f63ff4e..df19452 100644 --- a/components/selectChantier.tsx +++ b/components/selectChantier.tsx @@ -57,7 +57,7 @@ export default function SelectChantier() { } function onPressAddChantier(){ - router.push("/(tabs)/addChantier") + router.push("/(tabs)/addScreen") setIsOpen(false) }