diff --git a/admin-compliance/app/(sdk)/sdk/consent-management/page.tsx b/admin-compliance/app/(sdk)/sdk/consent-management/page.tsx index e7ee345..56778c2 100644 --- a/admin-compliance/app/(sdk)/sdk/consent-management/page.tsx +++ b/admin-compliance/app/(sdk)/sdk/consent-management/page.tsx @@ -12,6 +12,7 @@ */ import { useState, useEffect } from 'react' +import { useRouter } from 'next/navigation' import Link from 'next/link' import { useSDK } from '@/lib/sdk' import StepHeader from '@/components/sdk/StepHeader/StepHeader' @@ -207,9 +208,138 @@ function ApiGdprProcessEditor({ ) } +// ============================================================================= +// CONSENT TEMPLATE CREATE MODAL +// ============================================================================= + +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" + /> +
+
+ +