Migrate auth hooks to AuthContext and update tests for compatibility
- Refactored `useIsAuthenticated` and `useCurrentUser` to use `useAuth` from `AuthContext` instead of `useAuthStore`. - Updated test setups to inject `AuthProvider` with mocked store hooks for improved test isolation and consistency. - Replaced legacy `useAuthStore` mocks with `AuthContext`-compatible implementations in affected tests.
This commit is contained in:
@@ -22,6 +22,7 @@ import {
|
||||
} from '../client';
|
||||
import { useAuthStore } from '@/lib/stores/authStore';
|
||||
import type { User } from '@/lib/stores/authStore';
|
||||
import { useAuth } from '@/lib/auth/AuthContext';
|
||||
import { parseAPIError, getGeneralError } from '../errors';
|
||||
import { isTokenWithUser } from '../types';
|
||||
import config from '@/config/app.config';
|
||||
@@ -481,7 +482,7 @@ export function usePasswordChange(onSuccess?: (message: string) => void) {
|
||||
* @returns boolean indicating authentication status
|
||||
*/
|
||||
export function useIsAuthenticated(): boolean {
|
||||
return useAuthStore((state) => state.isAuthenticated);
|
||||
return useAuth((state) => state.isAuthenticated);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -489,7 +490,7 @@ export function useIsAuthenticated(): boolean {
|
||||
* @returns Current user or null
|
||||
*/
|
||||
export function useCurrentUser(): User | null {
|
||||
return useAuthStore((state) => state.user);
|
||||
return useAuth((state) => state.user);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user