import { prisma } from '@innungsapp/shared' import { format } from 'date-fns' import { de } from 'date-fns/locale' import Link from 'next/link' import { toggleAiFeature } from './actions' const PLAN_LABELS: Record = { pilot: 'Pilot', standard: 'Standard', pro: 'Pro', verband: 'Verband', } const PLAN_COLORS: Record = { pilot: 'bg-gray-100 text-gray-700', standard: 'bg-blue-100 text-blue-800', pro: 'bg-purple-100 text-purple-800', verband: 'bg-amber-100 text-amber-800', } const PAGE_SIZE = 20 export default async function SuperAdminPage({ searchParams, }: { searchParams: Promise<{ q?: string; page?: string }> }) { const { q = '', page = '1' } = await searchParams const currentPage = Math.max(1, parseInt(page, 10)) const skip = (currentPage - 1) * PAGE_SIZE const where = q ? { OR: [ { name: { contains: q, mode: 'insensitive' } }, { slug: { contains: q, mode: 'insensitive' } }, { contactEmail: { contains: q, mode: 'insensitive' } }, ], } : {} const [organizations, total] = await Promise.all([ prisma.organization.findMany({ where, orderBy: { createdAt: 'desc' }, skip, take: PAGE_SIZE, include: { _count: { select: { members: true, userRoles: true } } }, }), prisma.organization.count({ where }), ]) const totalPages = Math.ceil(total / PAGE_SIZE) return (

Innungs-Verwaltung PRO

Hierüber werden alle Mandanten der Lösung verwaltet.

Neue Innung anlegen
{/* List */}
{/* Search & Filter */}
{q && ( )}

Registrierte Innungen ({total})

{organizations.length === 0 ? (

{q ? 'Keine Treffer für Ihre Suche.' : 'Bisher keine Innungen angelegt.'}

) : ( organizations.map((org) => (

{org.name}

{org.plan}
@ {org.slug}
{org.contactEmail || 'Keine Kontaktmail'}
{ 'use server' await toggleAiFeature(org.id, !org.aiEnabled) }}>
Mitglieder {org._count.members}
Admins {org._count.userRoles}
Erstellt am {format(org.createdAt, 'dd.MM.yyyy', { locale: de })}
)) )}
{/* Pagination */} {totalPages > 1 && (
Seite {currentPage} / {totalPages}
{currentPage > 1 && ( ← Zurück )} {currentPage < totalPages && ( Weiter → )}
)}
) }