Fix AuthContext issue after refactoring
This commit is contained in:
@@ -7,6 +7,7 @@ const API_URL = getBaseUrl();
|
||||
export interface AuthContextType {
|
||||
appUser: AppUser | null;
|
||||
isLoading: boolean;
|
||||
isSignedIn: boolean;
|
||||
error: string | null;
|
||||
token: string | null;
|
||||
login: (token: string, user: AppUser) => void;
|
||||
@@ -99,6 +100,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
|
||||
value={{
|
||||
appUser,
|
||||
isLoading,
|
||||
isSignedIn: !!appUser,
|
||||
error,
|
||||
token,
|
||||
login,
|
||||
|
||||
@@ -1,10 +1 @@
|
||||
import { useContext } from 'react';
|
||||
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;
|
||||
};
|
||||
export { useAuth } from './AuthContext';
|
||||
|
||||
Reference in New Issue
Block a user