import { Navigate, Outlet } from 'react-router-dom';
import { usePublicAuthStore } from '../store/publicAuthStore';

export const ProtectedRoute = () => {
  const user = usePublicAuthStore((state) => state.user);
  const token = localStorage.getItem('public_token');

  // Si no hay usuario o no hay token, al login
  if (!user || !token) {
    return <Navigate to="/login" replace />;
  }

  return <Outlet />;
};