import { cookies } from "next/headers";
import dynamic from "next/dynamic";

const LoginFormNoSSR = dynamic(() => import("@/components/login-form"), {
  ssr: false,
});

export default function LoginPage({
  searchParams,
}: {
  searchParams: { tenantId?: string; callback?: string; clientId?: string };
}) {
  const rememberedEmail = cookies().get("iam_remember_email")?.value ?? "";

  return (
    <main className="min-h-screen flex items-center justify-center p-6">
      <LoginFormNoSSR
        clientId={searchParams.clientId ?? ""}
        tenantId={searchParams.tenantId ?? ""}
        callback={searchParams.callback ?? ""}
        initialEmail={rememberedEmail}
      />
    </main>
  );
}
