Fix AuthContext issue after refactoring
This commit is contained in:
@@ -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,
|
||||||
|
|||||||
@@ -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;
|
|
||||||
};
|
|
||||||
|
|||||||
Reference in New Issue
Block a user