import type { Locale } from "@/i18n/routing";

import { headers } from "next/headers";

import { redirect } from "@/i18n/navigation";
import { auth } from "@/lib/auth";

export default async function Page({ params }: { params: Promise<{ locale: string }> }) {
  const { locale } = await params;
  const session = await auth.api.getSession({
    headers: await headers(),
  });

  if (session) {
    redirect({ href: "/dashboard", locale: locale as Locale });
  }

  redirect({ href: "/login", locale: locale as Locale });
}
