diff --git a/admin-compliance/app/sdk/dsfa/[id]/_components/AddMitigationModal.tsx b/admin-compliance/app/sdk/dsfa/[id]/_components/AddMitigationModal.tsx new file mode 100644 index 0000000..14bf16c --- /dev/null +++ b/admin-compliance/app/sdk/dsfa/[id]/_components/AddMitigationModal.tsx @@ -0,0 +1,205 @@ +'use client' + +import React, { useState } from 'react' +import { DSFARisk } from '@/lib/sdk/dsfa/types' +import type { SDMGoal } from '@/lib/sdk/dsfa/types' +import { + MITIGATION_LIBRARY, + MITIGATION_TYPE_LABELS, + SDM_GOAL_LABELS, + EFFECTIVENESS_LABELS, +} from '@/lib/sdk/dsfa/mitigation-library' +import type { CatalogMitigation } from '@/lib/sdk/dsfa/mitigation-library' + +export function AddMitigationModal({ + risks, + onClose, + onAdd, +}: { + risks: DSFARisk[] + onClose: () => void + onAdd: (data: { risk_id: string; description: string; type: string; responsible_party: string }) => void +}) { + const [mode, setMode] = useState<'library' | 'manual'>('library') + const [riskId, setRiskId] = useState(risks[0]?.id || '') + const [type, setType] = useState('technical') + const [description, setDescription] = useState('') + const [responsibleParty, setResponsibleParty] = useState('') + const [typeFilter, setTypeFilter] = useState<'all' | 'technical' | 'organizational' | 'legal'>('all') + const [sdmFilter, setSdmFilter] = useState('all') + + const filteredLibrary = MITIGATION_LIBRARY.filter(m => { + if (typeFilter !== 'all' && m.type !== typeFilter) return false + if (sdmFilter !== 'all' && !m.sdmGoals.includes(sdmFilter)) return false + return true + }) + + function selectCatalogMitigation(m: CatalogMitigation) { + setType(m.type) + setDescription(`${m.title}\n\n${m.description}\n\nRechtsgrundlage: ${m.legalBasis}`) + setMode('manual') + } + + return ( +
+
+

Massnahme hinzufuegen

+ + {/* Tab Toggle */} +
+ + +
+ + {mode === 'library' ? ( +
+ {/* Filters */} +
+ + +
+ + {/* Library List */} +
+ {filteredLibrary.map(m => ( + + ))} +
+ {filteredLibrary.length === 0 && ( +

Keine Massnahmen fuer die gewaehlten Filter.

+ )} +
+ ) : ( +
+
+ + +
+ +
+ + +
+ +
+ +