gestion des ressources fonctionnelle, mais pas fini
This commit is contained in:
@@ -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