import { useState } from 'react'
import { Check, ArrowLeft } from 'lucide-react'
export function ForgotPassword({ onBack }) {
const [email, setEmail] = useState('')
const [sent, setSent] = useState(false)
const [loading, setLoading] = useState(false)
const [error, setError] = useState(null)
const handleSubmit = async () => {
if (!email.trim()) return setError('E-Mail eingeben')
setLoading(true); setError(null)
try {
const r = await fetch('/api/auth/forgot-password', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email: email.trim() })
})
if (!r.ok) throw new Error(await r.text())
setSent(true)
} catch(e) {
setError(e.message)
} finally { setLoading(false) }
}
if (sent) return (
đ§
E-Mail gesendet
Falls ein Konto mit dieser E-Mail existiert, hast du einen Link zum ZurĂźcksetzen erhalten.
Bitte prĂźfe auch deinen Spam-Ordner.
)
return (
Passwort vergessen
Recovery-Link per E-Mail
Gib deine E-Mail-Adresse ein. Du erhältst einen Link zum Zurßcksetzen deines Passworts.
setEmail(e.target.value)}
onKeyDown={e=>e.key==='Enter'&&handleSubmit()}
style={{width:'100%',marginBottom:12,boxSizing:'border-box'}} autoFocus/>
{error &&
{error}
}