merge + home
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
import SelectChantier from '@/components/selectChantier';
|
||||
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 { useLocalSearchParams, useRouter } from 'expo-router';
|
||||
import React, { useMemo, useState } from 'react';
|
||||
import { Button, FlatList, Image, StyleSheet, Text } from 'react-native';
|
||||
import rawConcerts from '../../data/concerts.json';
|
||||
|
||||
import { useChantier } from '../ContextChantier';
|
||||
import SelectChantier from "@/components/selectChantier";
|
||||
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 { useLocalSearchParams, useRouter } from "expo-router";
|
||||
import React, { useMemo, useState } from "react";
|
||||
import { FlatList, Image, StyleSheet, Text } from "react-native";
|
||||
import rawConcerts from "../../data/concerts.json";
|
||||
|
||||
import { useChantier } from "../ContextChantier";
|
||||
|
||||
type Concert = {
|
||||
group: string;
|
||||
@@ -23,14 +22,11 @@ type Concert = {
|
||||
};
|
||||
|
||||
export default function BonjourScreen() {
|
||||
|
||||
const router = useRouter();
|
||||
const { nom, prenom } = useLocalSearchParams(); // Recup data ecran precedent
|
||||
const [search, setSearch] = useState('');
|
||||
const [search, setSearch] = useState("");
|
||||
const { chantier, setChantier } = useChantier();
|
||||
|
||||
|
||||
|
||||
const concertsData: Concert[] = Array.isArray(rawConcerts)
|
||||
? (rawConcerts as Concert[])
|
||||
: [];
|
||||
@@ -40,32 +36,29 @@ export default function BonjourScreen() {
|
||||
const q = search.trim().toLowerCase();
|
||||
if (!q) return concertsData;
|
||||
return concertsData.filter(
|
||||
(item) => !!item && (item.group ?? '').toLowerCase().includes(q)
|
||||
(item) => !!item && (item.group ?? "").toLowerCase().includes(q)
|
||||
);
|
||||
}, [concertsData, search]);
|
||||
|
||||
|
||||
const renderItem = ({ item, index }: { item?: Concert; index: number }) => {
|
||||
const renderItem = ({ item, index }: { item?: Concert; index: number }) => {
|
||||
if (!item) {
|
||||
return null;
|
||||
}
|
||||
return(
|
||||
<ThemedView lvl={1} shadow={true} style={styles.card}>
|
||||
<Image source={{ uri: item.Image }} style={styles.image} />
|
||||
<ThemedView lvl={1} style={styles.info}>
|
||||
<ThemedText style={styles.group}>{item.group}</ThemedText>
|
||||
<ThemedText>{item.date}</ThemedText>
|
||||
<ThemedText>{item.location}</ThemedText>
|
||||
<ThemedText>Prix : {item.price} €</ThemedText>
|
||||
<ThemedText>Places restantes : {item.ticketsLeft}</ThemedText>
|
||||
return (
|
||||
<ThemedView lvl={1} shadow={true} style={styles.card}>
|
||||
<Image source={{ uri: item.Image }} style={styles.image} />
|
||||
<ThemedView lvl={1} style={styles.info}>
|
||||
<ThemedText style={styles.group}>{item.group}</ThemedText>
|
||||
<ThemedText>{item.date}</ThemedText>
|
||||
<ThemedText>{item.location}</ThemedText>
|
||||
<ThemedText>Prix : {item.price} €</ThemedText>
|
||||
<ThemedText>Places restantes : {item.ticketsLeft}</ThemedText>
|
||||
</ThemedView>
|
||||
</ThemedView>
|
||||
</ThemedView>);
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
return(
|
||||
return (
|
||||
<ThemedView lvl={3} style={styles.container}>
|
||||
<FlatList
|
||||
data={filteredData}
|
||||
@@ -75,7 +68,7 @@ export default function BonjourScreen() {
|
||||
ListHeaderComponent={
|
||||
<ThemedView opacity="00" style={styles.header}>
|
||||
<ThemedText style={styles.text}>
|
||||
Bonjour {prenom} {nom} {chantier&&chantier.chef.nom}
|
||||
Bonjour {prenom} {nom} {chantier && chantier.chef.name}
|
||||
</ThemedText>
|
||||
|
||||
<ThemedView style={styles.inputBack} shadow={true}>
|
||||
@@ -94,14 +87,17 @@ export default function BonjourScreen() {
|
||||
}
|
||||
/>
|
||||
|
||||
|
||||
|
||||
<ThemedView style={{width:"100%", position: 'absolute', backgroundColor:'transparent',}}>
|
||||
<SelectChantier ></SelectChantier>
|
||||
<ThemedView
|
||||
style={{
|
||||
width: "100%",
|
||||
position: "absolute",
|
||||
backgroundColor: "transparent",
|
||||
}}
|
||||
>
|
||||
<SelectChantier></SelectChantier>
|
||||
</ThemedView>
|
||||
|
||||
</ThemedView>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
@@ -113,21 +109,21 @@ const styles = StyleSheet.create({
|
||||
header: {
|
||||
marginTop: 60,
|
||||
marginBottom: 20,
|
||||
alignItems: 'center',
|
||||
alignItems: "center",
|
||||
paddingHorizontal: 20,
|
||||
},
|
||||
text: {
|
||||
fontSize: 22,
|
||||
fontWeight: 'bold',
|
||||
fontWeight: "bold",
|
||||
marginBottom: 10,
|
||||
},
|
||||
inputBack:{
|
||||
width:"100%",
|
||||
borderRadius:10,
|
||||
backgroundColor:'transparent'
|
||||
inputBack: {
|
||||
width: "100%",
|
||||
borderRadius: 10,
|
||||
backgroundColor: "transparent",
|
||||
},
|
||||
input: {
|
||||
width: '100%',
|
||||
width: "100%",
|
||||
//borderWidth: 1,
|
||||
//borderColor: '#ccc',
|
||||
borderRadius: 10,
|
||||
@@ -135,7 +131,7 @@ const styles = StyleSheet.create({
|
||||
fontSize: 16,
|
||||
},
|
||||
card: {
|
||||
flexDirection: 'row',
|
||||
flexDirection: "row",
|
||||
marginHorizontal: 20,
|
||||
marginBottom: 15,
|
||||
//borderWidth: 1,
|
||||
@@ -143,7 +139,6 @@ const styles = StyleSheet.create({
|
||||
borderRadius: 10,
|
||||
padding: 10,
|
||||
//backgroundColor: '#fafafa',
|
||||
|
||||
},
|
||||
image: {
|
||||
width: 80,
|
||||
@@ -153,10 +148,10 @@ const styles = StyleSheet.create({
|
||||
},
|
||||
info: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
justifyContent: "center",
|
||||
},
|
||||
group: {
|
||||
fontWeight: 'bold',
|
||||
fontWeight: "bold",
|
||||
fontSize: 16,
|
||||
marginBottom: 5,
|
||||
},
|
||||
@@ -164,8 +159,8 @@ const styles = StyleSheet.create({
|
||||
padding: 20,
|
||||
},
|
||||
empty: {
|
||||
textAlign: 'center',
|
||||
textAlign: "center",
|
||||
marginTop: 30,
|
||||
color: '#888',
|
||||
color: "#888",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
import { useRouter, useLocalSearchParams } from "expo-router";
|
||||
import { navigate } from "expo-router/build/global-state/routing";
|
||||
import { ThemedText } from "@/components/themed-text";
|
||||
import { ThemedTextInput } from '@/components/themed-textinput';
|
||||
import { ThemedView } from "@/components/themed-view";
|
||||
import { useLocalSearchParams, useRouter } from "expo-router";
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import {
|
||||
Button,
|
||||
FlatList,
|
||||
Image,
|
||||
Text,
|
||||
TextInput,
|
||||
View,
|
||||
StyleSheet,
|
||||
Text
|
||||
} from "react-native";
|
||||
import { getRessources, Ressource } from "../../services/ressourcesService";
|
||||
|
||||
export default function GestionnaireRessource() {
|
||||
const { nom, prenom } = useLocalSearchParams(); // Recup data ecran precedent
|
||||
const { nom, prenom } = useLocalSearchParams();
|
||||
const [search, setSearch] = useState("");
|
||||
const [ressource, setRessources] = useState<Ressource[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
@@ -25,12 +27,11 @@ export default function GestionnaireRessource() {
|
||||
const data = await getRessources();
|
||||
setRessources(data);
|
||||
} catch (error) {
|
||||
console.error("Erreur lors du chargement des ressources :", error);
|
||||
console.error("Erreur lors du chargement :", error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
loadData();
|
||||
}, []);
|
||||
|
||||
@@ -38,73 +39,66 @@ export default function GestionnaireRessource() {
|
||||
r.name.toLowerCase().includes(search.toLowerCase())
|
||||
);
|
||||
|
||||
const renderRessource = ({
|
||||
item,
|
||||
index,
|
||||
}: {
|
||||
item?: Ressource;
|
||||
index: number;
|
||||
}) => {
|
||||
if (!item) {
|
||||
// optionnel : afficher un placeholder pour debug
|
||||
// return <View style={styles.card}><Text>Item manquant</Text></View>;
|
||||
return null;
|
||||
}
|
||||
const renderRessource = ({ item }: { item: Ressource }) => {
|
||||
if (!item) return null;
|
||||
|
||||
return (
|
||||
<View style={styles.card}>
|
||||
<View style={styles.info}>
|
||||
<Image source={{ uri: item.Image }} style={styles.image} />
|
||||
<ThemedView lvl={1} shadow={true} style={styles.card}>
|
||||
<Image source={{ uri: item.Image }} style={styles.image} />
|
||||
<ThemedView lvl={1} style={styles.info}>
|
||||
<Text>{item.id}</Text>
|
||||
<Text>{item.name}</Text>
|
||||
<Text>{item.type}</Text>
|
||||
<Text>{item.quantity}</Text>
|
||||
<Text>{item.available_quantity}</Text>
|
||||
</View>
|
||||
</View>
|
||||
</ThemedView>
|
||||
</ThemedView>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<ThemedView lvl={3} style={styles.container}>
|
||||
<FlatList
|
||||
data={filteredData}
|
||||
renderItem={renderRessource}
|
||||
keyExtractor={(_, index) => index.toString()}
|
||||
contentContainerStyle={{ paddingBottom: 40 }}
|
||||
ListHeaderComponent={
|
||||
<View style={styles.header}>
|
||||
<ThemedView opacity="00" style={styles.header}>
|
||||
<Text style={styles.text}>
|
||||
Bonjour {prenom} {nom}
|
||||
</Text>
|
||||
|
||||
{/* 🔍 Champ de recherche */}
|
||||
<TextInput
|
||||
style={styles.input}
|
||||
placeholder="Rechercher une ressource..."
|
||||
value={search}
|
||||
onChangeText={setSearch}
|
||||
/>
|
||||
</View>
|
||||
{/* Input background */}
|
||||
<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={
|
||||
<Text style={styles.empty}>Aucun résultat trouvé 😕</Text>
|
||||
<ThemedText style={styles.empty}>Aucun résultat trouvé 😕</ThemedText>
|
||||
}
|
||||
/>
|
||||
|
||||
<View style={styles.footer}>
|
||||
<ThemedView lvl={3} style={styles.footer}>
|
||||
<Button
|
||||
title="Retour"
|
||||
onPress={() => router.push("/(tabs)/bonjourFL")}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
</ThemedView>
|
||||
</ThemedView>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
backgroundColor: "#fff",
|
||||
},
|
||||
header: {
|
||||
marginTop: 60,
|
||||
@@ -117,10 +111,12 @@ const styles = StyleSheet.create({
|
||||
fontWeight: "bold",
|
||||
marginBottom: 10,
|
||||
},
|
||||
inputBack: {
|
||||
width: "100%",
|
||||
borderRadius: 10,
|
||||
},
|
||||
input: {
|
||||
width: "100%",
|
||||
borderWidth: 1,
|
||||
borderColor: "#ccc",
|
||||
borderRadius: 10,
|
||||
padding: 10,
|
||||
fontSize: 16,
|
||||
@@ -129,11 +125,8 @@ const styles = StyleSheet.create({
|
||||
flexDirection: "row",
|
||||
marginHorizontal: 20,
|
||||
marginBottom: 15,
|
||||
borderWidth: 1,
|
||||
borderColor: "#ddd",
|
||||
borderRadius: 10,
|
||||
padding: 10,
|
||||
backgroundColor: "#fafafa",
|
||||
},
|
||||
image: {
|
||||
width: 80,
|
||||
@@ -145,11 +138,6 @@ const styles = StyleSheet.create({
|
||||
flex: 1,
|
||||
justifyContent: "center",
|
||||
},
|
||||
group: {
|
||||
fontWeight: "bold",
|
||||
fontSize: 16,
|
||||
marginBottom: 5,
|
||||
},
|
||||
footer: {
|
||||
padding: 20,
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Chantier, Chef, exempleChantier } from '@/class/class';
|
||||
import { createContext, ReactNode, useContext, useMemo, useState } from 'react';
|
||||
import { Chantier } from "@/class/class";
|
||||
import { createContext, ReactNode, useContext, useMemo, useState } from "react";
|
||||
|
||||
type ChantierContextType = {
|
||||
chantier: Chantier | null;
|
||||
@@ -15,10 +15,7 @@ type ChantierProviderProps = {
|
||||
export const ChantierProvider = ({ children }: ChantierProviderProps) => {
|
||||
const [chantier, setChantier] = useState<Chantier | null>(null);
|
||||
|
||||
const value = useMemo(
|
||||
() => ({ chantier, setChantier }),
|
||||
[chantier]
|
||||
);
|
||||
const value = useMemo(() => ({ chantier, setChantier }), [chantier]);
|
||||
|
||||
return (
|
||||
<ChantierContext.Provider value={value}>
|
||||
@@ -30,7 +27,7 @@ export const ChantierProvider = ({ children }: ChantierProviderProps) => {
|
||||
export const useChantier = () => {
|
||||
const context = useContext(ChantierContext);
|
||||
if (!context) {
|
||||
throw new Error('useChantier doit être utilisé dans <ChantierProvider>');
|
||||
throw new Error("useChantier doit être utilisé dans <ChantierProvider>");
|
||||
}
|
||||
return context;
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user