feat(compliance): P-01c Admin-konfigurierbare Rechtstexte (0.8.71)
Deploy Development / deploy (push) Successful in 46s
Test Suite / pytest-backend (push) Failing after 2s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 7s
Test Suite / playwright-tests (push) Successful in 50s
Deploy Development / deploy (push) Successful in 46s
Test Suite / pytest-backend (push) Failing after 2s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 7s
Test Suite / playwright-tests (push) Successful in 50s
DB 047: legal_documents (versioniert, draft/published/archived) +
legal_document_audit (Änderungslog); Partial-Unique-Index garantiert
max. ein published-Dokument pro document_type.
Backend: GET /api/legal-documents/{type}/published (kein Auth);
Superadmin-CRUD + Publish/Archive + Audit unter /api/admin/legal-documents.
Frontend: LegalPage lädt aus API mit Platzhalter-Fallback;
AdminLegalDocumentsPage (/admin/legal-documents) mit Tab-Navigation,
Versionsliste, Entwurf-Editor, Publish/Archive-Workflow, Änderungslog.
AdminPageNav: Link „Rechtstexte" ergänzt.
version: 0.8.71 (backend + frontend)
module: legal_documents 1.0.0
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
8bed0199b6
commit
80936b226d
14 files changed
+1184
-47
No files matched your search
@@ -38,6 +38,7 @@ import AdminHomeRedirect from './components/AdminHomeRedirect'
|
||||
import PlatformAdminRoute from './components/PlatformAdminRoute'
|
||||
import MediaLibraryPage from './pages/MediaLibraryPage'
|
||||
import LegalPage from './pages/LegalPage'
|
||||
import AdminLegalDocumentsPage from './pages/AdminLegalDocumentsPage'
|
||||
import SettingsLegalPage from './pages/SettingsLegalPage'
|
||||
import ActiveClubSwitcher from './components/ActiveClubSwitcher'
|
||||
import InactiveMembershipBanner from './components/InactiveMembershipBanner'
|
||||
@@ -242,6 +243,14 @@ function AppRoutes() {
|
||||
</PlatformAdminRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="admin/legal-documents"
|
||||
element={
|
||||
<PlatformAdminRoute>
|
||||
<AdminLegalDocumentsPage />
|
||||
</PlatformAdminRoute>
|
||||
}
|
||||
/>
|
||||
<Route path="trainer-contexts" element={<TrainerContextsPage />} />
|
||||
</Route>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { NavLink } from 'react-router-dom'
|
||||
import { TreePine, FolderTree, Download, Grid3x3, Users } from 'lucide-react'
|
||||
import { TreePine, FolderTree, Download, Grid3x3, Users, Scale } from 'lucide-react'
|
||||
|
||||
/**
|
||||
* Admin-Seiten-Navigation (horizontal) — nur für Super-Admins (globaler Portal-Mandant).
|
||||
@@ -11,6 +11,7 @@ export default function AdminPageNav() {
|
||||
{ to: '/admin/maturity-models', label: 'Fähigkeitsmatrix', icon: Grid3x3 },
|
||||
{ to: '/admin/catalogs', label: 'Kataloge', icon: FolderTree },
|
||||
{ to: '/admin/mediawiki-import', label: 'Wiki-Import', icon: Download },
|
||||
{ to: '/admin/legal-documents', label: 'Rechtstexte', icon: Scale },
|
||||
]
|
||||
|
||||
return (
|
||||
|
||||
@@ -0,0 +1,517 @@
|
||||
import { useState, useEffect, useCallback } from 'react'
|
||||
import { FileText, Plus, Eye, Edit2, Archive, CheckCircle, Clock, ChevronDown, ChevronUp } from 'lucide-react'
|
||||
import api from '../utils/api'
|
||||
|
||||
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 (
|
||||
<span style={{
|
||||
fontSize: '0.75rem',
|
||||
fontWeight: 600,
|
||||
color: s.color,
|
||||
border: `1px solid ${s.color}`,
|
||||
borderRadius: '4px',
|
||||
padding: '1px 6px',
|
||||
}}>
|
||||
{s.label}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
function SectionEditor({ sections, onChange }) {
|
||||
const addSection = () => onChange([...sections, { heading: '', content: '' }])
|
||||
const removeSection = (i) => onChange(sections.filter((_, idx) => idx !== i))
|
||||
const update = (i, field, val) => {
|
||||
const next = sections.map((s, idx) => idx === i ? { ...s, [field]: val } : s)
|
||||
onChange(next)
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{sections.map((sec, i) => (
|
||||
<div key={i} className="card" style={{ marginBottom: '0.75rem', padding: '12px' }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: '0.5rem' }}>
|
||||
<span style={{ fontSize: '0.8rem', color: 'var(--text3)' }}>Abschnitt {i + 1}</span>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
style={{ fontSize: '0.75rem', padding: '2px 8px' }}
|
||||
onClick={() => removeSection(i)}
|
||||
>
|
||||
Entfernen
|
||||
</button>
|
||||
</div>
|
||||
<div className="form-row">
|
||||
<label className="form-label">Überschrift</label>
|
||||
<input
|
||||
type="text"
|
||||
className="form-input"
|
||||
value={sec.heading}
|
||||
onChange={e => update(i, 'heading', e.target.value)}
|
||||
placeholder="Abschnittsüberschrift"
|
||||
/>
|
||||
</div>
|
||||
<div className="form-row">
|
||||
<label className="form-label">Inhalt</label>
|
||||
<textarea
|
||||
className="form-input"
|
||||
rows={4}
|
||||
value={sec.content}
|
||||
onChange={e => update(i, 'content', e.target.value)}
|
||||
placeholder="Textinhalt des Abschnitts"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
<button type="button" className="btn btn-secondary" onClick={addSection} style={{ width: '100%' }}>
|
||||
+ Abschnitt hinzufügen
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function DocTypeTab({ docType, active, onClick }) {
|
||||
return (
|
||||
<button
|
||||
className={`btn ${active ? 'btn-primary' : 'btn-secondary'}`}
|
||||
onClick={onClick}
|
||||
style={{ minWidth: '130px' }}
|
||||
>
|
||||
{docType.label}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
function DocumentRow({ doc, onPublish, onArchive, onEdit, onViewAudit }) {
|
||||
return (
|
||||
<div
|
||||
className="card"
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: '1rem',
|
||||
padding: '12px 16px',
|
||||
marginBottom: '0.5rem',
|
||||
}}
|
||||
>
|
||||
<div style={{ flex: 1 }}>
|
||||
<div style={{ fontWeight: 600, marginBottom: '2px' }}>
|
||||
{doc.title} <span style={{ color: 'var(--text3)', fontWeight: 400, fontSize: '0.85rem' }}>v{doc.version}</span>
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: '0.75rem', alignItems: 'center', flexWrap: 'wrap' }}>
|
||||
<StatusBadge status={doc.status} />
|
||||
{doc.published_at && (
|
||||
<span style={{ fontSize: '0.78rem', color: 'var(--text3)' }}>
|
||||
veröffentlicht {new Date(doc.published_at).toLocaleDateString('de-DE')}
|
||||
</span>
|
||||
)}
|
||||
{doc.change_note && (
|
||||
<span style={{ fontSize: '0.78rem', color: 'var(--text3)', fontStyle: 'italic' }}>
|
||||
{doc.change_note}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: '0.4rem', flexShrink: 0 }}>
|
||||
{doc.status === 'draft' && (
|
||||
<>
|
||||
<button
|
||||
className="btn btn-secondary"
|
||||
style={{ padding: '4px 10px', fontSize: '0.78rem' }}
|
||||
onClick={() => onEdit(doc)}
|
||||
title="Bearbeiten"
|
||||
>
|
||||
<Edit2 size={13} />
|
||||
</button>
|
||||
<button
|
||||
className="btn btn-primary"
|
||||
style={{ padding: '4px 10px', fontSize: '0.78rem' }}
|
||||
onClick={() => onPublish(doc)}
|
||||
title="Veröffentlichen"
|
||||
>
|
||||
<CheckCircle size={13} />
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
{doc.status === 'published' && (
|
||||
<button
|
||||
className="btn btn-secondary"
|
||||
style={{ padding: '4px 10px', fontSize: '0.78rem' }}
|
||||
onClick={() => onArchive(doc)}
|
||||
title="Archivieren"
|
||||
>
|
||||
<Archive size={13} />
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
className="btn btn-secondary"
|
||||
style={{ padding: '4px 10px', fontSize: '0.78rem' }}
|
||||
onClick={() => onViewAudit(doc)}
|
||||
title="Änderungslog"
|
||||
>
|
||||
<Clock size={13} />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function EditForm({ docType, editDoc, onSaved, onCancel }) {
|
||||
const [title, setTitle] = useState(editDoc ? editDoc.title : docType.defaultTitle)
|
||||
const [sections, setSections] = useState([])
|
||||
const [changeNote, setChangeNote] = useState('')
|
||||
const [saving, setSaving] = useState(false)
|
||||
const [error, setError] = useState(null)
|
||||
const [loadingDoc, setLoadingDoc] = useState(!!editDoc)
|
||||
|
||||
useEffect(() => {
|
||||
if (editDoc) {
|
||||
api.getLegalDocument(editDoc.id)
|
||||
.then(d => {
|
||||
setTitle(d.title)
|
||||
setSections(d.content_sections || [])
|
||||
setChangeNote(d.change_note || '')
|
||||
})
|
||||
.catch(e => setError(e.message))
|
||||
.finally(() => setLoadingDoc(false))
|
||||
}
|
||||
}, [editDoc])
|
||||
|
||||
const handleSave = async () => {
|
||||
setSaving(true)
|
||||
setError(null)
|
||||
try {
|
||||
const payload = { title, content_sections: sections, change_note: changeNote || null }
|
||||
if (editDoc) {
|
||||
await api.updateLegalDocument(editDoc.id, payload)
|
||||
} else {
|
||||
await api.createLegalDocument({ document_type: docType.key, ...payload })
|
||||
}
|
||||
onSaved()
|
||||
} catch (e) {
|
||||
setError(e.message)
|
||||
} finally {
|
||||
setSaving(false)
|
||||
}
|
||||
}
|
||||
|
||||
if (loadingDoc) return <div className="spinner" />
|
||||
|
||||
return (
|
||||
<div className="card" style={{ marginTop: '1rem' }}>
|
||||
<h3 style={{ marginBottom: '1rem' }}>
|
||||
{editDoc ? 'Entwurf bearbeiten' : 'Neuen Entwurf erstellen'}
|
||||
</h3>
|
||||
|
||||
{error && (
|
||||
<div className="card" style={{ borderLeft: '4px solid var(--danger)', marginBottom: '1rem' }}>
|
||||
<span style={{ color: 'var(--danger)' }}>{error}</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="form-row">
|
||||
<label className="form-label">Titel *</label>
|
||||
<input
|
||||
type="text"
|
||||
className="form-input"
|
||||
value={title}
|
||||
onChange={e => setTitle(e.target.value)}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="form-row">
|
||||
<label className="form-label">Abschnitte</label>
|
||||
<SectionEditor sections={sections} onChange={setSections} />
|
||||
</div>
|
||||
|
||||
<div className="form-row">
|
||||
<label className="form-label">Änderungsnotiz (optional)</label>
|
||||
<input
|
||||
type="text"
|
||||
className="form-input"
|
||||
value={changeNote}
|
||||
onChange={e => setChangeNote(e.target.value)}
|
||||
placeholder="z. B. Erste Version nach juristischer Prüfung"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div style={{ display: 'flex', gap: '0.75rem', marginTop: '0.5rem' }}>
|
||||
<button className="btn btn-primary" onClick={handleSave} disabled={saving || !title.trim()}>
|
||||
{saving ? 'Speichern…' : 'Entwurf speichern'}
|
||||
</button>
|
||||
<button className="btn btn-secondary" onClick={onCancel}>
|
||||
Abbrechen
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function AuditLog({ docId, onClose }) {
|
||||
const [entries, setEntries] = useState([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
|
||||
useEffect(() => {
|
||||
api.getLegalDocumentAudit(docId)
|
||||
.then(setEntries)
|
||||
.catch(() => setEntries([]))
|
||||
.finally(() => setLoading(false))
|
||||
}, [docId])
|
||||
|
||||
const ACTION_LABELS = {
|
||||
created: 'Erstellt',
|
||||
updated: 'Bearbeitet',
|
||||
published:'Veröffentlicht',
|
||||
archived: 'Archiviert',
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="card" style={{ marginTop: '1rem' }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: '1rem' }}>
|
||||
<h3 style={{ margin: 0 }}>Änderungslog</h3>
|
||||
<button className="btn btn-secondary" style={{ padding: '4px 10px', fontSize: '0.8rem' }} onClick={onClose}>
|
||||
Schließen
|
||||
</button>
|
||||
</div>
|
||||
{loading ? (
|
||||
<div className="spinner" />
|
||||
) : entries.length === 0 ? (
|
||||
<p style={{ color: 'var(--text3)' }}>Keine Einträge.</p>
|
||||
) : (
|
||||
entries.map(e => (
|
||||
<div key={e.id} style={{ padding: '8px 0', borderBottom: '1px solid var(--border)' }}>
|
||||
<div style={{ display: 'flex', gap: '0.75rem', alignItems: 'center', flexWrap: 'wrap' }}>
|
||||
<strong style={{ fontSize: '0.85rem' }}>{ACTION_LABELS[e.action] || e.action}</strong>
|
||||
{e.previous_status && (
|
||||
<span style={{ fontSize: '0.78rem', color: 'var(--text3)' }}>von {e.previous_status}</span>
|
||||
)}
|
||||
<span style={{ fontSize: '0.78rem', color: 'var(--text3)' }}>
|
||||
{new Date(e.created_at).toLocaleString('de-DE')}
|
||||
</span>
|
||||
{e.changed_by_name && (
|
||||
<span style={{ fontSize: '0.78rem', color: 'var(--text3)' }}>von {e.changed_by_name}</span>
|
||||
)}
|
||||
</div>
|
||||
{e.change_note && (
|
||||
<p style={{ margin: '2px 0 0', fontSize: '0.82rem', color: 'var(--text2)', fontStyle: 'italic' }}>
|
||||
{e.change_note}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default function AdminLegalDocumentsPage() {
|
||||
const [activeType, setActiveType] = useState(DOC_TYPES[0].key)
|
||||
const [documents, setDocuments] = useState([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [error, setError] = useState(null)
|
||||
const [showForm, setShowForm] = useState(false)
|
||||
const [editDoc, setEditDoc] = useState(null)
|
||||
const [auditDocId, setAuditDocId] = useState(null)
|
||||
const [confirmPublish, setConfirmPublish] = useState(null)
|
||||
|
||||
const activeDocType = DOC_TYPES.find(d => d.key === activeType)
|
||||
|
||||
const load = useCallback(() => {
|
||||
setLoading(true)
|
||||
setError(null)
|
||||
api.listLegalDocuments(activeType)
|
||||
.then(setDocuments)
|
||||
.catch(e => setError(e.message))
|
||||
.finally(() => setLoading(false))
|
||||
}, [activeType])
|
||||
|
||||
useEffect(() => {
|
||||
load()
|
||||
setShowForm(false)
|
||||
setEditDoc(null)
|
||||
setAuditDocId(null)
|
||||
setConfirmPublish(null)
|
||||
}, [load])
|
||||
|
||||
const handlePublish = async (doc) => {
|
||||
setConfirmPublish(doc)
|
||||
}
|
||||
|
||||
const confirmAndPublish = async () => {
|
||||
if (!confirmPublish) return
|
||||
try {
|
||||
await api.publishLegalDocument(confirmPublish.id, null)
|
||||
setConfirmPublish(null)
|
||||
load()
|
||||
} catch (e) {
|
||||
alert('Fehler: ' + e.message)
|
||||
}
|
||||
}
|
||||
|
||||
const handleArchive = async (doc) => {
|
||||
if (!confirm(`"${doc.title}" archivieren?`)) return
|
||||
try {
|
||||
await api.archiveLegalDocument(doc.id)
|
||||
load()
|
||||
} catch (e) {
|
||||
alert('Fehler: ' + e.message)
|
||||
}
|
||||
}
|
||||
|
||||
const handleEdit = (doc) => {
|
||||
setEditDoc(doc)
|
||||
setShowForm(true)
|
||||
setAuditDocId(null)
|
||||
}
|
||||
|
||||
const handleViewAudit = (doc) => {
|
||||
setAuditDocId(doc.id)
|
||||
setShowForm(false)
|
||||
setEditDoc(null)
|
||||
}
|
||||
|
||||
const handleNew = () => {
|
||||
setEditDoc(null)
|
||||
setShowForm(true)
|
||||
setAuditDocId(null)
|
||||
}
|
||||
|
||||
const handleSaved = () => {
|
||||
setShowForm(false)
|
||||
setEditDoc(null)
|
||||
load()
|
||||
}
|
||||
|
||||
const publishedDoc = documents.find(d => d.status === 'published')
|
||||
|
||||
return (
|
||||
<div className="app-main">
|
||||
<div style={{ maxWidth: '860px', margin: '0 auto' }}>
|
||||
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '0.75rem', marginBottom: '1.5rem' }}>
|
||||
<FileText size={22} color="var(--accent)" />
|
||||
<h1 style={{ margin: 0 }}>Rechtstexte verwalten</h1>
|
||||
</div>
|
||||
|
||||
<div className="card" style={{ marginBottom: '1rem', padding: '12px', background: 'var(--surface)' }}>
|
||||
<p style={{ margin: 0, fontSize: '0.88rem', color: 'var(--text2)' }}>
|
||||
Hier können Superadmins versionierte Rechtstexte erstellen, bearbeiten und veröffentlichen.
|
||||
Pro Dokumententyp kann immer nur ein Text veröffentlicht sein.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Tab-Leiste */}
|
||||
<div style={{ display: 'flex', gap: '0.5rem', flexWrap: 'wrap', marginBottom: '1.25rem' }}>
|
||||
{DOC_TYPES.map(dt => (
|
||||
<DocTypeTab
|
||||
key={dt.key}
|
||||
docType={dt}
|
||||
active={activeType === dt.key}
|
||||
onClick={() => setActiveType(dt.key)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Aktuell veröffentlicht */}
|
||||
{publishedDoc && (
|
||||
<div
|
||||
className="card"
|
||||
style={{
|
||||
marginBottom: '1rem',
|
||||
borderLeft: '3px solid var(--accent)',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: '0.75rem',
|
||||
padding: '10px 16px',
|
||||
}}
|
||||
>
|
||||
<CheckCircle size={16} color="var(--accent)" />
|
||||
<span style={{ fontSize: '0.88rem' }}>
|
||||
<strong>Aktuell live:</strong> {publishedDoc.title} (v{publishedDoc.version}
|
||||
{publishedDoc.published_at && `, ${new Date(publishedDoc.published_at).toLocaleDateString('de-DE')}`})
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Aktionen */}
|
||||
<div style={{ display: 'flex', justifyContent: 'flex-end', marginBottom: '0.75rem' }}>
|
||||
<button className="btn btn-primary" onClick={handleNew} style={{ display: 'flex', alignItems: 'center', gap: '0.4rem' }}>
|
||||
<Plus size={15} /> Neuer Entwurf
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Fehler */}
|
||||
{error && (
|
||||
<div className="card" style={{ borderLeft: '4px solid var(--danger)', marginBottom: '1rem' }}>
|
||||
<span style={{ color: 'var(--danger)' }}>{error}</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Bestätigung Veröffentlichen */}
|
||||
{confirmPublish && (
|
||||
<div className="card" style={{ borderLeft: '4px solid var(--accent)', marginBottom: '1rem' }}>
|
||||
<p style={{ margin: '0 0 0.75rem' }}>
|
||||
<strong>„{confirmPublish.title}"</strong> veröffentlichen?
|
||||
{publishedDoc && publishedDoc.id !== confirmPublish.id && (
|
||||
<> Die aktuelle Version ({publishedDoc.title} v{publishedDoc.version}) wird dabei archiviert.</>
|
||||
)}
|
||||
</p>
|
||||
<div style={{ display: 'flex', gap: '0.5rem' }}>
|
||||
<button className="btn btn-primary" onClick={confirmAndPublish}>Ja, veröffentlichen</button>
|
||||
<button className="btn btn-secondary" onClick={() => setConfirmPublish(null)}>Abbrechen</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Dokumentenliste */}
|
||||
{loading ? (
|
||||
<div className="spinner" />
|
||||
) : documents.length === 0 ? (
|
||||
<div className="card" style={{ textAlign: 'center', padding: '2rem', color: 'var(--text3)' }}>
|
||||
Noch keine Versionen für {activeDocType?.label}. Erstelle einen neuen Entwurf.
|
||||
</div>
|
||||
) : (
|
||||
documents.map(doc => (
|
||||
<DocumentRow
|
||||
key={doc.id}
|
||||
doc={doc}
|
||||
onPublish={handlePublish}
|
||||
onArchive={handleArchive}
|
||||
onEdit={handleEdit}
|
||||
onViewAudit={handleViewAudit}
|
||||
/>
|
||||
))
|
||||
)}
|
||||
|
||||
{/* Formular */}
|
||||
{showForm && (
|
||||
<EditForm
|
||||
docType={activeDocType}
|
||||
editDoc={editDoc}
|
||||
onSaved={handleSaved}
|
||||
onCancel={() => { setShowForm(false); setEditDoc(null) }}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Audit-Log */}
|
||||
{auditDocId && (
|
||||
<AuditLog docId={auditDocId} onClose={() => setAuditDocId(null)} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,4 +1,14 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import api from '../utils/api'
|
||||
|
||||
// document_type values used in the DB / API
|
||||
const TYPE_MAP = {
|
||||
impressum: 'impressum',
|
||||
datenschutz: 'privacy_policy',
|
||||
nutzungsbedingungen: 'terms_of_use',
|
||||
medienrichtlinie: 'media_policy',
|
||||
}
|
||||
|
||||
const PAGES = {
|
||||
impressum: {
|
||||
@@ -143,8 +153,31 @@ const LEGAL_LINKS = [
|
||||
]
|
||||
|
||||
function LegalPage({ type }) {
|
||||
const page = PAGES[type]
|
||||
if (!page) return null
|
||||
const fallback = PAGES[type]
|
||||
const [apiDoc, setApiDoc] = useState(undefined) // undefined = loading, null = not found
|
||||
const [loading, setLoading] = useState(true)
|
||||
|
||||
const documentType = TYPE_MAP[type]
|
||||
|
||||
useEffect(() => {
|
||||
if (!documentType) {
|
||||
setLoading(false)
|
||||
return
|
||||
}
|
||||
api.getPublishedLegalDocument(documentType)
|
||||
.then(doc => setApiDoc(doc))
|
||||
.catch(() => setApiDoc(null))
|
||||
.finally(() => setLoading(false))
|
||||
}, [documentType])
|
||||
|
||||
if (!fallback) return null
|
||||
|
||||
const isPlaceholder = !apiDoc
|
||||
|
||||
const title = apiDoc ? apiDoc.title : fallback.title
|
||||
const sections = apiDoc
|
||||
? (apiDoc.content_sections || [])
|
||||
: fallback.sections.map(s => ({ heading: s.heading, content: s.placeholder }))
|
||||
|
||||
return (
|
||||
<div style={{ minHeight: '100vh', background: 'var(--bg)', padding: '2rem 1rem' }}>
|
||||
@@ -156,33 +189,41 @@ function LegalPage({ type }) {
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div
|
||||
className="card"
|
||||
style={{
|
||||
marginBottom: '1.5rem',
|
||||
borderLeft: '4px solid var(--danger)',
|
||||
background: 'var(--surface)',
|
||||
}}
|
||||
>
|
||||
<strong style={{ color: 'var(--danger)' }}>⚠ MUSTER / PLATZHALTER</strong>
|
||||
<p style={{ margin: '0.5rem 0 0', color: 'var(--text2)', fontSize: '0.9rem' }}>
|
||||
Inhalt wird vor Produktivbetrieb juristisch geprüft und durch den Betreiber ergänzt.
|
||||
Diese Seite hat keinen rechtlich verbindlichen Charakter.
|
||||
</p>
|
||||
</div>
|
||||
{loading ? (
|
||||
<div className="spinner" />
|
||||
) : (
|
||||
<>
|
||||
{isPlaceholder && (
|
||||
<div
|
||||
className="card"
|
||||
style={{
|
||||
marginBottom: '1.5rem',
|
||||
borderLeft: '4px solid var(--danger)',
|
||||
background: 'var(--surface)',
|
||||
}}
|
||||
>
|
||||
<strong style={{ color: 'var(--danger)' }}>⚠ MUSTER / PLATZHALTER</strong>
|
||||
<p style={{ margin: '0.5rem 0 0', color: 'var(--text2)', fontSize: '0.9rem' }}>
|
||||
Inhalt wird vor Produktivbetrieb juristisch geprüft und durch den Betreiber ergänzt.
|
||||
Diese Seite hat keinen rechtlich verbindlichen Charakter.
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<h1 style={{ marginBottom: '2rem', color: 'var(--text1)' }}>{page.title}</h1>
|
||||
<h1 style={{ marginBottom: '2rem', color: 'var(--text1)' }}>{title}</h1>
|
||||
|
||||
{page.sections.map((section) => (
|
||||
<div key={section.heading} style={{ marginBottom: '1.75rem' }}>
|
||||
<h2 style={{ fontSize: '1.05rem', marginBottom: '0.4rem', color: 'var(--text1)' }}>
|
||||
{section.heading}
|
||||
</h2>
|
||||
<p style={{ color: 'var(--text3)', fontStyle: 'italic', margin: 0 }}>
|
||||
{section.placeholder}
|
||||
</p>
|
||||
</div>
|
||||
))}
|
||||
{sections.map((section, i) => (
|
||||
<div key={i} style={{ marginBottom: '1.75rem' }}>
|
||||
<h2 style={{ fontSize: '1.05rem', marginBottom: '0.4rem', color: 'var(--text1)' }}>
|
||||
{section.heading}
|
||||
</h2>
|
||||
<p style={{ color: isPlaceholder ? 'var(--text3)' : 'var(--text1)', fontStyle: isPlaceholder ? 'italic' : 'normal', margin: 0, whiteSpace: 'pre-wrap' }}>
|
||||
{section.content}
|
||||
</p>
|
||||
</div>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
|
||||
<div
|
||||
style={{
|
||||
|
||||
@@ -1510,7 +1510,30 @@ export const api = {
|
||||
request('/api/import/mediawiki/logs'),
|
||||
|
||||
deleteMediaWikiImportReference: (refId) =>
|
||||
request(`/api/import/mediawiki/references/${refId}`, { method: 'DELETE' })
|
||||
request(`/api/import/mediawiki/references/${refId}`, { method: 'DELETE' }),
|
||||
|
||||
// Legal Documents (public)
|
||||
getPublishedLegalDocument: (documentType) =>
|
||||
request(`/api/legal-documents/${documentType}/published`),
|
||||
|
||||
// Legal Documents (superadmin)
|
||||
listLegalDocuments: (documentType) =>
|
||||
request(`/api/admin/legal-documents${documentType ? `?document_type=${documentType}` : ''}`),
|
||||
createLegalDocument: (data) =>
|
||||
request('/api/admin/legal-documents', { method: 'POST', body: JSON.stringify(data) }),
|
||||
getLegalDocument: (id) =>
|
||||
request(`/api/admin/legal-documents/${id}`),
|
||||
updateLegalDocument: (id, data) =>
|
||||
request(`/api/admin/legal-documents/${id}`, { method: 'PUT', body: JSON.stringify(data) }),
|
||||
publishLegalDocument: (id, changeNote) =>
|
||||
request(`/api/admin/legal-documents/${id}/publish`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ change_note: changeNote }),
|
||||
}),
|
||||
archiveLegalDocument: (id) =>
|
||||
request(`/api/admin/legal-documents/${id}/archive`, { method: 'POST' }),
|
||||
getLegalDocumentAudit: (id) =>
|
||||
request(`/api/admin/legal-documents/${id}/audit`),
|
||||
}
|
||||
|
||||
export default api
|
||||
@@ -1,12 +1,13 @@
|
||||
// Shinkan Jinkendo Frontend Version
|
||||
|
||||
export const APP_VERSION = "0.8.70"
|
||||
export const APP_VERSION = "0.8.71"
|
||||
export const BUILD_DATE = "2026-05-10"
|
||||
|
||||
export const PAGE_VERSIONS = {
|
||||
LoginPage: "1.0.2",
|
||||
LegalPage: "1.0.0",
|
||||
LegalPage: "1.1.0",
|
||||
SettingsLegalPage: "1.0.0",
|
||||
AdminLegalDocumentsPage: "1.0.0",
|
||||
Dashboard: "1.0.0",
|
||||
AccountSettingsPage: "1.0.1",
|
||||
ExercisesPage: "1.5.0", // Fokus +/- Regeln, nur ohne Fokusbereich; Filterprefs
|
||||
|
||||
Reference in new issue
Block a user