import type { Metadata } from 'next' import Link from 'next/link' import { db } from '@/lib/db' import { requirePermission } from '@/lib/auth/current' import { listPersonnelFiles, listStatusTags } from '@/lib/personnel/service' import { de } from '@/lib/i18n/de' import { StampMark, classificationEdgeStyle } from '@/components/StampMark' import { StatusTags } from '@/components/StatusTags' export const metadata: Metadata = { title: de.personnel.listHeading } export const dynamic = 'force-dynamic' /** * Liste der Personalakten. * * Wie bei den Fallakten: Suche, Sichtbarkeit und Zählung laufen über dieselbe * Abfrage. Eine Akte über der Stufe des Lesers taucht weder auf noch in der * Zahl daneben. */ export default async function PersonnelListPage({ searchParams, }: { searchParams: Promise<{ q?: string; status?: string }> }) { // Ohne das Recht gibt es die Seite nicht - 404, nicht 403. const user = await requirePermission('personnel.read') const { q, status } = await searchParams const [{ files, total }, levels, statusTags] = await Promise.all([ listPersonnelFiles(user.permissions, { query: q, statusTag: status }), db.clearanceLevelConfig.findMany({ orderBy: { level: 'asc' } }), listStatusTags(), ]) const levelName = new Map(levels.map((l) => [l.level, l.name])) const darfAnlegen = user.permissions.isAdmin || user.permissions.permissions.has('personnel.edit') return (

{de.personnel.listHeading}

{de.personnel.countLabel(total)}
{status ? : null} {darfAnlegen ? ( {de.personnel.create} ) : null}
{files.length === 0 ? (

{q ? de.personnel.emptySearch : de.personnel.empty}

) : ( )}
) }