"use client" import React, { createContext, useContext, useEffect, useState } from 'react'; interface AuthContextProps { isAuthenticated: boolean | null; login: () => void; logout: () => void; } const AuthContext = createContext({ isAuthenticated: null, login: () => {}, logout: () => {}, }); export const AuthProvider = ({ children }: { children: React.ReactNode }) => { const [isAuthenticated, setIsAuthenticated] = useState(null); useEffect(() => { const token = localStorage.getItem('token'); if (token) { // You could add any token validation logic here setIsAuthenticated(true); } else { setIsAuthenticated(false); } }, []); const login = () => { setIsAuthenticated(true); }; const logout = () => { setIsAuthenticated(false); localStorage.removeItem('token'); }; return ( {children} ); }; export const useAuth = () => useContext(AuthContext);