'use client'; import { useState } from 'react'; import { Link } from '@/core/lib/navigation'; import { getClient } from '@/core/lib/brainerce'; import { LoadingSpinner } from '@/ui/shared/loading-spinner'; import { useTranslations } from '@/core/lib/translations'; export default function ForgotPasswordPage() { const t = useTranslations('auth'); const [email, setEmail] = useState(''); const [loading, setLoading] = useState(false); const [sent, setSent] = useState(false); const [error, setError] = useState(null); async function handleSubmit(e: React.FormEvent) { e.preventDefault(); if (loading) return; try { setLoading(true); setError(null); const client = getClient(); // The reset link's host is chosen by the server (the channel's domain), // never by this page; the email lands on /reset-password?token=... await client.forgotPassword(email); setSent(true); } catch (err) { const message = err instanceof Error ? err.message : 'Something went wrong. Please try again.'; setError(message); } finally { setLoading(false); } } return (

{t('forgotPasswordTitle')}

{t('forgotPasswordSubtitle')}

{error && (
{error}
)} {sent ? (
{t('resetLinkSent')}
{t('backToLogin')}
) : (
setEmail(e.target.value)} placeholder={t('emailPlaceholder')} autoComplete="email" className="border-border bg-background text-foreground placeholder:text-muted-foreground focus:ring-primary/20 focus:border-primary h-10 w-full rounded border px-3 text-sm focus:outline-none focus:ring-2" />
{t('backToLogin')}
)}
); }