'use client' import { useActionState, useState, useTransition } from 'react' import { caseText } from '@/lib/i18n/cases' import { clearanceText, commonText } from '@/lib/i18n/common' import { personnelText } from '@/lib/i18n/people' import { StatusTags } from '@/components/StatusTags' import { reclassifyPersonnelAction, updatePersonnelAction, type ActionResult, } from '../actions' type File = { id: string displayName: string rank: string | null departmentId: string | null department: { id: string; key: string; name: string } | null statusTags: string[] note: string | null classification: number userId: string | null } /** * Kopfdaten einer Personalakte: lesen und ändern in derselben Ansicht. * * Die Klassifizierung steht bewusst getrennt. Sie ändert, wer die Akte * überhaupt sieht, und eine Herabstufung braucht eine Begründung - das gehört * nicht in dasselbe Formular wie eine Korrektur der Dienstnummer. */ export function PersonnelHead({ file, canEdit, levels, statusTags, departments, }: { file: File canEdit: boolean levels: { level: number; name: string }[] statusTags: { key: string; name: string; colorToken: string }[] /** Die Abteilungen zur Auswahl. Freitext gibt es hier nicht mehr: sonst wäre jede Schreibweise eine eigene Abteilung, und genau das war der Grund für das Modell. */ departments: { id: string; key: string; name: string }[] }) { const [editing, setEditing] = useState(false) const [state, action, pending] = useActionState( updatePersonnelAction, null, ) if (!editing) { return (
{personnelText.status} {file.statusTags.length > 0 ? ( ) : ( {personnelText.statusNone} )}
{file.note ? (

{file.note}

) : null} {canEdit ? (
) : null}
) } return (
setEditing(false)} className="max-w-(--container-measure) space-y-4" >
{personnelText.status}
{statusTags.map((tag) => ( ))}

{personnelText.statusHint}