fix(auth): useLogin maps login response to User, ProtectedRoute calls useAuth()
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
import React from 'react';
|
||||
import { Navigate, useLocation } from 'react-router-dom';
|
||||
import { useAuthStore } from '@/store/authStore';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
|
||||
export function ProtectedRoute({ children }: { children: React.ReactNode }) {
|
||||
const { isAuthenticated } = useAuthStore();
|
||||
const location = useLocation();
|
||||
|
||||
// Load user data on mount (handles page refresh)
|
||||
useAuth();
|
||||
|
||||
if (!isAuthenticated) {
|
||||
return <Navigate to="/login" state={{ from: location }} replace />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user