import type { Metadata } from 'next'

import { CopilotChat } from '@/components/console/copilot-chat'
import { PermissionGate } from '@/components/console/permission-gate'
import { DemoDataBadge, PageHeader } from '@/components/ui/display'
import { getCurrentUser } from '@/lib/auth/current-user'
import { getI18n } from '@/lib/i18n/server'

export const metadata: Metadata = { title: 'NABDH Copilot' }
export const dynamic = 'force-dynamic'

export default async function CopilotPage() {
  const user = await getCurrentUser()
  const { t } = await getI18n()

  if (!user?.permissions.has('copilot.use')) return <PermissionGate />

  return (
    <>
      <PageHeader
        title={t('copilot.title')}
        subtitle={t('copilot.subtitle')}
        badge={<DemoDataBadge label={t('common.simulated')} title={t('common.simulatedTooltip')} />}
      />
      <CopilotChat />
    </>
  )
}
