import { Navigate, Outlet } from 'react-router';
import { useAuthStore } from './auth-store';
import { useAuth } from './use-auth';

export function ProtectedRoute() {
  const isAuthenticated = useAuthStore((s) => s.isAuthenticated);
  useAuth();

  if (!isAuthenticated) return <Navigate to="/login" replace />;
  return <Outlet />;
}
