import { AppShell } from "@/components/app-shell"
import { SiteHeader } from "@/components/site-header"
import { TicketDetailView } from "@/components/tickets/ticket-detail-view"
import { NewTicketDialogDeferred } from "@/components/tickets/new-ticket-dialog.client"
import { requireAuthenticatedSession } from "@/lib/auth-server"

type TicketDetailPageProps = {
  params: Promise<{ id: string }>
}

export default async function TicketDetailPage({ params }: TicketDetailPageProps) {
  await requireAuthenticatedSession()
  const { id } = await params

  return (
    <AppShell
      header={
        <SiteHeader
          title={`Ticket #${id}`}
          lead={"Detalhes do ticket"}
          secondaryAction={<SiteHeader.SecondaryButton>Compartilhar</SiteHeader.SecondaryButton>}
          primaryAction={<NewTicketDialogDeferred />}
        />
      }
    >
      <TicketDetailView id={id} />
    </AppShell>
  )
}
