'use client' import { useState } from 'react' interface CreateModalProps { onClose: () => void onCreated: () => void } export 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" />