Feat: AJout du style pour la gestion des ressources
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
import { useRouter, useLocalSearchParams } from "expo-router";
|
import { useRouter, useLocalSearchParams } from "expo-router";
|
||||||
import { navigate } from "expo-router/build/global-state/routing";
|
import { ThemedView } from "@/components/themed-view";
|
||||||
|
import { ThemedTextInput } from '@/components/themed-textinpute';
|
||||||
|
import { ThemedText } from "@/components/themed-text";
|
||||||
|
import { ThemedButton } from "@/components/themed-button";
|
||||||
|
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
@@ -7,16 +11,16 @@ import {
|
|||||||
Image,
|
Image,
|
||||||
Text,
|
Text,
|
||||||
TextInput,
|
TextInput,
|
||||||
View,
|
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
import { getRessources, Ressource } from "../../services/ressourcesService";
|
import { getRessources, Ressource } from "../../services/ressourcesService";
|
||||||
|
|
||||||
export default function GestionnaireRessource() {
|
export default function GestionnaireRessource() {
|
||||||
const { nom, prenom } = useLocalSearchParams(); // Recup data ecran precedent
|
const { nom, prenom } = useLocalSearchParams();
|
||||||
const [search, setSearch] = useState("");
|
const [search, setSearch] = useState("");
|
||||||
const [ressource, setRessources] = useState<Ressource[]>([]);
|
const [ressource, setRessources] = useState<Ressource[]>([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -25,12 +29,11 @@ export default function GestionnaireRessource() {
|
|||||||
const data = await getRessources();
|
const data = await getRessources();
|
||||||
setRessources(data);
|
setRessources(data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Erreur lors du chargement des ressources :", error);
|
console.error("Erreur lors du chargement :", error);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loadData();
|
loadData();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@@ -38,73 +41,66 @@ export default function GestionnaireRessource() {
|
|||||||
r.name.toLowerCase().includes(search.toLowerCase())
|
r.name.toLowerCase().includes(search.toLowerCase())
|
||||||
);
|
);
|
||||||
|
|
||||||
const renderRessource = ({
|
const renderRessource = ({ item }: { item: Ressource }) => {
|
||||||
item,
|
if (!item) return null;
|
||||||
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;
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.card}>
|
<ThemedView lvl={1} shadow={true} style={styles.card}>
|
||||||
<View style={styles.info}>
|
<Image source={{ uri: item.Image }} style={styles.image} />
|
||||||
<Image source={{ uri: item.Image }} style={styles.image} />
|
<ThemedView lvl={1} style={styles.info}>
|
||||||
<Text>{item.id}</Text>
|
<Text>{item.id}</Text>
|
||||||
<Text>{item.name}</Text>
|
<Text>{item.name}</Text>
|
||||||
<Text>{item.type}</Text>
|
<Text>{item.type}</Text>
|
||||||
<Text>{item.quantity}</Text>
|
<Text>{item.quantity}</Text>
|
||||||
<Text>{item.available_quantity}</Text>
|
<Text>{item.available_quantity}</Text>
|
||||||
</View>
|
</ThemedView>
|
||||||
</View>
|
</ThemedView>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<ThemedView lvl={3} style={styles.container}>
|
||||||
<FlatList
|
<FlatList
|
||||||
data={filteredData}
|
data={filteredData}
|
||||||
renderItem={renderRessource}
|
renderItem={renderRessource}
|
||||||
keyExtractor={(_, index) => index.toString()}
|
keyExtractor={(_, index) => index.toString()}
|
||||||
contentContainerStyle={{ paddingBottom: 40 }}
|
contentContainerStyle={{ paddingBottom: 40 }}
|
||||||
ListHeaderComponent={
|
ListHeaderComponent={
|
||||||
<View style={styles.header}>
|
<ThemedView opacity="00" style={styles.header}>
|
||||||
<Text style={styles.text}>
|
<Text style={styles.text}>
|
||||||
Bonjour {prenom} {nom}
|
Bonjour {prenom} {nom}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
{/* 🔍 Champ de recherche */}
|
{/* Input background */}
|
||||||
<TextInput
|
<ThemedView lvl={1} shadow={true} style={styles.inputBack}>
|
||||||
style={styles.input}
|
<ThemedTextInput
|
||||||
placeholder="Rechercher une ressource..."
|
lvl={0}
|
||||||
value={search}
|
style={styles.input}
|
||||||
onChangeText={setSearch}
|
placeholder="Rechercher une ressource..."
|
||||||
/>
|
value={search}
|
||||||
</View>
|
onChangeText={setSearch}
|
||||||
|
/>
|
||||||
|
</ThemedView>
|
||||||
|
</ThemedView>
|
||||||
}
|
}
|
||||||
ListEmptyComponent={
|
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
|
<Button
|
||||||
title="Retour"
|
title="Retour"
|
||||||
onPress={() => router.push("/(tabs)/bonjourFL")}
|
onPress={() => router.push("/(tabs)/bonjourFL")}
|
||||||
/>
|
/>
|
||||||
</View>
|
</ThemedView>
|
||||||
</View>
|
</ThemedView>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
backgroundColor: "#fff",
|
|
||||||
},
|
},
|
||||||
header: {
|
header: {
|
||||||
marginTop: 60,
|
marginTop: 60,
|
||||||
@@ -117,10 +113,12 @@ const styles = StyleSheet.create({
|
|||||||
fontWeight: "bold",
|
fontWeight: "bold",
|
||||||
marginBottom: 10,
|
marginBottom: 10,
|
||||||
},
|
},
|
||||||
|
inputBack: {
|
||||||
|
width: "100%",
|
||||||
|
borderRadius: 10,
|
||||||
|
},
|
||||||
input: {
|
input: {
|
||||||
width: "100%",
|
width: "100%",
|
||||||
borderWidth: 1,
|
|
||||||
borderColor: "#ccc",
|
|
||||||
borderRadius: 10,
|
borderRadius: 10,
|
||||||
padding: 10,
|
padding: 10,
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
@@ -129,11 +127,8 @@ const styles = StyleSheet.create({
|
|||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
marginHorizontal: 20,
|
marginHorizontal: 20,
|
||||||
marginBottom: 15,
|
marginBottom: 15,
|
||||||
borderWidth: 1,
|
|
||||||
borderColor: "#ddd",
|
|
||||||
borderRadius: 10,
|
borderRadius: 10,
|
||||||
padding: 10,
|
padding: 10,
|
||||||
backgroundColor: "#fafafa",
|
|
||||||
},
|
},
|
||||||
image: {
|
image: {
|
||||||
width: 80,
|
width: 80,
|
||||||
@@ -145,11 +140,6 @@ const styles = StyleSheet.create({
|
|||||||
flex: 1,
|
flex: 1,
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
},
|
},
|
||||||
group: {
|
|
||||||
fontWeight: "bold",
|
|
||||||
fontSize: 16,
|
|
||||||
marginBottom: 5,
|
|
||||||
},
|
|
||||||
footer: {
|
footer: {
|
||||||
padding: 20,
|
padding: 20,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user