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

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

export default async function ModerationPage({ params }: ModerationPageProps) {
  const { guildId } = await params;
  const [locale, moderation, cases, warnings] = await Promise.all([
    getLocale(),
    getModerationDashboard(guildId),
    listCases(guildId, CaseListQuerySchema.parse({})),
    listWarnings(guildId, WarningListQuerySchema.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} />
      <WarningsTable guildId={guildId} initialWarnings={warnings} />
      <CasesTable guildId={guildId} initialCases={cases} />
    </div>
  );
}
