import { PrintCartTags } from "@/components/print-cart-tags"

export default async function PrintCartTagsPage({
  params,
  searchParams,
}: {
  params: Promise<{ id: string }>
  searchParams: Promise<{ org?: string; roundId?: string; sessionId?: string; paper?: string; orientation?: string }>
}) {
  const { id } = await params
  const { org, roundId, sessionId, 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 (
    <PrintCartTags
      organizationId={org}
      tournamentId={id}
      roundId={roundId}
      sessionId={sessionId}
      initialPaper={paper === "Letter" ? "letter" : "a4"}
      initialOrientation={orientation === "landscape" ? "landscape" : "portrait"}
    />
  )
}
