'use client' import React, { useState, useEffect } from 'react' import { useParams } from 'next/navigation' interface TechFileSection { id: string section_type: string title: string description: string content: string | null status: 'empty' | 'draft' | 'generated' | 'reviewed' | 'approved' generated_at: string | null approved_at: string | null approved_by: string | null required: boolean } const SECTION_TYPES: Record = { risk_assessment_report: { icon: '📊', description: 'Zusammenfassung der Risikobeurteilung mit allen bewerteten Gefaehrdungen', }, hazard_log: { icon: '⚠️', description: 'Vollstaendiges Gefaehrdungsprotokoll mit S/E/P-Bewertungen', }, component_list: { icon: '🔧', description: 'Verzeichnis aller sicherheitsrelevanten Komponenten', }, classification_report: { icon: '📋', description: 'Regulatorische Klassifikation (AI Act, MVO, CRA, NIS2)', }, mitigation_report: { icon: '🛡️', description: 'Uebersicht aller Schutzmassnahmen nach 3-Stufen-Verfahren', }, verification_report: { icon: '✅', description: 'Verifikationsplan und Ergebnisse aller Nachweisverfahren', }, evidence_index: { icon: '📎', description: 'Index aller Nachweisdokumente mit Verknuepfungen', }, declaration_of_conformity: { icon: '📜', description: 'EU-Konformitaetserklaerung', }, instructions_for_use: { icon: '📖', description: 'Sicherheitshinweise fuer Betriebsanleitung', }, monitoring_plan: { icon: '📡', description: 'Post-Market Surveillance Plan', }, } const STATUS_CONFIG: Record = { empty: { label: 'Leer', color: 'text-gray-500', bgColor: 'bg-gray-100' }, draft: { label: 'Entwurf', color: 'text-yellow-700', bgColor: 'bg-yellow-100' }, generated: { label: 'Generiert', color: 'text-blue-700', bgColor: 'bg-blue-100' }, reviewed: { label: 'Geprueft', color: 'text-orange-700', bgColor: 'bg-orange-100' }, approved: { label: 'Freigegeben', color: 'text-green-700', bgColor: 'bg-green-100' }, } function StatusBadge({ status }: { status: string }) { const config = STATUS_CONFIG[status] || STATUS_CONFIG.empty return ( {config.label} ) } function SectionViewer({ section, onClose, onApprove, onSave, }: { section: TechFileSection onClose: () => void onApprove: (id: string) => void onSave: (id: string, content: string) => void }) { const [editedContent, setEditedContent] = useState(section.content || '') const [editing, setEditing] = useState(false) return (
{SECTION_TYPES[section.section_type]?.icon || '📄'}

{section.title}

{!editing && section.content && ( )} {editing && ( )} {section.status !== 'approved' && section.content && !editing && ( )}
{editing ? (