'use client' import { useState } from 'react' const inp: React.CSSProperties = { width: '100%', padding: '8px 12px', borderRadius: '6px', border: '1px solid var(--border-color)', background: 'var(--bg)', color: 'var(--text-primary)', fontSize: '14px', boxSizing: 'border-box', } const lbl: React.CSSProperties = { fontSize: '11px', fontWeight: 600, textTransform: 'uppercase', letterSpacing: '1px', color: 'var(--text-muted)', display: 'block', marginBottom: '6px', } export default function PasswortAendern() { const [current, setCurrent] = useState('') const [next, setNext] = useState('') const [confirm, setConfirm] = useState('') const [saving, setSaving] = useState(false) const [error, setError] = useState(null) const [success, setSuccess] = useState(false) async function handleSubmit(e: React.FormEvent) { e.preventDefault() setError(null) if (next !== confirm) { setError('Die neuen Passwörter stimmen nicht überein.'); return } if (next.length < 8) { setError('Das neue Passwort muss mindestens 8 Zeichen haben.'); return } setSaving(true) const res = await fetch('/api/admin/passwort', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ currentPassword: current, newPassword: next }), }) const json = await res.json() setSaving(false) if (!res.ok) { setError(json.error ?? 'Fehler beim Speichern.'); return } setSuccess(true) setCurrent(''); setNext(''); setConfirm('') setTimeout(() => setSuccess(false), 3000) } return (
setCurrent(e.target.value)} autoComplete="current-password" required />
setNext(e.target.value)} autoComplete="new-password" required />
setConfirm(e.target.value)} autoComplete="new-password" required />
{error && (

{error}

)}
) }