import { useState, useEffect, useCallback } from 'react' import { FileText, Plus, Edit2, Archive, CheckCircle, Clock, Copy, Download, ChevronUp, ChevronDown, Eye } from 'lucide-react' import api from '../utils/api' import { generateLegalPdf, legalSectionNumber } from '../utils/legalPdfExport' import LegalDocumentBody from '../components/LegalDocumentBody' import { LegalPreviewModal } from '../components/LegalDocumentPreview' const PDF_STATUS_META = { published: 'Gültig seit', draft: 'Entwurf — Stand', archived: 'Archiviert — Stand' } // ─── Sub-components ────────────────────────────────────────────────────────── const DOC_TYPES = [ { key: 'impressum', label: 'Impressum', defaultTitle: 'Impressum' }, { key: 'privacy_policy', label: 'Datenschutz', defaultTitle: 'Datenschutzerklärung' }, { key: 'terms_of_use', label: 'Nutzungsbedingungen', defaultTitle: 'Nutzungsbedingungen' }, { key: 'media_policy', label: 'Medienrichtlinie', defaultTitle: 'Medienrichtlinie' }, ] const STATUS_LABELS = { draft: { label: 'Entwurf', color: 'var(--text3)' }, published: { label: 'Veröffentlicht', color: 'var(--accent)' }, archived: { label: 'Archiviert', color: 'var(--danger)' }, } function StatusBadge({ status }) { const s = STATUS_LABELS[status] || { label: status, color: 'var(--text3)' } return ( {s.label} ) } function SectionEditor({ sections, onChange }) { const update = (i, field, val) => onChange(sections.map((s, idx) => idx === i ? { ...s, [field]: val } : s)) const remove = (i) => onChange(sections.filter((_, idx) => idx !== i)) const move = (i, dir) => { const next = [...sections] const j = i + dir if (j < 0 || j >= next.length) return ;[next[i], next[j]] = [next[j], next[i]] onChange(next) } // Insert empty section after index i (-1 = prepend) const insertAfter = (i) => { const next = [...sections] next.splice(i + 1, 0, { heading: '', content: '' }) onChange(next) } const InsertButton = ({ afterIndex }) => (
) return (
{sections.map((sec, i) => (
Abschnitt {i + 1}
update(i, 'heading', e.target.value)} placeholder="Abschnittsüberschrift" />