import { PropsWithChildren, createContext } from "react"; import { IAuthActions } from "./auth-actions"; export interface IAuthContextState extends Partial {} export const AuthContext = createContext>({}); export const AuthProvider = ({ children, authActions, }: PropsWithChildren<{ authActions: Partial }>) => { const handleLogin = (params: unknown) => { try { return Promise.resolve(authActions.login?.(params)); } catch (error) { console.error(error); return Promise.reject(error); } }; const handleLogout = (params: unknown) => { try { return Promise.resolve(authActions.logout?.(params)); } catch (error) { console.error(error); return Promise.reject(error); } }; const handleCheck = async () => { try { return Promise.resolve(authActions.check?.()); } catch (error) { console.error(error); return Promise.reject(error); } }; return ( {children} ); };