19 lines
620 B
TypeScript
19 lines
620 B
TypeScript
import { useEffect } from 'react';
|
|
import { useAuthStore } from '@/features/auth/store/authStore';
|
|
import type { UseAuthReturn } from './types';
|
|
|
|
/**
|
|
* Hook pour gérer l'authentification et la persistance de session
|
|
* Utilise le store Zustand unifié pour l'état d'authentification
|
|
* FE-TYPE-012: Fully typed hook return
|
|
*/
|
|
export function useAuth(): UseAuthReturn {
|
|
const { isAuthenticated, isLoading, checkAuthStatus } = useAuthStore();
|
|
|
|
useEffect(() => {
|
|
// Vérifier le statut d'authentification au chargement
|
|
checkAuthStatus();
|
|
}, [checkAuthStatus]);
|
|
|
|
return { isAuthenticated, isLoading };
|
|
}
|