diff --git a/src/assets/images/icons/error.svg b/src/assets/images/icons/error.svg
new file mode 100644
index 0000000..3cc645e
--- /dev/null
+++ b/src/assets/images/icons/error.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/assets/images/icons/success.svg b/src/assets/images/icons/success.svg
new file mode 100644
index 0000000..cae29c3
--- /dev/null
+++ b/src/assets/images/icons/success.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/components/AuthPages/ForgetPwdResponse.jsx b/src/components/AuthPages/ForgetPwdResponse.jsx
new file mode 100644
index 0000000..013678f
--- /dev/null
+++ b/src/components/AuthPages/ForgetPwdResponse.jsx
@@ -0,0 +1,37 @@
+import React from 'react'
+import { useNavigate } from 'react-router-dom'
+import localImgLoad from '../../lib/localImgLoad'
+
+const ForgetPwdResponse = ({title, message, type}) => {
+ const navigate = useNavigate()
+ return (
+ <>
+
+
+ {title}
+
+
+
+
+
+
+
+ {message}
+
+
+
+
+
+
+
+ >
+ )
+}
+
+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..0eb7772 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,12 +29,26 @@ 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) {
- const reqData = { email };
+ const reqData = { email, action:11013 };
setResetLoading(true);
try {
const res = await userApi.StartResetPassword(reqData);
@@ -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,102 @@ 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}
+
+ )}
+
+
+
+
- {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.
-
- This error occurs because you have already used this link or the link
- has broken/expired. Start with the reset process again. If it doesn't
- work, try to create the account from the start.
-
-
-
-
-
-
-
-);
diff --git a/src/lib/EmailValidator.js b/src/lib/EmailValidator.js
new file mode 100644
index 0000000..5521833
--- /dev/null
+++ b/src/lib/EmailValidator.js
@@ -0,0 +1,9 @@
+export default function EmailValidator(email) {
+ let regEx = /^[^0-9][a-zA-Z0-9._%+-]+@[a-zA-Z]+(\.[a-zA-Z]+)+$/;
+ if (regEx.test(email) == false) {
+ return false
+ }else{
+ return true
+ }
+}
+
\ No newline at end of file
diff --git a/src/lib/PasswordValidator.js b/src/lib/PasswordValidator.js
new file mode 100644
index 0000000..53b1a02
--- /dev/null
+++ b/src/lib/PasswordValidator.js
@@ -0,0 +1,9 @@
+export default function PasswordValidator(password) {
+ const regEx = /^[a-zA-Z0-9!@#$%^&*()_+{}\[\]:;<>,.?~\\/\-='"`|]+$/;
+ if (/[!@#$%^&*()_+{}\[\]:;<>,.?~\\/\-='"`|]/.test(password) == false || /[0-9]/.test(password)==false || /[A-Z]/.test(password)==false || /[a-z]/.test(password)==false) {
+ return false
+ }else{
+ return true
+ }
+}
+
\ No newline at end of file