import { useAuth } from '@/hooks/useAuth';
import { type PropsWithChildren } from 'react';
import { Navigate } from 'react-router-dom';

export const ProtectedRoute = ({ children }: PropsWithChildren) => {
  const auth = useAuth();

  if (!auth.accessToken) {
    // If no token, redirect to login page
    return <Navigate to="/login" replace />;
  }

  // If token exists, render the children components
  return children;
};
