'use client' import React, { useState, useEffect } from 'react' interface TOMControl { id: string title: string description: string domain_id: string priority: string gdpr_articles: string[] } interface TOMControlPanelProps { obligationId: string onClose: () => void } const UCCA_API = '/api/sdk/v1/ucca/obligations' const DOMAIN_LABELS: Record = { GOV: 'Governance', HR: 'Human Resources', IAM: 'Identity & Access', AC: 'Access Control', CRYPTO: 'Kryptographie', LOG: 'Logging & Monitoring', SDLC: 'Softwareentwicklung', OPS: 'Betrieb', NET: 'Netzwerk', BCP: 'Business Continuity', VENDOR: 'Lieferanten', DATA: 'Datenschutz', } const PRIORITY_COLORS: Record = { kritisch: 'bg-red-100 text-red-700', hoch: 'bg-orange-100 text-orange-700', mittel: 'bg-yellow-100 text-yellow-700', niedrig: 'bg-green-100 text-green-700', } export default function TOMControlPanel({ obligationId, onClose }: TOMControlPanelProps) { const [controls, setControls] = useState([]) const [loading, setLoading] = useState(true) const [error, setError] = useState(null) useEffect(() => { async function load() { setLoading(true) setError(null) try { const res = await fetch(`${UCCA_API}/tom-controls/for-obligation/${obligationId}`) if (!res.ok) throw new Error(`HTTP ${res.status}`) const data = await res.json() setControls(data.controls || []) } catch (e) { setError(e instanceof Error ? e.message : 'Laden fehlgeschlagen') } finally { setLoading(false) } } load() }, [obligationId]) return (

TOM Controls

{loading &&

Lade Controls...

} {error &&

{error}

} {!loading && !error && controls.length === 0 && (

Keine TOM Controls verknuepft

)} {!loading && controls.length > 0 && (
{controls.map(c => (
{c.id} {DOMAIN_LABELS[c.domain_id] || c.domain_id} {c.priority && ( {c.priority} )}

{c.title}

{c.description && (

{c.description}

)}
))}
)}
) }