'use client' import React, { useState, useEffect, useCallback } from 'react' import Link from 'next/link' import { useParams, useRouter } from 'next/navigation' import { DSFA, DSFARisk, DSFAMitigation, DSFA_SECTIONS, DSFA_STATUS_LABELS, DSFA_RISK_LEVEL_LABELS, DSFA_LEGAL_BASES, DSFA_AFFECTED_RIGHTS, calculateRiskLevel, SDM_GOALS, } from '@/lib/sdk/dsfa/types' import type { SDMGoal, DSFARiskCategory } from '@/lib/sdk/dsfa/types' import { RISK_CATALOG, RISK_CATEGORY_LABELS, COMPONENT_FAMILY_LABELS, getRisksByCategory, getRisksBySDMGoal, } from '@/lib/sdk/dsfa/risk-catalog' import type { CatalogRisk } from '@/lib/sdk/dsfa/risk-catalog' import { MITIGATION_LIBRARY, MITIGATION_TYPE_LABELS, SDM_GOAL_LABELS, EFFECTIVENESS_LABELS, getMitigationsBySDMGoal, getMitigationsByType, getMitigationsForRisk, } from '@/lib/sdk/dsfa/mitigation-library' import type { CatalogMitigation } from '@/lib/sdk/dsfa/mitigation-library' import { getDSFA, updateDSFASection, addDSFARisk, removeDSFARisk, addDSFAMitigation, updateDSFAMitigationStatus, updateDSFA, } from '@/lib/sdk/dsfa/api' import { RiskMatrix, ApprovalPanel, DSFASidebar, ThresholdAnalysisSection, StakeholderConsultationSection, Art36Warning, ReviewScheduleSection, AIUseCaseSection, } from '@/components/sdk/dsfa' // ============================================================================= // SECTION EDITORS // ============================================================================= interface SectionProps { dsfa: DSFA onUpdate: (data: Record) => Promise isSubmitting: boolean } // Section 1: Systematische Beschreibung (Art. 35 Abs. 7 lit. a) function Section1Editor({ dsfa, onUpdate, isSubmitting }: SectionProps) { const [formData, setFormData] = useState({ processing_description: dsfa.processing_description || '', processing_purpose: dsfa.processing_purpose || '', data_categories: dsfa.data_categories || [], data_subjects: dsfa.data_subjects || [], recipients: dsfa.recipients || [], legal_basis: dsfa.legal_basis || '', legal_basis_details: dsfa.legal_basis_details || '', }) const [newCategory, setNewCategory] = useState('') const [newSubject, setNewSubject] = useState('') const [newRecipient, setNewRecipient] = useState('') const handleSave = () => { onUpdate(formData) } const addItem = (field: 'data_categories' | 'data_subjects' | 'recipients', value: string, setter: (v: string) => void) => { if (value.trim()) { setFormData(prev => ({ ...prev, [field]: [...prev[field], value.trim()] })) setter('') } } const removeItem = (field: 'data_categories' | 'data_subjects' | 'recipients', index: number) => { setFormData(prev => ({ ...prev, [field]: prev[field].filter((_, i) => i !== index) })) } return (
{/* Processing Purpose */}