import * as React from "react" ; /** Custom types */ import { UserAuth } from "../custom-types" ; /** Custom Hooks */ import useAuthHandler from "../utils/custom-hooks/AuthHandler" ; /** Utils */ import { DEFAULT_USER_AUTH } from "../utils/Consts" ; import { getStoredUserAuth } from "../utils/Helpers" ; interface IAuthContextInterface { auth : UserAuth ; setAuthStatus : ( userAuth : UserAuth ) => void ; setUnauthStatus : ( ) => void ; } export const authContext = React . createContext < IAuthContextInterface > ( { auth : DEFAULT_USER_AUTH , setAuthStatus : ( ) => { } , setUnauthStatus : ( ) => { } } ) ; const { Provider } = authContext ; const AuthProvider = ( { children } ) => { const { auth , setAuthStatus , setUnauthStatus } = useAuthHandler ( getStoredUserAuth ( ) ) ; return ( < Provider value = { { auth , setAuthStatus , setUnauthStatus } } > { children } < /Provider>); } ; export default AuthProvider ;