Merge branch 'reservation-test'
This commit is contained in:
@@ -9,7 +9,11 @@ import { ThemedView } from "@/components/theme/themed-view";
|
||||
|
||||
export default function AddScreen() {
|
||||
const [typeAdd, setTypeAdd] = useState('');
|
||||
const [editMode, setEditMode] = useState(false);
|
||||
|
||||
function onPressSwitchMode(){
|
||||
setEditMode(!editMode);
|
||||
}
|
||||
|
||||
return(
|
||||
<ThemedView lvl={3} style={styles.back}>
|
||||
|
||||
@@ -5,7 +5,6 @@ import Constants from "expo-constants"; //pour connaître la taille de la barre
|
||||
import { useLocalSearchParams, useRouter } from "expo-router";
|
||||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import { FlatList, Image, StyleSheet, Text, View } from "react-native";
|
||||
import rawConcerts from "../../data/concerts.json";
|
||||
import { getUsers } from "@/services/ressourcesService";
|
||||
import { useChantier } from "../ContextChantier";
|
||||
import SelectChantier from "@/components/selectChantier";
|
||||
@@ -34,7 +33,7 @@ export default function GestionOuvrier() {
|
||||
async function loadData() {
|
||||
try {
|
||||
//Nous ne gardons que les Ouvriers, qui peuvent être assignés à un chantier
|
||||
const data = (await getRessources()).filter(u => u.type === "ouvrier");
|
||||
const data = (await getRessources()).filter(u => u.type === "Ouvrier");
|
||||
setRessources(data);
|
||||
} catch (error) {
|
||||
console.error("Erreur lors du chargement :", error);
|
||||
@@ -43,19 +42,6 @@ export default function GestionOuvrier() {
|
||||
loadData();
|
||||
}, []);
|
||||
|
||||
const concertsData: Concert[] = Array.isArray(rawConcerts)
|
||||
? (rawConcerts as Concert[])
|
||||
: [];
|
||||
|
||||
const filteredData = useMemo(() => {
|
||||
if (!Array.isArray(concertsData)) return [];
|
||||
const q = search.trim().toLowerCase();
|
||||
if (!q) return concertsData;
|
||||
return concertsData.filter(
|
||||
(item) => !!item && (item.group ?? "").toLowerCase().includes(q)
|
||||
);
|
||||
}, [concertsData, search]);
|
||||
|
||||
const renderItem = ({ item, index }: { item?: Ressources; index: number }) => {
|
||||
if (!item) {
|
||||
return null;
|
||||
|
||||
@@ -15,7 +15,7 @@ import { useRessources } from "../ContextRessource";
|
||||
export default function GestionnaireRessource() {
|
||||
const [search, setSearch] = useState("");
|
||||
const {ressources, setRessources} = useRessources();
|
||||
const [filterType, setFilterType] = useState("tout");
|
||||
const [filterType, setFilterType] = useState("Tout");
|
||||
const [showFilterMenu, setShowFilterMenu] = useState(false);
|
||||
const router = useRouter();
|
||||
|
||||
@@ -33,7 +33,7 @@ export default function GestionnaireRessource() {
|
||||
|
||||
const filteredData = ressources.filter((r) => {
|
||||
const matchName = r.name.toLowerCase().includes(search.toLowerCase());
|
||||
const matchType = filterType === "tout" || r.type === filterType;
|
||||
const matchType = filterType === "Tout" || r.type === filterType;
|
||||
return matchName && matchType;
|
||||
});
|
||||
|
||||
@@ -43,6 +43,7 @@ export default function GestionnaireRessource() {
|
||||
<ThemedView lvl={1} shadow={true} style={styles.card}>
|
||||
<Image source={{ uri: item.Image }} style={styles.image} />
|
||||
<ThemedView lvl={1} style={styles.info}>
|
||||
<ThemedText>Id : {item.id}</ThemedText>
|
||||
<ThemedText>Nom : {item.name}</ThemedText>
|
||||
<ThemedText>Type : {item.type}</ThemedText>
|
||||
<ThemedText>Quantité totale : {item.quantity}</ThemedText>
|
||||
@@ -68,7 +69,7 @@ export default function GestionnaireRessource() {
|
||||
<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) => (
|
||||
{["Tout", "Outil", "Machine","Ouvrier"].map((t) => (
|
||||
<ThemedButton
|
||||
key={t}
|
||||
lvl={1}
|
||||
|
||||
@@ -23,9 +23,11 @@ export default function Home() {
|
||||
<View style={{width:"100%", position: 'absolute'}}>
|
||||
<SelectChantier></SelectChantier>
|
||||
</View>
|
||||
{chantier&&
|
||||
<View style={{width:"100%", position: 'absolute',marginLeft:"50%"}}>
|
||||
<SetStatus></SetStatus>
|
||||
</View>
|
||||
}
|
||||
<ScrollView>
|
||||
<View style={{paddingTop:60}}>
|
||||
<ChantierSummary style={styles.summary} data={{ chantier }} />
|
||||
|
||||
33
app/ContextReservation.tsx
Normal file
33
app/ContextReservation.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
import { Reservation } from "@/class/class";
|
||||
import { createContext, ReactNode, useContext, useMemo, useState } from "react";
|
||||
|
||||
type ReservationContextType = {
|
||||
reservations: Reservation[];
|
||||
setReservations: (list: Reservation[]) => void;
|
||||
};
|
||||
|
||||
const ReservationsContext = createContext<ReservationContextType | null>(null);
|
||||
|
||||
type ReservationsProviderProps = {
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
export const ReservationsProvider = ({ children }: ReservationsProviderProps) => {
|
||||
const [reservations, setReservations] = useState<Reservation[]>([]);
|
||||
|
||||
const value = useMemo(() => ({ reservations, setReservations }), [reservations]);
|
||||
|
||||
return (
|
||||
<ReservationsContext.Provider value={value}>
|
||||
{children}
|
||||
</ReservationsContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export const useReservations = () => {
|
||||
const context = useContext(ReservationsContext);
|
||||
if (!context) {
|
||||
throw new Error("useRessources doit être utilisé dans <ReservationsContext>");
|
||||
}
|
||||
return context;
|
||||
};
|
||||
@@ -16,9 +16,11 @@ import { Platform, UIManager } from 'react-native';
|
||||
import { ChantierProvider } from "./ContextChantier";
|
||||
import { UserProvider } from "./ContextUser";
|
||||
import { RessourcesProvider } from "./ContextRessource";
|
||||
import { ReservationsProvider } from "./ContextReservation";
|
||||
import LoginScreen from "./login/login";
|
||||
|
||||
|
||||
|
||||
export const unstable_settings = {
|
||||
anchor: "(tabs)",
|
||||
};
|
||||
@@ -60,18 +62,20 @@ export default function RootLayout() {
|
||||
<UserProvider>
|
||||
<ChantierProvider>
|
||||
<RessourcesProvider>
|
||||
<ThemeProvider value={colorScheme === "dark" ? DarkTheme : DefaultTheme}>
|
||||
<Stack>
|
||||
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
|
||||
<Stack.Screen name="selectChantier" options={{ headerShown: false }}/>
|
||||
<Stack.Screen
|
||||
name="modal"
|
||||
options={{ presentation: "modal", title: "Modal" }}
|
||||
/>
|
||||
<Stack.Screen name="login" options={{ headerShown: false }} />
|
||||
</Stack>
|
||||
<StatusBar style="auto" />
|
||||
</ThemeProvider>
|
||||
<ReservationsProvider>
|
||||
<ThemeProvider value={colorScheme === "dark" ? DarkTheme : DefaultTheme}>
|
||||
<Stack>
|
||||
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
|
||||
<Stack.Screen name="selectChantier" options={{ headerShown: false }}/>
|
||||
<Stack.Screen
|
||||
name="modal"
|
||||
options={{ presentation: "modal", title: "Modal" }}
|
||||
/>
|
||||
<Stack.Screen name="login" options={{ headerShown: false }} />
|
||||
</Stack>
|
||||
<StatusBar style="auto" />
|
||||
</ThemeProvider>
|
||||
</ReservationsProvider>
|
||||
</RessourcesProvider>
|
||||
</ChantierProvider>
|
||||
</UserProvider>
|
||||
|
||||
Reference in New Issue
Block a user