addChantier

This commit is contained in:
Rochas
2025-12-11 23:22:45 +01:00
parent 46c6707d14
commit 8ba664c2ad
2 changed files with 35 additions and 16 deletions

View File

@@ -15,14 +15,18 @@ import { ThemedButton } from '@/components/theme/themed-button';
import { ThemedTextInput } from '@/components/theme/themed-textinput'; import { ThemedTextInput } from '@/components/theme/themed-textinput';
import Constants from 'expo-constants'; //pour connaître la taille de la barre menu de l'OS en haut import Constants from 'expo-constants'; //pour connaître la taille de la barre menu de l'OS en haut
//Uniquement accessible par le RESPONSSABLE du chantier
//Pour créer ou modifier un chantier
export default function AddChantier() { export default function AddChantier() {
const { chantier, setChantier } = useChantier(); const { chantier, setChantier } = useChantier();
const { user, setUser } = useUser(); const { user, setUser } = useUser();
const { ressources, setRessources } = useRessources(); const { ressources, setRessources } = useRessources();
const [editMode,setEditMode] = useState(false);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [nom, setNom] = useState(''); const [objet, setObjet] = useState('');
const [date, setDate] = useState('');
const [chefChantier, setChefChantier] = useState(''); const [chefChantier, setChefChantier] = useState('');
const [adresse, setAdresse] = useState(''); const [adresse, setAdresse] = useState('');
const [duree, setDuree] = useState(''); const [duree, setDuree] = useState('');
@@ -34,10 +38,10 @@ export default function AddChantier() {
setLoading(true); setLoading(true);
} }
const renderInut = (name : string, preFill : string, value : string) => { const renderInut = (name : string, preFill : string, value : string, setValue : ((text:string) => void)) => {
return ( return (
<View> <View style = {styles.inputLine}>
<ThemedText>{name}</ThemedText> <ThemedText style = {styles.inputName}>{name}:</ThemedText>
<ThemedTextInput lvl = {1} style = {styles.input} placeholder={preFill} value = {value} onChangeText={setAdresse} /> <ThemedTextInput lvl = {1} style = {styles.input} placeholder={preFill} value = {value} onChangeText={setAdresse} />
</View> </View>
); );
@@ -47,27 +51,34 @@ export default function AddChantier() {
return ( return (
<ThemedView lvl={3} style={styles.back}> <ThemedView lvl={3} style={styles.back}>
<View style={styles.container}> <View style={styles.container}>
{editMode &&
<View style={{width:"100%", position: 'absolute'}}> <View style={{width:"100%", position: 'absolute'}}>
<SelectChantier></SelectChantier> <SelectChantier></SelectChantier>
</View> </View>
}
<ScrollView> <ScrollView>
<View style = {styles.header}> <View style = {styles.header}>
<ThemedText style = {styles.text}>Ajouter un nouveau chantier </ThemedText>
<ThemedTextInput lvl = {1} style = {styles.input} placeholder='Adresse du chantier' value = {adresse} onChangeText={setAdresse} />
<ThemedTextInput lvl = {1} style = {styles.input} placeholder='Date de Dep' value = {duree} onChangeText={setDuree} />
<ThemedTextInput lvl = {1} style = {styles.input} placeholder='06 01 02 03 04' value = {contact} onChangeText={setContact} />
<ThemedTextInput lvl = {1} style = {styles.input} placeholder='chef de chantier' value= {chefChantier} onChangeText={setChefChantier}/>
<ThemedText style = {styles.text}>Ajouter un équipier</ThemedText>
<ThemedText style = {styles.text}>Ajouter une ressources</ThemedText> <ThemedText style = {styles.text}>
{editMode? "Edition d'un chantier"
:"Ajouter un nouveau chantier"}
</ThemedText>
{renderInut("Objet","Renovation",objet,setObjet)}
{renderInut("Date de départ","TOTO : JOUR + Demi journé",date,setDate)}
{renderInut("Estimation de la durée (1/2 Journée)","14",duree,setDuree)}
{renderInut("Adresse","1 Rue de la Coutellerie, Paris",adresse,setAdresse)}
{renderInut("Contact client","07 01 02 03 04 05",contact,setContact)}
{renderInut("Vehicule","TODO pas un input bien sûre",adresse,setAdresse)}
{renderInut("Chef de chantier","TODO pas un input non plus",chefChantier,setChefChantier)}
<ThemedButton <ThemedButton
lvl={1} lvl={1}
shadow={true} shadow={true}
style={{ padding: 10, borderRadius: 8, marginBottom: 10 }} style={{ padding: 10, borderRadius: 8, marginBottom: 10 }}
onPress={() => handleAddChantier()} onPress={() => handleAddChantier()}
> >
<ThemedText>+</ThemedText>
</ThemedButton> </ThemedButton>
</View> </View>
@@ -88,7 +99,6 @@ const styles = StyleSheet.create({
}, },
header: { header: {
marginTop:60, marginTop:60,
marginBottom: 20,
alignItems: "center", alignItems: "center",
paddingHorizontal: 20, paddingHorizontal: 20,
}, },
@@ -102,6 +112,15 @@ const styles = StyleSheet.create({
borderRadius: 10, borderRadius: 10,
backgroundColor: "transparent", backgroundColor: "transparent",
}, },
inputLine:{
width: "100%",
//flexDirection: 'row',
paddingVertical: 5,
//alignItems: "center",
},
inputName: {
fontSize: 16,
},
input: { input: {
width: "100%", width: "100%",
borderRadius: 10, borderRadius: 10,

View File

@@ -43,13 +43,13 @@ const styles = StyleSheet.create({
container: { container: {
flex: 1, flex: 1,
marginTop: Constants.statusBarHeight, //pour la barre menu du haut marginTop: Constants.statusBarHeight, //pour la barre menu du haut
paddingTop : 60,
}, },
header: { header: {
flex: 1, flex: 1,
width:"100%" width:"100%"
}, },
summary:{ summary:{
marginTop:60,
padding:10, padding:10,
}, },
anomaly:{ anomaly:{