'use client' import React, { useState } from 'react' export function IncidentCreateModal({ onClose, onSuccess }: { onClose: () => void onSuccess: () => void }) { const [title, setTitle] = useState('') const [category, setCategory] = useState('data_breach') const [severity, setSeverity] = useState('medium') const [description, setDescription] = useState('') const [detectedBy, setDetectedBy] = useState('') const [affectedSystems, setAffectedSystems] = useState('') const [estimatedAffectedPersons, setEstimatedAffectedPersons] = useState('0') const [isSaving, setIsSaving] = useState(false) const [error, setError] = useState(null) const handleSave = async () => { if (!title.trim()) { setError('Titel ist erforderlich.') return } setIsSaving(true) setError(null) try { const res = await fetch('/api/sdk/v1/incidents', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ title, category, severity, description, detectedBy, affectedSystems: affectedSystems.split(',').map(s => s.trim()).filter(Boolean), estimatedAffectedPersons: Number(estimatedAffectedPersons) }) }) if (!res.ok) { const data = await res.json().catch(() => ({})) throw new Error(data.detail || data.message || `Fehler: ${res.status}`) } onSuccess() } catch (err: unknown) { setError(err instanceof Error ? err.message : 'Unbekannter Fehler') } finally { setIsSaving(false) } } return (
{/* Backdrop */}
{/* Modal */}

Neuen Vorfall erfassen

{error && (
{error}
)}
{/* Title */}
setTitle(e.target.value)} className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500 text-sm" placeholder="Kurze Beschreibung des Vorfalls" />
{/* Category */}
{/* Severity */}
{/* Description */}