import { PrintResultlist } from "@/components/print-resultlist"

export default async function PrintResultlistPage({
  params,
  searchParams,
}: {
  params: Promise<{ id: string }>
  searchParams: Promise<{ org?: string; paper?: string; orientation?: string }>
}) {
  const { id } = await params
  const { org, paper, orientation } = await searchParams

  if (!org) {
    return (
      <main className="flex min-h-[100dvh] flex-col items-center justify-center gap-2 bg-background px-5 text-center">
        <p className="text-sm font-medium text-destructive">
          Mangler organisasjon i lenken. Gå tilbake til dashbordet og prøv igjen.
        </p>
      </main>
    )
  }

  return (
    <PrintResultlist
      organizationId={org}
      tournamentId={id}
      initialSize={paper === "Letter" ? "Letter" : "A4"}
      initialOrientation={orientation === "landscape" ? "landscape" : "portrait"}
    />
  )
}
