import Home from "~/components/home";
import type { Route } from "./+types/_index";
import { auth } from "../../lib/auth";
import { redirect } from "react-router";

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

  if (!session) {
    throw redirect("/log-in");
  }

  return { session };
}

export default function HomePage() {
  return <Home />;
}
