import { useState } from 'react'; import { supabase } from '@imphnen-frontend-service/service'; import { Link } from 'react-router'; import { toast } from 'sonner'; export default function ForgotPasswordPage() { const [email, setEmail] = useState(''); const [isLoading, setIsLoading] = useState(false); const [emailSent, setEmailSent] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (!email) { toast.error('Please enter your email'); return; } try { setIsLoading(true); const { error } = await supabase.auth.resetPasswordForEmail(email, { redirectTo: `${window.location.origin}/auth/reset-password`, }); if (error) { throw error; } setEmailSent(true); toast.success('Password reset email sent! Check your inbox.'); } catch (err) { console.error('Failed to send reset email:', err); toast.error((err as Error).message || 'Failed to send reset email'); } finally { setIsLoading(false); } }; if (emailSent) { return (
We've sent a password reset link to {email}
Click the link in the email to reset your password. The link will expire in 1 hour.
No worries, we'll send you reset instructions