import Link from "next/link"; import { Plus } from "lucide-react"; import { prisma } from "@/server/db"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { PageHead, Pill } from "@/components/mockup-ui"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; import { createTenant } from "@/server/actions/admin"; import { getMailStatus } from "@/server/actions/mail"; import { MailStatusPanel } from "@/components/mail-status-panel"; import { getTranslations } from "next-intl/server"; import { TrialBadge } from "@/components/trial/trial-badge"; const STATUS_TONE: Record = { ACTIVE: "ok", SUSPENDED: "warn", ARCHIVED: "mut" }; const STATUS_LABEL: Record = { ACTIVE: "Aktiv", SUSPENDED: "Gesperrt", ARCHIVED: "Archiviert" }; export default async function AdminPage({ searchParams }: { searchParams: Promise<{ new?: string; plan?: string }> }) { // Zugriff (Plattform-Session + MFA) wird im (platform)/layout.tsx erzwungen. const params = await searchParams; // L15 Testphase: Filter Test/Voll const tt = await getTranslations("trial.platform"); const tp = await getTranslations("plans"); const planFilter = params.plan === "trial" ? "TRIAL" : params.plan === "full" ? "FULL" : null; const [tenants, mailStatus] = await Promise.all([ prisma.tenant.findMany({ where: planFilter ? { plan: planFilter } : undefined, include: { _count: { select: { users: true } }, modules: true }, orderBy: { createdAt: "asc" }, }), // SEC1: Betriebszustand der Mail-Strecke + Testversand. getMailStatus(), ]); return (
} /> {params.new && (

Neuen Kunden anlegen

Beim Anlegen werden automatisch ausgerollt: Standard-Rollen (Mandantenadministrator, Backoffice, Teamleiter, Monteur), erster Admin-User, alle Module und Mandanten-Einstellungen (idempotent, protokolliert).

)}
Kunde Kürzel Status {tt("colPlan")} {tp("colTier")} Nutzer Aktive Module {tenants.map((t) => { const active = t.modules.filter((m) => m.enabled).length; return ( {t.name} {t.sector &&
{t.sector}
}
{t.slug} {STATUS_LABEL[t.status]} {/* L17 Pakete: Stufe als Badge (Testphase läuft immer als Profi) */} {tp(`tier.${t.tier}`)} {t._count.users} {active > 0 ? `${active} Module` : "—"}
); })}
); }