import { useState } from "react"; import { Link } from "react-router-dom"; import { AuthWrapper } from "./AuthWrapper" import "./page-auth.css"; import AuthRepository from "../../repositories/AuthRepository"; import showToast from "../../services/toastService"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; const forgotPassSceham = z.object({ email: z.string().email(), }) const ForgotPasswordPage = () => { const [loding, setLoading] = useState(false) const { register, handleSubmit, formState: { errors }, reset, getValues } = useForm({ resolver: zodResolver(forgotPassSceham), defaultValues: { email: "" } }) const onSubmit = async (data) => { try { setLoading(true) const response = await AuthRepository.forgotPassword(data) if (response.data && response.success) showToast("verification email has been sent to your registered email address", "success") reset() setLoading(false) } catch (err) { reset() if (err.response.status === 404) { showToast("verification email has been sent to your registered email address", "success") } else { showToast("Something wrong", "error") } setLoading(false) } } return (

Forgot Password? 🔒

Enter your email and we'll send you instructions to reset your password

{errors.email && (
{errors.email.message}
)}
Back to login
{/* Footer Text */}
); }; export default ForgotPasswordPage;