'use client' import { useState } from 'react' export function ConsentTemplateCreateModal({ onClose, onSuccess, }: { onClose: () => void onSuccess: () => void }) { const [templateKey, setTemplateKey] = useState('') const [subject, setSubject] = useState('') const [body, setBody] = useState('') const [language, setLanguage] = useState('de') const [saving, setSaving] = useState(false) const [error, setError] = useState(null) async function handleSave() { if (!templateKey.trim()) { setError('Template-Key ist erforderlich.') return } setSaving(true) setError(null) try { const res = await fetch('/api/sdk/v1/consent-templates', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ template_key: templateKey.trim(), subject: subject.trim(), body: body.trim(), language, }), }) if (!res.ok) { const data = await res.json().catch(() => ({})) throw new Error(data.detail || data.message || `Fehler: ${res.status}`) } onSuccess() } catch (e: unknown) { setError(e instanceof Error ? e.message : 'Unbekannter Fehler') } finally { setSaving(false) } } return (

Neue E-Mail Vorlage

{error && (
{error}
)}
setTemplateKey(e.target.value)} className="w-full px-3 py-2 border border-slate-300 rounded-lg text-sm focus:ring-2 focus:ring-purple-500 focus:border-purple-500" placeholder="z.B. dsr_confirmation" />
setSubject(e.target.value)} className="w-full px-3 py-2 border border-slate-300 rounded-lg text-sm focus:ring-2 focus:ring-purple-500 focus:border-purple-500" placeholder="E-Mail Betreff" />