import { Navigate, Outlet } from "react-router-dom";
import { useAuth } from "../context/auth_context";

// Component to handle login route
export const LoginRoute = () => {
  const { user } = useAuth();

  // If user is authenticated, redirect to home page
  if (user) {
    return <Navigate to="/" replace={true} />;
  }

  // Render the login page if user is not authenticated
  return <Outlet />;
};
