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 (

Check Your Email

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.

); } return (

Forgot Password?

No worries, we'll send you reset instructions

setEmail(e.target.value)} placeholder="your@email.com" disabled={isLoading} className="w-full px-4 py-2.5 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent disabled:bg-gray-100 disabled:cursor-not-allowed" required />
← Back to Login
); }