import { TicketCategoriesManager } from '@/components/modules/ticket-categories-manager';
import { TicketConfigForm } from '@/components/modules/ticket-config-form';
import { getLocale, t } from '@/lib/i18n';
import { getTicketConfigDashboard, listTicketCategories } from '@/lib/module-configs/tickets';

interface TicketsPageProps {
  params: Promise<{ guildId: string }>;
}

export default async function TicketsPage({ params }: TicketsPageProps) {
  const { guildId } = await params;
  const [locale, config, categories] = await Promise.all([
    getLocale(),
    getTicketConfigDashboard(guildId),
    listTicketCategories(guildId)
  ]);

  return (
    <div className="space-y-6">
      <div>
        <h1 className="text-2xl font-semibold">{t(locale, 'modules.tickets.label')}</h1>
        <p className="text-sm text-muted-foreground">{t(locale, 'modules.tickets.description')}</p>
      </div>
      <TicketConfigForm guildId={guildId} initialValue={config} />
      <TicketCategoriesManager guildId={guildId} initialCategories={categories} />
    </div>
  );
}
