You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
884 B
37 lines
884 B
import { createContext, ReactNode, useContext, useState } from "react";
|
|
|
|
export type IGlobalContextProps = {
|
|
role: string;
|
|
setRole: (role: string) => void;
|
|
};
|
|
|
|
export const globalContextDefaultValues: IGlobalContextProps = {
|
|
role: null,
|
|
setRole: () => { },
|
|
}
|
|
|
|
export const GlobalContext = createContext<IGlobalContextProps>(globalContextDefaultValues);
|
|
|
|
type Props = {
|
|
children: ReactNode;
|
|
};
|
|
|
|
export const GlobalContextProvider = (props: Props) => {
|
|
const [role, setCurrentRole] = useState(null)
|
|
|
|
return (
|
|
<GlobalContext.Provider
|
|
value={{
|
|
role: role,
|
|
setRole: setCurrentRole,
|
|
}}
|
|
>
|
|
{props.children}
|
|
</GlobalContext.Provider>
|
|
);
|
|
};
|
|
|
|
// import { useGlobalContext } from 'context';
|
|
// const { user } = useGlobalContext();
|
|
|
|
// Pour utiliser le context n'importe ou
|