'use client' import { useState } from 'react' import Link from 'next/link' import { requestPasswordReset } from '@/lib/actions/auth' import { cn } from '@/lib/utils/index' import { Button } from '@/components/ui/button' import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' export function ForgotPasswordForm({ className, ...props }: React.ComponentPropsWithoutRef<'div'>) { const [email, setEmail] = useState('') const [error, setError] = useState(null) const [success, setSuccess] = useState(false) const [isLoading, setIsLoading] = useState(false) const handleForgotPassword = async (e: React.FormEvent) => { e.preventDefault() setIsLoading(true) setError(null) try { const result = await requestPasswordReset(email) if (!result.success) throw new Error(result.error ?? 'An error occurred') setSuccess(true) } catch (error: unknown) { setError(error instanceof Error ? error.message : 'An error occurred') } finally { setIsLoading(false) } } return (
{success ? ( Check Your Email Password reset instructions sent

If you registered using your email and password, you will receive a password reset email.

) : ( Reset Your Password Type in your email and we'll send you a link to reset your password
setEmail(e.target.value)} />
{error &&

{error}

}
Already have an account?{' '} Login
)}
) }