'use client'; import { useState } from 'react'; import Link from 'next/link'; import { useForm } from 'react-hook-form'; import { zodResolver } from '@hookform/resolvers/zod'; import { z } from 'zod'; import { toast } from 'sonner'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { BrandedAuthShell } from '@/components/shared/branded-auth-shell'; import { cn } from '@/lib/utils'; const resetSchema = z.object({ email: z.string().email('Please enter a valid email address'), }); type ResetFormData = z.infer; export default function ResetPasswordPage() { const [submitted, setSubmitted] = useState(false); const [isLoading, setIsLoading] = useState(false); const { register, handleSubmit, formState: { errors }, } = useForm({ resolver: zodResolver(resetSchema), }); async function onSubmit(data: ResetFormData) { setIsLoading(true); try { // Always show the same success message regardless of whether the email exists. await fetch('/api/auth/reset-password', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email: data.email }), }); setSubmitted(true); } catch { toast.error('Something went wrong. Please try again.'); } finally { setIsLoading(false); } } return (

Reset your password

We'll email you a link

{submitted ? (

Check your email

If an account exists for that email address, we have sent a password reset link. Please check your inbox and spam folder.

Back to sign in
) : (
{errors.email &&

{errors.email.message}

}

Remember your password?{' '} Sign in

)}
); }