import { OpenTicketsManager } from '@/components/modules/open-tickets-manager';
import { TicketCategoriesManager } from '@/components/modules/ticket-categories-manager';
import { TicketConfigForm } from '@/components/modules/ticket-config-form';
import { getLocale, t } from '@/lib/i18n';
import {
  getTicketConfigDashboard,
  listOpenTickets,
  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, openTickets] = await Promise.all([
    getLocale(),
    getTicketConfigDashboard(guildId),
    listTicketCategories(guildId),
    listOpenTickets(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>
      <OpenTicketsManager guildId={guildId} initialTickets={openTickets} />
      <TicketConfigForm guildId={guildId} initialValue={config} />
      <TicketCategoriesManager guildId={guildId} initialCategories={categories} />
    </div>
  );
}
