'use client' import React, { useState, useEffect } from 'react' import { useSDK } from '@/lib/sdk' import { StepHeader, STEP_EXPLANATIONS } from '@/components/sdk/StepHeader' // ============================================================================= // TYPES // ============================================================================= interface Escalation { id: string title: string description: string | null priority: 'low' | 'medium' | 'high' | 'critical' status: 'open' | 'in_progress' | 'escalated' | 'resolved' | 'closed' category: string | null assignee: string | null reporter: string | null source_module: string | null due_date: string | null resolved_at: string | null created_at: string updated_at: string } interface EscalationStats { by_status: Record by_priority: Record total: number active: number } // ============================================================================= // HELPERS // ============================================================================= const priorityColors: Record = { critical: 'bg-red-500 text-white', high: 'bg-orange-500 text-white', medium: 'bg-yellow-500 text-white', low: 'bg-green-500 text-white', } const priorityLabels: Record = { critical: 'Kritisch', high: 'Hoch', medium: 'Mittel', low: 'Niedrig', } const statusColors: Record = { open: 'bg-blue-100 text-blue-700', in_progress: 'bg-yellow-100 text-yellow-700', escalated: 'bg-red-100 text-red-700', resolved: 'bg-green-100 text-green-700', closed: 'bg-gray-100 text-gray-600', } const statusLabels: Record = { open: 'Offen', in_progress: 'In Bearbeitung', escalated: 'Eskaliert', resolved: 'Geloest', closed: 'Geschlossen', } const categoryLabels: Record = { dsgvo_breach: 'DSGVO-Verletzung', ai_act: 'AI Act', vendor: 'Vendor', internal: 'Intern', other: 'Sonstiges', } function formatDate(iso: string | null): string { if (!iso) return '—' return new Date(iso).toLocaleDateString('de-DE') } // ============================================================================= // CREATE MODAL // ============================================================================= interface CreateModalProps { onClose: () => void onCreated: () => void } function EscalationCreateModal({ onClose, onCreated }: CreateModalProps) { const [title, setTitle] = useState('') const [description, setDescription] = useState('') const [priority, setPriority] = useState('medium') const [category, setCategory] = useState('') const [assignee, setAssignee] = useState('') const [dueDate, setDueDate] = useState('') const [saving, setSaving] = useState(false) const [error, setError] = useState(null) async function handleSave() { if (!title.trim()) { setError('Titel ist erforderlich.') return } setSaving(true) setError(null) try { const res = await fetch('/api/sdk/v1/escalations', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ title: title.trim(), description: description.trim() || null, priority, category: category || null, assignee: assignee.trim() || null, due_date: dueDate || null, }), }) if (!res.ok) { const err = await res.json() throw new Error(err.detail || err.error || 'Fehler beim Erstellen') } onCreated() onClose() } catch (e: unknown) { setError(e instanceof Error ? e.message : 'Unbekannter Fehler') } finally { setSaving(false) } } return (

Neue Eskalation erstellen

{error && (
{error}
)}
setTitle(e.target.value)} className="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-purple-500" placeholder="Kurze Beschreibung der Eskalation" />