import { redirect } from "react-router";
import type { Route } from "./+types/log-in";
import { auth } from "../../lib/auth";
import Login from "~/components/login";

export async function loader({ request }: Route.LoaderArgs) {
  const session = await auth.api.getSession({
    headers: request.headers,
  });

  if (session) {
    throw redirect("/");
  }

  return null;
}

export default function LogInPage() {
  return <Login />;
}
