+ >
+ )
+}
+
+export default ForgetPwdResponse
\ No newline at end of file
diff --git a/src/components/AuthPages/ForgotPassword/index.jsx b/src/components/AuthPages/ForgotPassword/index.jsx
index e53214b..d336a16 100644
--- a/src/components/AuthPages/ForgotPassword/index.jsx
+++ b/src/components/AuthPages/ForgotPassword/index.jsx
@@ -4,6 +4,8 @@ import WrenchBoard from "../../../assets/images/wrenchboard-logo-text.png";
import usersService from "../../../services/UsersService";
import InputCom from "../../Helpers/Inputs/InputCom";
import AuthLayout from "../AuthLayout";
+import EmailValidator from "../../../lib/EmailValidator";
+import ForgetPwdResponse from "../ForgetPwdResponse";
export default function ForgotPassword() {
const [checked, setValue] = useState(false);
@@ -11,7 +13,7 @@ export default function ForgotPassword() {
// email
const [email, setMail] = useState("");
const [msgError, setMsgError] = useState("");
- const [msgSuccess, setMsgSuccess] = useState(false);
+ const [msgSuccess, setMsgSuccess] = useState(null);
const navigate = useNavigate();
const userApi = new usersService();
@@ -27,8 +29,22 @@ export default function ForgotPassword() {
const resetHandler = async () => {
if (email == "") {
setMsgError("An email is required");
- } else if (!checked) {
+ return setTimeout(() => {
+ setMsgError(null);
+ }, process.env.REACT_APP_RESET_START_ERROR_TIMEOUT);
+ }
+ if (!checked) {
setMsgError("Check if you are human");
+ return setTimeout(() => {
+ setMsgError(null);
+ }, process.env.REACT_APP_RESET_START_ERROR_TIMEOUT);
+ }
+
+ if(!EmailValidator(email)){ // CHECKS IF EMAIL IS VALID
+ setMsgError("Invalid Email");
+ return setTimeout(() => {
+ setMsgError(null);
+ }, process.env.REACT_APP_RESET_START_ERROR_TIMEOUT);
}
if (email !== "" && checked) {
@@ -41,8 +57,11 @@ export default function ForgotPassword() {
setMail("");
setValue(false);
setResetLoading(false);
+ }else{
+ setMsgSuccess(false);
}
} catch (error) {
+ setMsgSuccess(false);
setResetLoading(false);
setMail("");
setMsgError("An error occurred");
@@ -53,9 +72,6 @@ export default function ForgotPassword() {
}, process.env.REACT_APP_RESET_START_ERROR_TIMEOUT);
}
}
- setTimeout(() => {
- setMsgError(null);
- }, process.env.REACT_APP_RESET_START_ERROR_TIMEOUT);
};
return (
@@ -73,106 +89,116 @@ export default function ForgotPassword() {
-
-
- Forget Password
-
-
- Enter your email to reset your password.
-
-
-
-
-
+ {msgSuccess == null ?
+ <>
+
+
+ Forget Password
+
+
+ Enter your email to reset your password.
+
- {/* hCaptha clone for the time being */}
-
-
-
- {/* Checkbox */}
-
-
-
-
-
+
+
+
+
+ {/* 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.
+
+ )} */}
+
+
+
+
+
- {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.
-