import { createContext, type Dispatch, type ReactNode, type SetStateAction, useContext, useState, } from "react"; interface ILichessUser { username: string; id: string; isLoggedIn: boolean; } interface ILichessUserContextType { user: ILichessUser | null; setUser: Dispatch> } const LichessUserContext = createContext( undefined, ); export const LichessUserProvider = ({ children }: { children: ReactNode }) => { const [user, setUser] = useState(null); // TODO useEffect to check and login user on mount return ( {children} ); }; export const useLichessUser = () => { const context = useContext(LichessUserContext); if (!context) { throw new Error("useLichessUser must be used within a LichessUserProvider"); } return context; };