add en un seul écran, composant lié aux add dans un dossier /composants/add

This commit is contained in:
Rochas
2025-12-13 18:48:54 +01:00
parent b5c751cada
commit bcf9907007
9 changed files with 133 additions and 103 deletions

View File

@@ -9,13 +9,8 @@ import GestionOuvrier from './gestion_ouvrier';
import ListMateriel from './gestionnaire_ressource'; import ListMateriel from './gestionnaire_ressource';
import Home from './home'; import Home from './home';
import MapScreen from './mapScreen'; import MapScreen from './mapScreen';
import AddChantier from './addChantier';
import AddRessource from './addRessource';
import AddArtisant from './addArtisant';
import AntDesign from '@expo/vector-icons/AntDesign'; import AntDesign from '@expo/vector-icons/AntDesign';
import { UserProvider } from '../ContextUser'; import AddScreen from './addScreen';
import { ChantierProvider } from '../ContextChantier';
import { RessourcesProvider } from '../ContextRessource';
const Tabs = createBottomTabNavigator(); const Tabs = createBottomTabNavigator();
@@ -68,8 +63,8 @@ export default function TabLayout() {
> >
</Tabs.Screen> </Tabs.Screen>
<Tabs.Screen <Tabs.Screen
name="addChantier" name="Ajouter"
component={AddChantier} component={AddScreen}
options={{ options={{
title: 'Ajouter', title: 'Ajouter',
tabBarIcon: ({ color }) => ( tabBarIcon: ({ color }) => (
@@ -78,28 +73,6 @@ export default function TabLayout() {
}} }}
/> />
<Tabs.Screen
name="addRessource"
component={AddRessource}
options={{
title: 'Ressources',
tabBarIcon: ({ color }) => (
<AntDesign name="plus" size={24} color={color} />
),
}}
/>
<Tabs.Screen
name="addArtisant"
component={AddArtisant}
options={{
title: 'Artisants',
tabBarIcon: ({ color }) => (
<AntDesign name="plus" size={24} color={color} />
),
}}
/>
</Tabs.Navigator> </Tabs.Navigator>
); );

View File

@@ -1,35 +1,81 @@
import { ThemedButton } from "@/components/theme/themed-button"; import { ThemedButton } from "@/components/theme/themed-button";
import { ThemedText } from "@/components/theme/themed-text"; import { ThemedText } from "@/components/theme/themed-text";
import { useState } from "react"; import { useState } from "react";
import { View } from "react-native"; 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";
export default function AddScreen() { export default function AddScreen() {
const [typeAdd, setTypeAdd] = useState(''); const [typeAdd, setTypeAdd] = useState('');
return( return(
<View> <ThemedView lvl={3} style={styles.back}>
<ThemedButton> <View style={styles.container}>
<ThemedText> {typeAdd===""? (
Ajouter un chantier <View style={styles.selectTypeAdd} >
</ThemedText> <ThemedButton style={styles.button} onPress={() => setTypeAdd("Chantier")}>
</ThemedButton> <ThemedText>
<ThemedButton> Ajouter un chantier
<ThemedText> </ThemedText>
Ajouter un équipement </ThemedButton>
</ThemedText> <ThemedButton style={styles.button} onPress={() => setTypeAdd("Outil")}>
</ThemedButton> <ThemedText>
<ThemedButton> Ajouter un équipement
<ThemedText> </ThemedText>
Ajouter un vehicule ou machine </ThemedButton>
</ThemedText> <ThemedButton style={styles.button} onPress={() => setTypeAdd("Machine")}>
</ThemedButton> <ThemedText>
<ThemedButton> Ajouter un vehicule ou machine
<ThemedText> </ThemedText>
Ajouter un ouvrier </ThemedButton>
</ThemedText> <ThemedButton style={styles.button} onPress={() => setTypeAdd("Ouvrier")}>
</ThemedButton> <ThemedText>
</View> Ajouter un ouvrier
</ThemedText>
</ThemedButton>
</View>
):
<View>
<ThemedButton style={styles.button} onPress={() => setTypeAdd("")}>
<ThemedText>
Retour
</ThemedText>
</ThemedButton>
{typeAdd==="Chantier"? (
<AddChantier/>
):
(
<AddRessource ressourceType={typeAdd as 'Outil' | 'Machine' | 'Ouvrier'}/>
)}
</View>
}
</View>
</ThemedView>
) )
} }
const styles = StyleSheet.create({
back:{
height:"100%",
width:"100%",
},
container: {
flex: 1,
marginTop: Constants.statusBarHeight, //pour la barre menu du haut
},
button:{
padding:10,
borderRadius:10,
},
selectTypeAdd:{
gap:30,
padding:20
}
});

View File

@@ -6,9 +6,9 @@ import SetStatus from '@/components/setStatus';
import { ThemedView } from '@/components/theme/themed-view'; import { ThemedView } from '@/components/theme/themed-view';
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { StyleSheet, ScrollView, Button, TextInput, Text, View, Modal } from 'react-native'; import { StyleSheet, ScrollView, Button, TextInput, Text, View, Modal } from 'react-native';
import { useChantier } from '../ContextChantier'; import { useChantier } from '../../app/ContextChantier';
import { useRessources } from '../ContextRessource'; import { useRessources } from '../../app/ContextRessource';
import { useUser } from '../ContextUser'; import { useUser } from '../../app/ContextUser';
import { getRessources, getUsers, addChantier } from '@/services/ressourcesService'; import { getRessources, getUsers, addChantier } from '@/services/ressourcesService';
import { Chantier, Ressources, User } from '@/class/class'; import { Chantier, Ressources, User } from '@/class/class';
import { ThemedText } from '@/components/theme/themed-text'; import { ThemedText } from '@/components/theme/themed-text';
@@ -17,7 +17,7 @@ import { ThemedTextInput } from '@/components/theme/themed-textinput';
import DateTimePicker, { DateTimePickerEvent } from '@react-native-community/datetimepicker'; 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 Constants from 'expo-constants'; //pour connaître la taille de la barre menu de l'OS en haut
import SelectChafChantier from '@/components/selectChefChantier'; import SelectChafChantier from '@/components/add/select/selectChefChantier';
import SelectMachine from '@/components/selectMachine'; import SelectMachine from '@/components/selectMachine';
//Uniquement accessible par le RESPONSSABLE du chantier //Uniquement accessible par le RESPONSSABLE du chantier
@@ -182,10 +182,9 @@ const styles = StyleSheet.create({
}, },
container: { container: {
flex: 1, flex: 1,
marginTop: Constants.statusBarHeight, //pour la barre menu du haut
}, },
header: { header: {
marginTop:60, marginTop:30,
alignItems: "center", alignItems: "center",
paddingHorizontal: 20, paddingHorizontal: 20,
}, },

View File

@@ -1,13 +1,12 @@
import ChantierSummary from '@/components/chantierSummary'; import ChantierSummary from '@/components/chantierSummary';
import SelectChantier from '@/components/selectChantier'; import SelectChantier from '@/components/selectChantier';
import SetStatus from '@/components/setStatus';
import { ThemedView } from '@/components/theme/themed-view'; import { ThemedView } from '@/components/theme/themed-view';
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { StyleSheet, ScrollView, Button, TextInput, Text, View, Modal } from 'react-native'; import { StyleSheet, ScrollView, Button, TextInput, Text, View, Modal } from 'react-native';
import { useChantier } from '../ContextChantier'; import { useChantier } from '../../app/ContextChantier';
import { useRessources } from '../ContextRessource'; import { useRessources } from '../../app/ContextRessource';
import { useUser } from '../ContextUser'; import { useUser } from '../../app/ContextUser';
import { getRessources, getUsers, addChantier } from '@/services/ressourcesService'; import { getRessources, getUsers, addChantier } from '@/services/ressourcesService';
import { Chantier, Ressources, User } from '@/class/class'; import { Chantier, Ressources, User } from '@/class/class';
import { ThemedText } from '@/components/theme/themed-text'; import { ThemedText } from '@/components/theme/themed-text';
@@ -16,8 +15,8 @@ import { ThemedTextInput } from '@/components/theme/themed-textinput';
import DateTimePicker, { DateTimePickerEvent } from '@react-native-community/datetimepicker'; 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 Constants from 'expo-constants'; //pour connaître la taille de la barre menu de l'OS en haut
import SelectChafChantier from '@/components/selectChefChantier'; import SelectChafChantier from '@/components/add/select/selectChefChantier';
import SelectRessource from '@/components/selectRessource'; import SelectRessource from '@/components/add/select/selectRessource';
import { db } from '@/firebase_config'; import { db } from '@/firebase_config';
import { doc } from 'firebase/firestore'; import { doc } from 'firebase/firestore';
@@ -209,7 +208,10 @@ export default function AddChantier() {
<ThemedText style = {styles.inputName}>Ouvriers:</ThemedText> <ThemedText style = {styles.inputName}>Ouvriers:</ThemedText>
<SelectRessource style={styles.input} sendRessources={setOuviers} ressourceType="Ouvrier"/> <SelectRessource style={styles.input} sendRessources={setOuviers} ressourceType="Ouvrier"/>
</View> </View>
<View style = {styles.inputLine}>
<ThemedText style = {styles.inputName}>Outils:</ThemedText>
<SelectRessource style={styles.input} sendRessources={setOuviers} ressourceType="Outil"/>
</View>
<ThemedButton <ThemedButton
@@ -237,10 +239,9 @@ const styles = StyleSheet.create({
}, },
container: { container: {
flex: 1, flex: 1,
marginTop: Constants.statusBarHeight, //pour la barre menu du haut },
},
header: { header: {
marginTop:60, marginTop:30,
alignItems: "center", alignItems: "center",
paddingHorizontal: 20, paddingHorizontal: 20,
}, },

View File

@@ -6,9 +6,9 @@ import SetStatus from '@/components/setStatus';
import { ThemedView } from '@/components/theme/themed-view'; import { ThemedView } from '@/components/theme/themed-view';
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { StyleSheet, ScrollView, Button, TextInput, Text, View, Modal } from 'react-native'; import { StyleSheet, ScrollView, Button, TextInput, Text, View, Modal } from 'react-native';
import { useChantier } from '../ContextChantier'; import { useChantier } from '@/app/ContextChantier';
import { useRessources } from '../ContextRessource'; import { useRessources } from '@/app/ContextRessource';
import { useUser } from '../ContextUser'; import { useUser } from '@/app/ContextUser';
import { getRessources, getUsers, addChantier } from '@/services/ressourcesService'; import { getRessources, getUsers, addChantier } from '@/services/ressourcesService';
import { Chantier, Ressources, User } from '@/class/class'; import { Chantier, Ressources, User } from '@/class/class';
import { ThemedText } from '@/components/theme/themed-text'; import { ThemedText } from '@/components/theme/themed-text';
@@ -17,19 +17,37 @@ import { ThemedTextInput } from '@/components/theme/themed-textinput';
import DateTimePicker, { DateTimePickerEvent } from '@react-native-community/datetimepicker'; 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 Constants from 'expo-constants'; //pour connaître la taille de la barre menu de l'OS en haut
import SelectChafChantier from '@/components/selectChefChantier'; import SelectChafChantier from '@/components/add/select/selectChefChantier';
import SelectMachine from '@/components/selectMachine'; import SelectMachine from '@/components/selectMachine';
//Uniquement accessible par le RESPONSSABLE du chantier
//Pour créer ou modifier un chantier type Dictionary = {
export default function AddRessource() { [key: string]: string;
};
const exempleNom: Dictionary = {
'Outil': "Boîte à outils",
'Machine': "Bulldozer",
'Ouvrier': "Charpentier"
};
const exempleQte: Dictionary = {
'Outil': "12",
'Machine': "1",
'Ouvrier': "12"
};
type Props = {
ressourceType: 'Outil' | 'Machine' | 'Ouvrier';
};
export default function AddRessource({ressourceType, ...otherProps }: Props) {
const { ressources, setRessources } = useRessources(); const { ressources, setRessources } = useRessources();
const [editMode,setEditMode] = useState(false); const [editMode,setEditMode] = useState(false);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [nom, setNom] = useState(''); const [nom, setNom] = useState('');
const [type, setType] = useState('');
const [quantite, setQuantite] = useState(''); const [quantite, setQuantite] = useState('');
const [quantiteDisponible,setQuantiteDisponible] = useState(''); const [quantiteDisponible,setQuantiteDisponible] = useState('');
const [openConfirmation,setOpenConfirmation] = useState(false); const [openConfirmation,setOpenConfirmation] = useState(false);
@@ -53,7 +71,7 @@ export default function AddRessource() {
setOpenConfirmation(false); setOpenConfirmation(false);
} }
function isValidRessource():Boolean{ function isValidRessource():Boolean{
return nom!= "" && type!= "" && quantite != "" && quantiteDisponible != "" return nom!= "" && quantite != "" && quantiteDisponible != ""
} }
const renderValidationScreen = () => { const renderValidationScreen = () => {
@@ -61,12 +79,10 @@ export default function AddRessource() {
<Modal transparent={true} > <Modal transparent={true} >
<View style={styles.overlay}> <View style={styles.overlay}>
<ThemedView style={styles.overlayView}> <ThemedView style={styles.overlayView}>
<ThemedText style={{fontSize: 25}}>Créer la nouvelle ressource suivante ? :</ThemedText> <ThemedText style={{fontSize: 25}}>Créer la nouvelle {ressourceType} suivante ? :</ThemedText>
<ThemedView lvl={2} style={styles.summaryNewChantier}> <ThemedView lvl={2} style={styles.summaryNewChantier}>
<ThemedText style={{fontSize: 20}}>Nom: {nom===''?"NONE":nom}</ThemedText> <ThemedText style={{fontSize: 20}}>Nom: {nom===''?"NONE":nom}</ThemedText>
<ThemedText style={{fontSize: 20}}>Type: {type===''?"NONE":type}</ThemedText> <ThemedText style={{fontSize: 20}}>Quantité Total: {quantite===''?"0":quantite} </ThemedText>
<ThemedText style={{fontSize: 20}}>quantite: {quantite===''?"0":quantite} </ThemedText>
<ThemedText style={{fontSize: 20}}>quantite disponible: {quantiteDisponible===''?"NONE":quantiteDisponible}</ThemedText>
</ThemedView> </ThemedView>
<View style={styles.overlayView}> <View style={styles.overlayView}>
<ThemedButton lvl={2} border={5} style={styles.buttonValid} onPress={() => onConfirm()}> <ThemedButton lvl={2} border={5} style={styles.buttonValid} onPress={() => onConfirm()}>
@@ -107,12 +123,10 @@ return (
<ThemedText style = {styles.text}> <ThemedText style = {styles.text}>
{editMode? "Edition d'un chantier" {editMode? "Edition d'un chantier"
:"Ajouter une nouvelle ressource"} :"Ajouter une ressource " + ressourceType}
</ThemedText> </ThemedText>
{renderInut("Nom","Marteau",nom,setNom,false)} {renderInut("Nom",exempleNom[ressourceType],nom,setNom,false)}
{renderInut("Type","outil",type,setType,false)} {renderInut("Quantité Total",exempleQte[ressourceType],quantite,setQuantite,true)}
{renderInut("Quantité ","14",quantite,setQuantite,true)}
{renderInut("Quantité disponible","14",quantiteDisponible,setQuantiteDisponible,true)}
<ThemedButton <ThemedButton
lvl={1} lvl={1}
shadow={true} shadow={true}
@@ -138,10 +152,9 @@ const styles = StyleSheet.create({
}, },
container: { container: {
flex: 1, flex: 1,
marginTop: Constants.statusBarHeight, //pour la barre menu du haut
}, },
header: { header: {
marginTop:60, marginTop:30,
alignItems: "center", alignItems: "center",
paddingHorizontal: 20, paddingHorizontal: 20,
}, },

View File

@@ -2,8 +2,8 @@ import { Chantier, Ressources } from '@/class/class';
import { ThemedView, } from '@/components/theme/themed-view'; import { ThemedView, } from '@/components/theme/themed-view';
import React, { useState } from 'react'; import React, { useState } from 'react';
import { Image, StyleProp, StyleSheet, View, ViewStyle } from 'react-native'; import { Image, StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
import { ThemedText } from './theme/themed-text'; import { ThemedText } from '@/components/theme/themed-text';
import { ThemedButton } from './theme/themed-button'; import { ThemedButton } from '@/components/theme/themed-button';
type RessourcesQte = [Ressources, number]; type RessourcesQte = [Ressources, number];

View File

@@ -3,9 +3,9 @@ import { changeChantierStatus } from "@/services/ressourcesService";
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { Dimensions, FlatList, LayoutAnimation, Modal, Pressable, ScrollView, StyleProp, StyleSheet, View, ViewStyle } from 'react-native'; import { Dimensions, FlatList, LayoutAnimation, Modal, Pressable, ScrollView, StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
import Animated, { LinearTransition } from 'react-native-reanimated'; import Animated, { LinearTransition } from 'react-native-reanimated';
import { ThemedButton } from './theme/themed-button'; import { ThemedButton } from '../../theme/themed-button';
import { ThemedText } from './theme/themed-text'; import { ThemedText } from '../../theme/themed-text';
import { ThemedView } from "./theme/themed-view"; import { ThemedView } from "../../theme/themed-view";
import { User } from '@/class/class'; import { User } from '@/class/class';
import { getUsers } from "@/services/ressourcesService"; import { getUsers } from "@/services/ressourcesService";

View File

@@ -3,12 +3,12 @@ import { changeChantierStatus } from "@/services/ressourcesService";
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { Dimensions, FlatList, LayoutAnimation, Modal, Pressable, ScrollView, StyleProp, StyleSheet, View, ViewStyle } from 'react-native'; import { Dimensions, FlatList, LayoutAnimation, Modal, Pressable, ScrollView, StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
import Animated, { LinearTransition } from 'react-native-reanimated'; import Animated, { LinearTransition } from 'react-native-reanimated';
import { ThemedButton } from './theme/themed-button'; import { ThemedButton } from '@/components/theme/themed-button';
import { ThemedText } from './theme/themed-text'; import { ThemedText } from '@/components/theme/themed-text';
import { ThemedView } from "./theme/themed-view"; import { ThemedView } from "@/components/theme/themed-view";
import { Ressources, User } from '@/class/class'; import { Ressources, User } from '@/class/class';
import { getRessources } from "@/services/ressourcesService"; import { getRessources } from "@/services/ressourcesService";
import RessourceSummary from './ressourceSummary'; import RessourceSummary from '@/components/add/select/ressourceSummary';
const { width, height } = Dimensions.get("window"); const { width, height } = Dimensions.get("window");

View File

@@ -8,9 +8,7 @@ import { ThemedText } from './theme/themed-text';
import { ThemedView } from "./theme/themed-view"; import { ThemedView } from "./theme/themed-view";
import { Ressources, User } from '@/class/class'; import { Ressources, User } from '@/class/class';
import { getRessources } from "@/services/ressourcesService"; import { getRessources } from "@/services/ressourcesService";
import RessourceSummary from './ressourceSummary'; import RessourceSummary from '@/components/add/select/ressourceSummary';
const { width, height } = Dimensions.get("window");
type RessourcesQte = [Ressources, number]; type RessourcesQte = [Ressources, number];