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 ; } return <>{children}; }