import React , { createContext , Dispatch , ReactNode , SetStateAction , useContext , useState } from "react" ; import { User } from "../../types/api/user" ; type LoginUser = User & { isAdmin : boolean ; } ; type LoginUserContextType = { loginUser : LoginUser | null ; setLoginUser : Dispatch < SetStateAction < LoginUser | null > > ; } ; const LoginUserContext = createContext < LoginUserContextType > ( { } as LoginUserContextType ) ; export const LoginUserProvider = ( props ) => { const { children } = props ; const [ loginUser , setLoginUser ] = useState < LoginUser | null > ( null ) ; return ( < LoginUserContext . Provider value = { { loginUser , setLoginUser } } > { children } < /LoginUserContext.Provider>); } ; export const useLoginUser = ( ) : LoginUserContextType => useContext ( LoginUserContext ) ;