'use client'; import { isLoggedIn } from 'components/profile/actions'; import { createContext, useEffect, useState } from 'react'; type AuthContextType = { isAuthenticated: boolean; loading: boolean; }; const AuthContext = createContext({ isAuthenticated: false, loading: true }); type AuthProviderProps = { children: React.ReactNode; }; export function AuthProvider({ children }: AuthProviderProps) { const [isAuthenticated, setIsAuthenticated] = useState(false); const [loading, setLoading] = useState(true); useEffect(() => { async function checkAuth() { const isLogged = await isLoggedIn(); setIsAuthenticated(isLogged); setLoading(false); } checkAuth(); }, []); return ( {children} ); } export default AuthContext;