import { CaseListQuerySchema } from '@nexumi/shared';
import { CasesTable } from '@/components/modules/cases-table';
import { ModerationForm } from '@/components/modules/moderation-form';
import { getLocale, t } from '@/lib/i18n';
import { listCases } from '@/lib/module-configs/cases';
import { getModerationDashboard } from '@/lib/module-configs/moderation';

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

export default async function ModerationPage({ params }: ModerationPageProps) {
  const { guildId } = await params;
  const [locale, moderation, cases] = await Promise.all([
    getLocale(),
    getModerationDashboard(guildId),
    listCases(guildId, CaseListQuerySchema.parse({}))
  ]);

  return (
    <div className="space-y-6">
      <div>
        <h1 className="text-2xl font-semibold">{t(locale, 'modules.moderation.label')}</h1>
        <p className="text-sm text-muted-foreground">{t(locale, 'modules.moderation.description')}</p>
      </div>
      <ModerationForm guildId={guildId} initialValue={moderation} />
      <CasesTable guildId={guildId} initialCases={cases} />
    </div>
  );
}
