31 lines
814 B
TypeScript
31 lines
814 B
TypeScript
import { ReactNode, useState } from "react";
|
|
import GlobalStateContext from "./GlobalStateContext";
|
|
|
|
|
|
|
|
const GlobalStateProvider = ({ children }: { children: ReactNode }) => {
|
|
const [isAuthenticate, setIsAuthenticate] = useState<boolean>(true);
|
|
const [isBarLoading, setIsBarLoading] = useState<boolean>(false); // ✅ Fixed typo
|
|
const [userAccess, setUserAccess] = useState<string[]>(() => {
|
|
const stored = sessionStorage.getItem('userAccess');
|
|
return stored ? JSON.parse(stored) : [];
|
|
});
|
|
|
|
|
|
|
|
return (
|
|
<GlobalStateContext.Provider value={{
|
|
isAuthenticate,
|
|
setIsAuthenticate,
|
|
isBarLoading,
|
|
setIsBarLoading, // ✅ Fixed typo
|
|
userAccess,
|
|
setUserAccess
|
|
}}>
|
|
{children}
|
|
</GlobalStateContext.Provider>
|
|
);
|
|
};
|
|
|
|
export default GlobalStateProvider;
|