'use client' import React, { useState } from 'react' import { AuthLayout } from '@/components/layouts/AuthLayout' import { Input } from '@/components/common/Input' import { Button } from '@/components/common/Button' import { Link } from '@/components/common/Link' import { useApi } from '@/lib/hooks/useApi' export default function ResetPasswordPage() { const { execute, isLoading, error } = useApi() const [email, setEmail] = useState('') const [emailError, setEmailError] = useState('') const [success, setSuccess] = useState(false) const validateEmail = () => { if (!email) { setEmailError('Email is required') return false } else if (!/\S+@\S+\.\S+/.test(email)) { setEmailError('Email is invalid') return false } setEmailError('') return true } const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() if (!validateEmail()) { return } const data = await execute({ method: 'POST', url: '/auth/reset-password/request', data: { email }, }) if (data) { setSuccess(true) } } if (success) { return ( We've sent a password reset link to{' '} {email} Please check your email and click the link to reset your password. The link will expire in 24 hours. Back to login ) } return ( {error && ( {error.message || 'Failed to send reset email. Please try again.'} )} { setEmail(e.target.value) if (emailError) setEmailError('') }} error={emailError} required fullWidth autoComplete="email" /> Send reset link Remember your password?{' '} Sign in ) }
We've sent a password reset link to{' '} {email}
Please check your email and click the link to reset your password. The link will expire in 24 hours.
{error.message || 'Failed to send reset email. Please try again.'}