Fix AuthContext issue after refactoring

This commit is contained in:
2026-03-14 23:22:28 -03:00
parent 6898297935
commit 47f2f4c13f
2 changed files with 3 additions and 10 deletions

View File

@@ -7,6 +7,7 @@ const API_URL = getBaseUrl();
export interface AuthContextType { export interface AuthContextType {
appUser: AppUser | null; appUser: AppUser | null;
isLoading: boolean; isLoading: boolean;
isSignedIn: boolean;
error: string | null; error: string | null;
token: string | null; token: string | null;
login: (token: string, user: AppUser) => void; login: (token: string, user: AppUser) => void;
@@ -99,6 +100,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
value={{ value={{
appUser, appUser,
isLoading, isLoading,
isSignedIn: !!appUser,
error, error,
token, token,
login, login,

View File

@@ -1,10 +1 @@
import { useContext } from 'react'; export { useAuth } from './AuthContext';
import { AuthContext } from './AuthContextType';
export const useAuth = () => {
const context = useContext(AuthContext);
if (!context) {
throw new Error('useAuth must be used within an AuthProvider');
}
return context;
};