'use client' import React, { useState } from 'react' export function WhistleblowerCreateModal({ onClose, onSuccess }: { onClose: () => void onSuccess: () => void }) { const [title, setTitle] = useState('') const [description, setDescription] = useState('') const [category, setCategory] = useState('corruption') const [priority, setPriority] = useState('normal') const [isAnonymous, setIsAnonymous] = useState(true) const [reporterName, setReporterName] = useState('') const [reporterEmail, setReporterEmail] = useState('') const [isSaving, setIsSaving] = useState(false) const [error, setError] = useState(null) const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() if (!title.trim() || !description.trim()) return setIsSaving(true) setError(null) try { const body: Record = { title: title.trim(), description: description.trim(), category, priority, isAnonymous, status: 'new' } if (!isAnonymous) { body.reporterName = reporterName.trim() body.reporterEmail = reporterEmail.trim() } const res = await fetch('/api/sdk/v1/whistleblower/reports', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) }) 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 */}

Neue Meldung erfassen

{error && (
{error}
)}
{/* Title */}
setTitle(e.target.value)} required 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" />
{/* Description */}