import React, { useState } from "react"; import { Link, useNavigate } from "react-router-dom"; import WrenchBoard from "../../../assets/images/wrenchboard.png"; import usersService from "../../../services/UsersService"; import InputCom from "../../Helpers/Inputs/InputCom"; import AuthLayout from "../AuthLayout"; export default function ForgotPassword() { const [checked, setValue] = useState(false); const [resetLoading, setResetLoading] = useState(false); // email const [email, setMail] = useState(""); const [msgError, setMsgError] = useState(""); const [msgSuccess, setMsgSuccess] = useState(false); const navigate = useNavigate(); const userApi = new usersService(); const handleEmail = (e) => { setMail(e?.target.value); }; const humanChecker = () => { setValue(!checked); }; const resetHandler = async () => { if (email == "") { setMsgError("An email is required"); } else if (!checked) { setMsgError("Check if you are human"); } if (email !== "" && checked) { const reqData = { email }; setResetLoading(true); try { const res = await userApi.StartResetPassword(reqData); if (res.status === 200) { setMsgSuccess(true); setMail(""); setValue(false); setResetLoading(false); } } catch (error) { setResetLoading(false); setMail(""); setMsgError("An error occurred"); throw new Error(error); } finally { setTimeout(() => { setMsgError(null); }, process.env.REACT_APP_RESET_START_ERROR_TIMEOUT); } } setTimeout(() => { setMsgError(null); }, process.env.REACT_APP_RESET_START_ERROR_TIMEOUT); }; return ( <>
wrenchboard

Forget Password

Enter your email to reset your password.
{/* hCaptha clone for the time being */}
{/* Checkbox */}
{msgError && (
{msgError}
)} {msgSuccess && (
If we find your email, you will receive a link to reset your password. Please use or{" "} contact form {" "} if you did not get our message after few minutes.
)}
); }