import { LoginForm } from "@/components/auth/login-form"
import { AuthShell } from "@/components/auth/auth-shell"

export default function LoginPage({
  searchParams,
}: {
  searchParams: Promise<{ redirect?: string }>
}) {
  return (
    <AuthShell
      title="Welcome back"
      subtitle="Sign in to meet new people over video chat."
    >
      <LoginFormWrapper searchParamsPromise={searchParams} />
    </AuthShell>
  )
}

async function LoginFormWrapper({
  searchParamsPromise,
}: {
  searchParamsPromise: Promise<{ redirect?: string }>
}) {
  const params = await searchParamsPromise
  return <LoginForm redirectTo={params.redirect ?? "/"} />
}
