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 Home from './home';
import MapScreen from './mapScreen';
import AddChantier from './addChantier';
import AddRessource from './addRessource';
import AddArtisant from './addArtisant';
import AntDesign from '@expo/vector-icons/AntDesign';
import { UserProvider } from '../ContextUser';
import { ChantierProvider } from '../ContextChantier';
import { RessourcesProvider } from '../ContextRessource';
import AddScreen from './addScreen';
const Tabs = createBottomTabNavigator();
@@ -68,8 +63,8 @@ export default function TabLayout() {
>
</Tabs.Screen>
<Tabs.Screen
name="addChantier"
component={AddChantier}
name="Ajouter"
component={AddScreen}
options={{
title: 'Ajouter',
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>
);

View File

@@ -1,35 +1,81 @@
import { ThemedButton } from "@/components/theme/themed-button";
import { ThemedText } from "@/components/theme/themed-text";
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() {
const [typeAdd, setTypeAdd] = useState('');
return(
<View>
<ThemedButton>
<ThemedText>
Ajouter un chantier
</ThemedText>
</ThemedButton>
<ThemedButton>
<ThemedText>
Ajouter un équipement
</ThemedText>
</ThemedButton>
<ThemedButton>
<ThemedText>
Ajouter un vehicule ou machine
</ThemedText>
</ThemedButton>
<ThemedButton>
<ThemedText>
Ajouter un ouvrier
</ThemedText>
</ThemedButton>
</View>
<ThemedView lvl={3} style={styles.back}>
<View style={styles.container}>
{typeAdd===""? (
<View style={styles.selectTypeAdd} >
<ThemedButton style={styles.button} onPress={() => setTypeAdd("Chantier")}>
<ThemedText>
Ajouter un chantier
</ThemedText>
</ThemedButton>
<ThemedButton style={styles.button} onPress={() => setTypeAdd("Outil")}>
<ThemedText>
Ajouter un équipement
</ThemedText>
</ThemedButton>
<ThemedButton style={styles.button} onPress={() => setTypeAdd("Machine")}>
<ThemedText>
Ajouter un vehicule ou machine
</ThemedText>
</ThemedButton>
<ThemedButton style={styles.button} onPress={() => setTypeAdd("Ouvrier")}>
<ThemedText>
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 React, { useEffect, useState } from 'react';
import { StyleSheet, ScrollView, Button, TextInput, Text, View, Modal } from 'react-native';
import { useChantier } from '../ContextChantier';
import { useRessources } from '../ContextRessource';
import { useUser } from '../ContextUser';
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';
@@ -17,7 +17,7 @@ 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/selectChefChantier';
import SelectChafChantier from '@/components/add/select/selectChefChantier';
import SelectMachine from '@/components/selectMachine';
//Uniquement accessible par le RESPONSSABLE du chantier
@@ -182,10 +182,9 @@ const styles = StyleSheet.create({
},
container: {
flex: 1,
marginTop: Constants.statusBarHeight, //pour la barre menu du haut
},
header: {
marginTop:60,
marginTop:30,
alignItems: "center",
paddingHorizontal: 20,
},

View File

@@ -1,13 +1,12 @@
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 '../ContextChantier';
import { useRessources } from '../ContextRessource';
import { useUser } from '../ContextUser';
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';
@@ -16,8 +15,8 @@ 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/selectChefChantier';
import SelectRessource from '@/components/selectRessource';
import SelectChafChantier from '@/components/add/select/selectChefChantier';
import SelectRessource from '@/components/add/select/selectRessource';
import { db } from '@/firebase_config';
import { doc } from 'firebase/firestore';
@@ -209,7 +208,10 @@ export default function AddChantier() {
<ThemedText style = {styles.inputName}>Ouvriers:</ThemedText>
<SelectRessource style={styles.input} sendRessources={setOuviers} ressourceType="Ouvrier"/>
</View>
<View style = {styles.inputLine}>
<ThemedText style = {styles.inputName}>Outils:</ThemedText>
<SelectRessource style={styles.input} sendRessources={setOuviers} ressourceType="Outil"/>
</View>
<ThemedButton
@@ -237,10 +239,9 @@ const styles = StyleSheet.create({
},
container: {
flex: 1,
marginTop: Constants.statusBarHeight, //pour la barre menu du haut
},
},
header: {
marginTop:60,
marginTop:30,
alignItems: "center",
paddingHorizontal: 20,
},

View File

@@ -6,9 +6,9 @@ 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 '../ContextChantier';
import { useRessources } from '../ContextRessource';
import { useUser } from '../ContextUser';
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';
@@ -17,19 +17,37 @@ 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/selectChefChantier';
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 AddRessource() {
type Dictionary = {
[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 [editMode,setEditMode] = useState(false);
const [loading, setLoading] = useState(false);
const [nom, setNom] = useState('');
const [type, setType] = useState('');
const [quantite, setQuantite] = useState('');
const [quantiteDisponible,setQuantiteDisponible] = useState('');
const [openConfirmation,setOpenConfirmation] = useState(false);
@@ -53,7 +71,7 @@ export default function AddRessource() {
setOpenConfirmation(false);
}
function isValidRessource():Boolean{
return nom!= "" && type!= "" && quantite != "" && quantiteDisponible != ""
return nom!= "" && quantite != "" && quantiteDisponible != ""
}
const renderValidationScreen = () => {
@@ -61,12 +79,10 @@ export default function AddRessource() {
<Modal transparent={true} >
<View style={styles.overlay}>
<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}>
<ThemedText style={{fontSize: 20}}>Nom: {nom===''?"NONE":nom}</ThemedText>
<ThemedText style={{fontSize: 20}}>Type: {type===''?"NONE":type}</ThemedText>
<ThemedText style={{fontSize: 20}}>quantite: {quantite===''?"0":quantite} </ThemedText>
<ThemedText style={{fontSize: 20}}>quantite disponible: {quantiteDisponible===''?"NONE":quantiteDisponible}</ThemedText>
<ThemedText style={{fontSize: 20}}>Quantité Total: {quantite===''?"0":quantite} </ThemedText>
</ThemedView>
<View style={styles.overlayView}>
<ThemedButton lvl={2} border={5} style={styles.buttonValid} onPress={() => onConfirm()}>
@@ -107,12 +123,10 @@ return (
<ThemedText style = {styles.text}>
{editMode? "Edition d'un chantier"
:"Ajouter une nouvelle ressource"}
:"Ajouter une ressource " + ressourceType}
</ThemedText>
{renderInut("Nom","Marteau",nom,setNom,false)}
{renderInut("Type","outil",type,setType,false)}
{renderInut("Quantité ","14",quantite,setQuantite,true)}
{renderInut("Quantité disponible","14",quantiteDisponible,setQuantiteDisponible,true)}
{renderInut("Nom",exempleNom[ressourceType],nom,setNom,false)}
{renderInut("Quantité Total",exempleQte[ressourceType],quantite,setQuantite,true)}
<ThemedButton
lvl={1}
shadow={true}
@@ -138,10 +152,9 @@ const styles = StyleSheet.create({
},
container: {
flex: 1,
marginTop: Constants.statusBarHeight, //pour la barre menu du haut
},
header: {
marginTop:60,
marginTop:30,
alignItems: "center",
paddingHorizontal: 20,
},

View File

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

View File

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

View File

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