'use client' import React, { useState } from 'react' import { AIUseCaseModule, AI_USE_CASE_TYPES, PRIVACY_BY_DESIGN_CATEGORIES, PrivacyByDesignCategory, PrivacyByDesignMeasure, AIModuleReviewTrigger, AIModuleReviewTriggerType, checkArt22Applicability, } from '@/lib/sdk/dsfa/ai-use-case-types' import { TABS, REVIEW_TRIGGER_TYPES } from './AIUseCaseEditorConstants' import { Tab1System, Tab2Data, Tab3Purpose, Tab4AIAct, Tab5Risks, Tab6PrivacyByDesign, Tab7Review, } from './AIUseCaseEditorTabs' interface AIUseCaseModuleEditorProps { module: AIUseCaseModule onSave: (module: AIUseCaseModule) => void onCancel: () => void isSaving?: boolean } export function AIUseCaseModuleEditor({ module: initialModule, onSave, onCancel, isSaving }: AIUseCaseModuleEditorProps) { const [activeTab, setActiveTab] = useState(1) const [module, setModule] = useState(initialModule) const [newCategory, setNewCategory] = useState('') const [newOutputCategory, setNewOutputCategory] = useState('') const [newSubject, setNewSubject] = useState('') const typeInfo = AI_USE_CASE_TYPES[module.use_case_type] const art22Required = checkArt22Applicability(module) const update = (updates: Partial) => { setModule(prev => ({ ...prev, ...updates })) } const addToList = (field: keyof AIUseCaseModule, value: string, setter: (v: string) => void) => { if (!value.trim()) return const current = (module[field] as string[]) || [] update({ [field]: [...current, value.trim()] } as Partial) setter('') } const removeFromList = (field: keyof AIUseCaseModule, idx: number) => { const current = (module[field] as string[]) || [] update({ [field]: current.filter((_, i) => i !== idx) } as Partial) } const togglePbdMeasure = (category: PrivacyByDesignCategory) => { const existing = module.privacy_by_design_measures || [] const found = existing.find(m => m.category === category) if (found) { update({ privacy_by_design_measures: existing.map(m => m.category === category ? { ...m, implemented: !m.implemented } : m )}) } else { const newMeasure: PrivacyByDesignMeasure = { category, description: PRIVACY_BY_DESIGN_CATEGORIES[category].description, implemented: true, } update({ privacy_by_design_measures: [...existing, newMeasure] }) } } const toggleReviewTrigger = (type: AIModuleReviewTriggerType) => { const existing = module.review_triggers || [] const found = existing.find(t => t.type === type) if (found) { update({ review_triggers: existing.filter(t => t.type !== type) }) } else { const label = REVIEW_TRIGGER_TYPES.find(rt => rt.value === type)?.label || type const newTrigger: AIModuleReviewTrigger = { type, description: label } update({ review_triggers: [...existing, newTrigger] }) } } return (
{/* Header */}
{typeInfo.icon}

{module.name || typeInfo.label}

{typeInfo.label} — KI-Anwendungsfall-Anhang

{/* Tab Bar */}
{TABS.map(tab => ( ))}
{/* Content */}
{activeTab === 1 && } {activeTab === 2 && ( )} {activeTab === 3 && } {activeTab === 4 && } {activeTab === 5 && } {activeTab === 6 && } {activeTab === 7 && }
{/* Footer */}
{activeTab > 1 && ( )} {activeTab < 7 && ( )}
) }