import { de } from '@/lib/i18n/de' import { fillPlaceholders, isInputField } from '@/lib/templates/fields' import { RedactedText } from '@/components/Redacted' import { SectionEditor } from './SectionEditor' import type { RenderedSection } from '@/lib/cases/sectionService' /** * Abschnitte einer Fallakte: der aktuelle Sachstand, aus der Vorlage erzeugt. * * Feste Textbausteine der Vorlage werden gerendert, nicht bearbeitet — ihre * Platzhalter ziehen die Werte der Eingabefelder. Damit trägt dieselbe * Darstellung ein Formular und einen Vertragstext. */ export function Sections({ caseNumber, sections, canEdit, }: { caseNumber: string sections: RenderedSection[] canEdit: boolean }) { if (sections.length === 0) { return

{de.section.empty}

} const werte = Object.fromEntries( sections.filter((s) => s.visible).map((s) => [s.fieldKey, s.value]), ) return (
{sections.map((section) => { const field = section.field // Feste Bausteine der Vorlage. if (!isInputField(field)) { if (field.type === 'pagebreak') return
if (field.type === 'signature') { return (

{field.label}

) } const text = fillPlaceholders(field.text ?? '', werte) return field.type === 'heading' ? (

{text || field.label}

) : (

{text}

) } return (
{field.label} {field.requiredToClose ? ( {de.section.requiredToClose} ) : null}
{!section.visible ? ( // Serverseitig ersetzt: der echte Wert ist gar nicht erst hier.

{de.section.lockedField(section.value.requiredLevel)}

) : section.segments ? (
{canEdit ? ( ) : null}
) : ( )}
) })}
) }