clean gestionnaire_ressource et ouvrier, ajout de select Chantier + templateScreen
This commit is contained in:
@@ -4,10 +4,11 @@ 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 { useLocalSearchParams, useRouter } from "expo-router";
|
||||
import React, { useMemo, useState } from "react";
|
||||
import { FlatList, Image, StyleSheet, Text } from "react-native";
|
||||
import { FlatList, Image, StyleSheet, Text, View } from "react-native";
|
||||
import rawConcerts from "../../data/concerts.json";
|
||||
|
||||
import { useChantier } from "../ContextChantier";
|
||||
import SelectChantier from "@/components/selectChantier";
|
||||
|
||||
type Concert = {
|
||||
group: string;
|
||||
@@ -56,36 +57,45 @@ export default function GestionOuvrier() {
|
||||
};
|
||||
|
||||
return (
|
||||
<ThemedView lvl={3} style={styles.container}>
|
||||
<FlatList
|
||||
data={filteredData}
|
||||
renderItem={renderItem}
|
||||
keyExtractor={(_, index) => index.toString()}
|
||||
contentContainerStyle={{ paddingBottom: 40 }}
|
||||
ListHeaderComponent={
|
||||
<ThemedView opacity="00" style={styles.header}>
|
||||
<ThemedView lvl={3} style={styles.back}>
|
||||
<View style={styles.container}>
|
||||
<View style={{width:"100%", position: 'absolute'}}>
|
||||
<SelectChantier></SelectChantier>
|
||||
</View>
|
||||
|
||||
<ThemedView style={styles.inputBack} shadow={true}>
|
||||
<ThemedTextInput
|
||||
lvl={0}
|
||||
style={styles.input}
|
||||
placeholder="Rechercher un artisant..."
|
||||
value={search}
|
||||
onChangeText={setSearch}
|
||||
/>
|
||||
</ThemedView>
|
||||
</ThemedView>
|
||||
}
|
||||
ListEmptyComponent={
|
||||
<Text style={styles.empty}>Aucun résultat n'a été trouvé</Text>
|
||||
}
|
||||
/>
|
||||
|
||||
<FlatList
|
||||
data={filteredData}
|
||||
renderItem={renderItem}
|
||||
keyExtractor={(_, index) => index.toString()}
|
||||
contentContainerStyle={{ paddingBottom: 40 }}
|
||||
ListHeaderComponent={
|
||||
<View style={styles.header}>
|
||||
<ThemedView style={styles.inputBack} shadow={true}>
|
||||
<ThemedTextInput
|
||||
lvl={0}
|
||||
style={styles.input}
|
||||
placeholder="Rechercher un artisant..."
|
||||
value={search}
|
||||
onChangeText={setSearch}
|
||||
/>
|
||||
</ThemedView>
|
||||
</View>
|
||||
}
|
||||
ListEmptyComponent={
|
||||
<Text style={styles.empty}>Aucun résultat n'a été trouvé</Text>
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
</ThemedView>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
back:{
|
||||
height:"100%",
|
||||
width:"100%",
|
||||
},
|
||||
container: {
|
||||
flex: 1,
|
||||
marginTop: Constants.statusBarHeight, //pour la barre menu du haut
|
||||
@@ -93,7 +103,7 @@ const styles = StyleSheet.create({
|
||||
},
|
||||
header: {
|
||||
marginTop: 60,
|
||||
marginBottom: 20,
|
||||
marginBottom: 10,
|
||||
alignItems: "center",
|
||||
paddingHorizontal: 20,
|
||||
},
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import { ThemedText } from "@/components/themed-text";
|
||||
import { ThemedTextInput } from "@/components/themed-textinput";
|
||||
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 { ThemedButton } from "@/components/themed-button";
|
||||
import { useLocalSearchParams, useRouter } from "expo-router";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { FlatList, Image, StyleSheet, Text } from "react-native";
|
||||
import { FlatList, Image, StyleSheet, Text, View } from "react-native";
|
||||
import { Ressources } from "../../class/class";
|
||||
import { getRessources } from "../../services/ressourcesService";
|
||||
import SelectChantier from "@/components/selectChantier";
|
||||
|
||||
export default function GestionnaireRessource() {
|
||||
const { nom, prenom } = useLocalSearchParams();
|
||||
@@ -50,87 +53,98 @@ export default function GestionnaireRessource() {
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<ThemedView lvl={3} style={styles.container}>
|
||||
{/* Overlay menu filtre */}
|
||||
{showFilterMenu && (
|
||||
<ThemedView lvl={2} style={styles.filterMenuOverlay}>
|
||||
<ThemedView lvl={1} style={styles.filterMenu}>
|
||||
<Text style={styles.filterTitle}>Filtrer par type</Text>
|
||||
{["tout", "Outil", "Machine"].map((t) => (
|
||||
<ThemedView lvl={3} style={styles.back}>
|
||||
<View style={styles.container}>
|
||||
|
||||
<View style={{width:"100%", position: 'absolute'}}>
|
||||
<SelectChantier></SelectChantier>
|
||||
</View>
|
||||
|
||||
|
||||
{/* Overlay menu filtre */}
|
||||
{showFilterMenu && (
|
||||
<ThemedView lvl={2} style={styles.filterMenuOverlay}>
|
||||
<ThemedView lvl={5} style={styles.filterMenu}>
|
||||
<ThemedText style={styles.filterTitle}>Filtrer par type</ThemedText>
|
||||
{["tout", "Outil", "Machine"].map((t) => (
|
||||
<ThemedButton
|
||||
key={t}
|
||||
lvl={1}
|
||||
shadow={true}
|
||||
style={{ padding: 10, borderRadius: 8, marginBottom: 10 }}
|
||||
onPress={() => {
|
||||
setFilterType(t);
|
||||
setShowFilterMenu(false);
|
||||
}}
|
||||
>
|
||||
<ThemedText style={{ textAlign: "center" }}>{t}</ThemedText>
|
||||
</ThemedButton>
|
||||
))}
|
||||
|
||||
{/* Bouton "Fermer" remplacé */}
|
||||
<ThemedButton
|
||||
key={t}
|
||||
lvl={1}
|
||||
shadow={true}
|
||||
style={{ padding: 10, borderRadius: 8, marginBottom: 10 }}
|
||||
onPress={() => {
|
||||
setFilterType(t);
|
||||
setShowFilterMenu(false);
|
||||
}}
|
||||
style={{ padding: 10, borderRadius: 8 }}
|
||||
onPress={() => setShowFilterMenu(false)}
|
||||
>
|
||||
<ThemedText style={{ textAlign: "center" }}>{t}</ThemedText>
|
||||
<ThemedText style={{ textAlign: "center" }}>Fermer</ThemedText>
|
||||
</ThemedButton>
|
||||
))}
|
||||
|
||||
{/* Bouton "Fermer" remplacé */}
|
||||
<ThemedButton
|
||||
lvl={1}
|
||||
shadow={true}
|
||||
style={{ padding: 10, borderRadius: 8 }}
|
||||
onPress={() => setShowFilterMenu(false)}
|
||||
>
|
||||
<ThemedText style={{ textAlign: "center" }}>Fermer</ThemedText>
|
||||
</ThemedButton>
|
||||
</ThemedView>
|
||||
</ThemedView>
|
||||
)}
|
||||
|
||||
<FlatList
|
||||
data={filteredData}
|
||||
renderItem={renderRessource}
|
||||
keyExtractor={(_, index) => index.toString()}
|
||||
contentContainerStyle={{ paddingBottom: 40 }}
|
||||
ListHeaderComponent={
|
||||
<ThemedView opacity="00" style={styles.header}>
|
||||
<ThemedText style={styles.text}>
|
||||
Bonjour {prenom} {nom}
|
||||
</ThemedText>
|
||||
|
||||
{/* Bouton filtre en haut à droite */}
|
||||
<ThemedButton
|
||||
lvl={1}
|
||||
shadow={true}
|
||||
style={{ padding: 10, borderRadius: 8, marginBottom: 10 }}
|
||||
onPress={() => setShowFilterMenu(true)}
|
||||
>
|
||||
<ThemedText>{`Filtre: ${filterType}`}</ThemedText>
|
||||
</ThemedButton>
|
||||
|
||||
<ThemedView lvl={1} shadow={true} style={styles.inputBack}>
|
||||
<ThemedTextInput
|
||||
lvl={0}
|
||||
style={styles.input}
|
||||
placeholder="Rechercher une ressource..."
|
||||
value={search}
|
||||
onChangeText={setSearch}
|
||||
/>
|
||||
</ThemedView>
|
||||
</ThemedView>
|
||||
}
|
||||
ListEmptyComponent={
|
||||
<ThemedText style={styles.empty}>Aucun résultat trouvé</ThemedText>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
<FlatList
|
||||
data={filteredData}
|
||||
renderItem={renderRessource}
|
||||
keyExtractor={(_, index) => index.toString()}
|
||||
contentContainerStyle={{ paddingBottom: 40 }}
|
||||
ListHeaderComponent={
|
||||
<View style={styles.header}>
|
||||
<ThemedView lvl={1} shadow={true} style={styles.inputBack}>
|
||||
<ThemedTextInput
|
||||
lvl={0}
|
||||
style={styles.input}
|
||||
placeholder="Rechercher une ressource..."
|
||||
value={search}
|
||||
onChangeText={setSearch}
|
||||
/>
|
||||
</ThemedView>
|
||||
|
||||
{/* Bouton filtre en haut à droite */}
|
||||
<ThemedButton
|
||||
lvl={1}
|
||||
shadow={true}
|
||||
style={{ padding: 10, borderRadius: 8, marginTop: 10 }}
|
||||
onPress={() => setShowFilterMenu(true)}
|
||||
>
|
||||
<ThemedText>{`Filtre: ${filterType}`}</ThemedText>
|
||||
</ThemedButton>
|
||||
</View>
|
||||
}
|
||||
ListEmptyComponent={
|
||||
<ThemedText style={styles.empty}>Aucun résultat trouvé</ThemedText>
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
</ThemedView>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
back:{
|
||||
height:"100%",
|
||||
width:"100%",
|
||||
},
|
||||
container: {
|
||||
flex: 1,
|
||||
marginTop: 60,
|
||||
marginTop: Constants.statusBarHeight,
|
||||
},
|
||||
header: {
|
||||
marginTop: 60,
|
||||
marginBottom: 20,
|
||||
alignItems: "center",
|
||||
paddingHorizontal: 20,
|
||||
@@ -191,7 +205,6 @@ const styles = StyleSheet.create({
|
||||
width: "80%",
|
||||
borderRadius: 12,
|
||||
padding: 20,
|
||||
backgroundColor: "#fff",
|
||||
},
|
||||
filterTitle: {
|
||||
fontSize: 18,
|
||||
|
||||
31
app/(tabs)/templateSreen.tsx
Normal file
31
app/(tabs)/templateSreen.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
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 } from "react-native";
|
||||
|
||||
import { useChantier } from "../ContextChantier";
|
||||
|
||||
|
||||
export default function TemplateScreen() {
|
||||
const { chantier, setChantier } = useChantier();
|
||||
|
||||
|
||||
return (
|
||||
<ThemedView lvl={3} style={styles.back}>
|
||||
<View style={styles.container}>
|
||||
|
||||
</View>
|
||||
</ThemedView>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
back:{
|
||||
height:"100%",
|
||||
width:"100%",
|
||||
},
|
||||
container: {
|
||||
flex: 1,
|
||||
marginTop: Constants.statusBarHeight, //pour la barre menu du haut
|
||||
},
|
||||
});
|
||||
@@ -4,6 +4,7 @@ import { getChantiers } from "@/services/ressourcesService";
|
||||
import { useRouter } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import {
|
||||
ActivityIndicator,
|
||||
Dimensions,
|
||||
Image,
|
||||
Pressable,
|
||||
@@ -34,8 +35,10 @@ export default function SelectChantier() {
|
||||
const { chantier, setChantier } = useChantier();
|
||||
const [search, setSearch] = useState("");
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const [isLoaded, setIsLoaded] = useState(false);
|
||||
const [chantiers, setChantiers] = useState<Chantier[]>([]);
|
||||
const router = useRouter();
|
||||
|
||||
|
||||
const AnimatedThemedView = Animated.createAnimatedComponent(ThemedView);
|
||||
const AnimatedThemedText = Animated.createAnimatedComponent(ThemedText);
|
||||
@@ -44,9 +47,11 @@ export default function SelectChantier() {
|
||||
Animated.createAnimatedComponent(ThemedTextInput);
|
||||
|
||||
async function onPressOpen(){
|
||||
setIsLoaded(false);
|
||||
setIsOpen(!isOpen);
|
||||
if(!isOpen){
|
||||
const updatedChantiers = await getChantiers();
|
||||
setIsLoaded(true);
|
||||
setChantiers(updatedChantiers)
|
||||
}
|
||||
}
|
||||
@@ -78,7 +83,6 @@ export default function SelectChantier() {
|
||||
<Image source={{ uri:"https://cdn.discordapp.com/attachments/1425108443571945644/1427207643180826757/raw.png?ex=69392bb2&is=6937da32&hm=dcc09e76d3dca89d2418947b46efbd38673b9dc559027724b2e51d493b173bc9&" /*chantier.urlImg*/ }} style={styles.image} />
|
||||
</View>
|
||||
<View>
|
||||
<ThemedText>{chantier.chef != null ? "true" : "false"}</ThemedText>
|
||||
<ThemedText>Adresse: {chantier.adresse}</ThemedText>
|
||||
<ThemedText>Chef de chantier: {chantier.chef.last_name}{" "}{chantier.chef.name}</ThemedText>
|
||||
<ThemedText>État: {chantier.etat}</ThemedText>
|
||||
@@ -107,14 +111,16 @@ export default function SelectChantier() {
|
||||
+
|
||||
</ThemedText>
|
||||
</ThemedButton>
|
||||
|
||||
<ThemedView lvl={2} style={styles.list}>
|
||||
<View style={styles.list}>
|
||||
{isLoaded?
|
||||
<ScrollView contentContainerStyle={styles.chantiersList}>
|
||||
{chantiers.map((chantier, index) =>
|
||||
renderChantier(chantier, index)
|
||||
)}
|
||||
</ScrollView>
|
||||
</ThemedView>
|
||||
: <ActivityIndicator style={{height:"100%"}} color="#808080" size="large" />}
|
||||
</View>
|
||||
|
||||
</View>
|
||||
)}
|
||||
</AnimatedThemedView>
|
||||
|
||||
@@ -70,7 +70,7 @@ export default function SetStatus() {
|
||||
<Modal transparent={true} >
|
||||
<View style={styles.overlay}>
|
||||
<ThemedView style={styles.overlayView}>
|
||||
<ThemedText style={{fontSize: 25}}>Changer l'était du chantier en {tempStatus} ?</ThemedText>
|
||||
<ThemedText style={{fontSize: 25}}>Changer l'état du chantier en {tempStatus} ?</ThemedText>
|
||||
<View style={styles.overlayView}>
|
||||
<ThemedButton lvl={2} border={5} style={styles.buttonValid} onPress={() => onConfirm()}>
|
||||
<ThemedText style={{fontSize: 25}}>Confirmer</ThemedText>
|
||||
|
||||
Reference in New Issue
Block a user