Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 20dae2dbc3 | |||
| b75c12f0a9 | |||
| dd94177a95 | |||
| d9c381ed83 | |||
| a50b9f0026 | |||
| fb4939946e | |||
| 12e940d9b3 | |||
| fbeff6d8c5 | |||
| 1d18d8e6ac | |||
| 81aff85dae | |||
| 145b77dcf7 | |||
| fabf07f2d1 |
@@ -18,11 +18,13 @@ REACT_APP_USERS_ENDPOINT="https://apigate.lotus.g1.wrenchboard.com/svs/user"
|
||||
#"https://devapi.mermsemr.com/en/desktop/api/v2/myfituser"
|
||||
|
||||
REACT_APP_SESSION_EXPIRE_MINUTES=300000
|
||||
REACT_APP_SESSION_EXPIRE_CHECKER=300000
|
||||
REACT_APP_SESSION_EXPIRE_CHECKER=60000
|
||||
|
||||
REACT_APP_LOGIN_ERROR_TIMEOUT=7000
|
||||
REACT_APP_SIGNUP_ERROR_TIMEOUT=7000
|
||||
|
||||
REACT_APP_FLUTTERWAVE_APIKEY=FLWPUBK_TEST-54c90141b028789d671067bd72f781a9-X
|
||||
|
||||
# Had to change the error time to 3sec cause it took too long
|
||||
REACT_APP_RESET_START_ERROR_TIMEOUT=3000
|
||||
|
||||
|
||||
+3
-1
@@ -18,11 +18,13 @@ REACT_APP_USERS_ENDPOINT="https://apigate.lotus.g1.wrenchboard.com/svs/user"
|
||||
#"https://devapi.mermsemr.com/en/desktop/api/v2/myfituser"
|
||||
|
||||
REACT_APP_SESSION_EXPIRE_MINUTES=300000
|
||||
REACT_APP_SESSION_EXPIRE_CHECKER=300000
|
||||
REACT_APP_SESSION_EXPIRE_CHECKER=60000
|
||||
|
||||
REACT_APP_LOGIN_ERROR_TIMEOUT=7000
|
||||
REACT_APP_SIGNUP_ERROR_TIMEOUT=7000
|
||||
|
||||
REACT_APP_FLUTTERWAVE_APIKEY=FLWPUBK_TEST-54c90141b028789d671067bd72f781a9-X
|
||||
|
||||
# Had to change the error time to 3sec cause it took too long
|
||||
REACT_APP_RESET_START_ERROR_TIMEOUT=3000
|
||||
|
||||
|
||||
+3
-1
@@ -18,11 +18,13 @@ REACT_APP_USERS_ENDPOINT="https://apigate.orion.g1.wrenchboard.com/svs/user"
|
||||
#"https://devapi.mermsemr.com/en/desktop/api/v2/myfituser"
|
||||
|
||||
REACT_APP_SESSION_EXPIRE_MINUTES=300000
|
||||
REACT_APP_SESSION_EXPIRE_CHECKER=300000
|
||||
REACT_APP_SESSION_EXPIRE_CHECKER=60000
|
||||
|
||||
REACT_APP_LOGIN_ERROR_TIMEOUT=7000
|
||||
REACT_APP_SIGNUP_ERROR_TIMEOUT=7000
|
||||
|
||||
REACT_APP_FLUTTERWAVE_APIKEY=FLWPUBK_TEST-54c90141b028789d671067bd72f781a9-X
|
||||
|
||||
# Had to change the error time to 3sec cause it took too long
|
||||
REACT_APP_RESET_START_ERROR_TIMEOUT=3000
|
||||
|
||||
|
||||
+6
-6
@@ -14,16 +14,16 @@
|
||||
"cors": "^2.8.5",
|
||||
"faker": "^6.6.6",
|
||||
"formik": "^2.2.9",
|
||||
"react": "^18.0.0",
|
||||
"react-chartjs-2": "^4.1.0",
|
||||
"react-countup": "^6.2.0",
|
||||
"react-dom": "^18.0.0",
|
||||
"react-lottie": "^1.2.3",
|
||||
"react-redux": "^8.0.2",
|
||||
"react-router-dom": "^6.0.2",
|
||||
"react-scripts": "5.0.0",
|
||||
"react-slick": "^0.29.0",
|
||||
"react-toastify": "^9.0.1",
|
||||
"flutterwave-react-v3": "^1.3.0",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-redux": "^8.0.5",
|
||||
"react-scripts": "5.0.1",
|
||||
"redux": "^4.2.0",
|
||||
"slick-carousel": "^1.8.1",
|
||||
"web-vitals": "^1.0.1",
|
||||
@@ -53,4 +53,4 @@
|
||||
"last 1 safari version"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -22,7 +22,7 @@ import UpdatePasswordPages from "./views/UpdatePasswordPages";
|
||||
import UploadProductPage from "./views/UploadProductPage";
|
||||
import UserProfilePage from "./views/UserProfilePage";
|
||||
import VerifyYouPages from "./views/VerifyYouPages";
|
||||
|
||||
import VerifyPasswordPages from "./views/VerifyPasswordPages";
|
||||
import RemindersPage from './views/RemindersPage';
|
||||
import TrackingPage from "./views/TrackingPage";
|
||||
import CalendarPage from "./views/CalendarPage";
|
||||
@@ -50,6 +50,7 @@ export default function Routers() {
|
||||
element={<UpdatePasswordPages />}
|
||||
/>
|
||||
<Route path="/vemail" element={<VerifyLinkPages />} />
|
||||
<Route path="/complereset" element={<VerifyPasswordPages />} />
|
||||
<Route exact path="/outmessage" element={<VerifyYouPages />} />
|
||||
|
||||
{/* private route */}
|
||||
|
||||
@@ -4,17 +4,16 @@ import { toast } from "react-toastify";
|
||||
import googleLogo from "../../../assets/images/google-logo.svg";
|
||||
import appleLogo from "../../../assets/images/apple-black.svg";
|
||||
import facebookLogo from "../../../assets/images/facebook-4.svg";
|
||||
import WrenchBoard from "../../../assets/images/wrenchboard.png"
|
||||
import WrenchBoard from "../../../assets/images/wrenchboard.png";
|
||||
import usersService from "../../../services/UsersService";
|
||||
import InputCom from "../../Helpers/Inputs/InputCom";
|
||||
import AuthLayout from "../AuthLayout";
|
||||
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import {updateUserDetails} from '../../../store/UserDetails'
|
||||
import { updateUserDetails } from "../../../store/UserDetails";
|
||||
|
||||
export default function Login() {
|
||||
|
||||
const dispatch = useDispatch()
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const [checked, setValue] = useState(false);
|
||||
const [loginLoading, setLoginLoading] = useState(false);
|
||||
@@ -22,7 +21,7 @@ export default function Login() {
|
||||
//login error state
|
||||
const [loginError, setLoginError] = useState(false);
|
||||
// for the catch error
|
||||
const [msgError, setMsgError] = useState('');
|
||||
const [msgError, setMsgError] = useState("");
|
||||
|
||||
const rememberMe = () => {
|
||||
setValue(!checked);
|
||||
@@ -41,57 +40,62 @@ export default function Login() {
|
||||
const navigate = useNavigate();
|
||||
const userApi = new usersService();
|
||||
|
||||
|
||||
const doLogin = async () => {
|
||||
if (email == '' && password == '') {
|
||||
setMsgError('Please fill in fields')
|
||||
}
|
||||
try {
|
||||
if (email !== "" && password !== "") {
|
||||
var postData = {
|
||||
username: email,
|
||||
password: password,
|
||||
sessionid: 'STARTING'
|
||||
sessionid: "STARTING",
|
||||
};
|
||||
const loginResult = await userApi.logInUser(postData); // just for a test
|
||||
const loginResult = await userApi.logInUser(postData); // just for a test
|
||||
//debugger;
|
||||
// if (email === "support@mermsemr.com") {
|
||||
if (loginResult.data.status > 0 && loginResult.data.internal_return == 100 && loginResult.data.session != '') { // just for a start
|
||||
if (
|
||||
loginResult.data.status > 0 &&
|
||||
loginResult.data.internal_return == 100 &&
|
||||
loginResult.data.session != ""
|
||||
) {
|
||||
// just for a start
|
||||
localStorage.setItem("member_id", `${loginResult.data.member_id}`);
|
||||
localStorage.setItem("uid", `${loginResult.data.uid}`);
|
||||
localStorage.setItem("session_token", `${loginResult.data.session}`);
|
||||
localStorage.setItem("session", `${loginResult.data.session}`);
|
||||
setLoginLoading(true);
|
||||
// userApi.getUserReminders(); //testing
|
||||
dispatch(updateUserDetails(loginResult.data))
|
||||
dispatch(updateUserDetails(loginResult.data));
|
||||
setTimeout(() => {
|
||||
navigate("/", { replace: true });
|
||||
setLoginLoading(false);
|
||||
}, 2000);
|
||||
} else {
|
||||
// toast.error("Invalid Credential");
|
||||
setLoginError(true)
|
||||
setLoginError(true);
|
||||
}
|
||||
} else {
|
||||
setMsgError("Please fill in fields");
|
||||
}
|
||||
} catch (error) {
|
||||
setMsgError('An error occurred')
|
||||
setMsgError("An error occurred");
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
setLoginError(false)
|
||||
setMsgError(null)
|
||||
}, Number(process.env.REACT_APP_LOGIN_ERROR_TIMEOUT))
|
||||
setLoginError(false);
|
||||
setMsgError(null);
|
||||
}, Number(process.env.REACT_APP_LOGIN_ERROR_TIMEOUT));
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<AuthLayout
|
||||
slogan="Welcome to WrenchBoard"
|
||||
>
|
||||
<AuthLayout slogan="Welcome to WrenchBoard">
|
||||
<div className="w-full">
|
||||
<div className='mb-12'>
|
||||
<Link to='#'>
|
||||
<img src={WrenchBoard} alt="wrenchboard" className="h-10 mx-auto" />
|
||||
<div className="mb-12">
|
||||
<Link to="#">
|
||||
<img
|
||||
src={WrenchBoard}
|
||||
alt="wrenchboard"
|
||||
className="h-10 mx-auto"
|
||||
/>
|
||||
</Link>
|
||||
</div>
|
||||
<div className="content-wrapper login shadow-md w-full lg:max-w-[500px] mx-auto flex justify-center items-center xl:bg-white dark:bg-dark-white 2xl:w-[828px] rounded-[0.475rem] sm:p-7 p-5">
|
||||
@@ -100,7 +104,15 @@ export default function Login() {
|
||||
<h1 className="text-[#181c32] font-semibold dark:text-white mb-3 leading-[27.3px] text-[22.75px]">
|
||||
Sign In to WrenchBoard
|
||||
</h1>
|
||||
<span className="text-gray-400 font-medium text-[16.25px] leading-[24.375px]">New Here? <Link to='/signup' className='font-semibold text-[#4687ba] hover:text-[#009ef7] transition'>Create an Account</Link></span>
|
||||
<span className="text-gray-400 font-medium text-[16.25px] leading-[24.375px]">
|
||||
New Here?{" "}
|
||||
<Link
|
||||
to="/signup"
|
||||
className="font-semibold text-[#4687ba] hover:text-[#009ef7] transition"
|
||||
>
|
||||
Create an Account
|
||||
</Link>
|
||||
</span>
|
||||
</div>
|
||||
<div className="input-area">
|
||||
<div className="input-item mb-5">
|
||||
@@ -160,8 +172,23 @@ export default function Login() {
|
||||
Forgot Password
|
||||
</a>
|
||||
</div> */}
|
||||
{loginError && <div className="relative p-4 text-[#912741] bg-[#fcd9e2] border-[#fbc6d3] mb-4 rounded-[0.475rem] text-md font-thin leading-[19.5px] text-[13px]">Invalid username or password- Please <Link to='/#' className='text-[#009ef7]'>reset your password</Link> or <Link to='/signup' className='text-[#009ef7]'>create a new account</Link></div>}
|
||||
{msgError && <div className="relative p-4 text-[#912741] bg-[#fcd9e2] border-[#fbc6d3] mb-4 rounded-[0.475rem] text-md font-light leading-[19.5px] text-[13px]">{msgError}</div>}
|
||||
{loginError && (
|
||||
<div className="relative p-4 text-[#912741] bg-[#fcd9e2] border-[#fbc6d3] mb-4 rounded-[0.475rem] text-md font-thin leading-[19.5px] text-[13px]">
|
||||
Invalid username or password- Please{" "}
|
||||
<Link to="/#" className="text-[#009ef7]">
|
||||
reset your password
|
||||
</Link>{" "}
|
||||
or{" "}
|
||||
<Link to="/signup" className="text-[#009ef7]">
|
||||
create a new account
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
{msgError && (
|
||||
<div className="relative p-4 text-[#912741] bg-[#fcd9e2] border-[#fbc6d3] mb-4 rounded-[0.475rem] text-md font-light leading-[19.5px] text-[13px]">
|
||||
{msgError}
|
||||
</div>
|
||||
)}
|
||||
<div className="signin-area mb-3.5">
|
||||
<div className="flex justify-center">
|
||||
<button
|
||||
@@ -176,9 +203,9 @@ export default function Login() {
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
<BrandBtn link='#' imgSrc={googleLogo} brand='Google' />
|
||||
<BrandBtn link='#' imgSrc={facebookLogo} brand='Facebook' />
|
||||
<BrandBtn link='#' imgSrc={appleLogo} brand='Apple' />
|
||||
<BrandBtn link="#" imgSrc={googleLogo} brand="Google" />
|
||||
<BrandBtn link="#" imgSrc={facebookLogo} brand="Facebook" />
|
||||
<BrandBtn link="#" imgSrc={appleLogo} brand="Apple" />
|
||||
</div>
|
||||
{/* <div className="signup-area flex justify-center">
|
||||
<p className="sm:text-lg text-sm text-thin-light-gray font-normal">
|
||||
@@ -188,7 +215,10 @@ export default function Login() {
|
||||
</a>
|
||||
</p>
|
||||
</div> */}
|
||||
<div className="pt-5 text-[#181c32] text-center font-semibold text-[13.975px] leading-[20.9625px]">This site is protected by hCaptcha and the our Privacy Policy and Terms of Service apply.</div>
|
||||
<div className="pt-5 text-[#181c32] text-center font-semibold text-[13.975px] leading-[20.9625px]">
|
||||
This site is protected by hCaptcha and the our Privacy Policy
|
||||
and Terms of Service apply.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -198,11 +228,7 @@ export default function Login() {
|
||||
);
|
||||
}
|
||||
|
||||
const BrandBtn = ({
|
||||
link,
|
||||
imgSrc,
|
||||
brand
|
||||
}) => {
|
||||
const BrandBtn = ({ link, imgSrc, brand }) => {
|
||||
return (
|
||||
<div className="flex justify-center bottomMargin">
|
||||
<a
|
||||
@@ -215,5 +241,5 @@ const BrandBtn = ({
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
@@ -56,17 +56,13 @@ export default function SignUp() {
|
||||
|
||||
const handleSignUp = async () => {
|
||||
let { country, first_name, last_name, email, password } = formData;
|
||||
|
||||
if (email === "" && password === "" && first_name === "") {
|
||||
setMsgError("Please fill in fields");
|
||||
}
|
||||
|
||||
try {
|
||||
if (
|
||||
email !== "" &&
|
||||
password !== "" &&
|
||||
first_name !== "" &&
|
||||
last_name !== ""
|
||||
last_name !== "" &&
|
||||
country !== ""
|
||||
) {
|
||||
setSignUpLoading(true);
|
||||
const reqData = {
|
||||
@@ -98,6 +94,8 @@ export default function SignUp() {
|
||||
setSignUpLoading(false);
|
||||
setMsgError("An error occurred");
|
||||
}
|
||||
} else {
|
||||
setMsgError("Please fill in fields");
|
||||
}
|
||||
} catch (error) {
|
||||
throw new Error(error);
|
||||
@@ -106,7 +104,7 @@ export default function SignUp() {
|
||||
setMsgError(null);
|
||||
}, process.env.REACT_APP_SIGNUP_ERROR_TIMEOUT);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
getCountryList();
|
||||
@@ -262,7 +260,7 @@ export default function SignUp() {
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleSignUp}
|
||||
className={`rounded-[0.475rem] mb-6 text-white flex justify-center bg-[#4687ba] hover:bg-[#009ef7] transition-all duration-300 items-center h-[42px] py-[0.8875rem] px-[1.81rem] text-[14.95px]`}
|
||||
className={`rounded-[0.475rem] mb-6 text-white flex justify-center bg-[#4687ba] hover:bg-[#009ef7] transition-all duration-300 items-center h-[42px] py-[0.8875rem] px-[1.81rem] text-[14.95px] btn-login`}
|
||||
>
|
||||
{signUpLoading ? (
|
||||
<div className="signup btn-loader"></div>
|
||||
@@ -278,26 +276,35 @@ export default function SignUp() {
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex-1 flex justify-center items-center p-10">
|
||||
<div className="flex items-center">
|
||||
<Link to="#" className="text-[#a1a5b7] text-[15px] px-2 font-medium hover:text-[#009ef7]">
|
||||
About
|
||||
</Link>
|
||||
<Link to="#" className="text-[#a1a5b7] text-[15px] px-2 font-medium hover:text-[#009ef7]">
|
||||
Services
|
||||
</Link>
|
||||
<Link to="#" className="text-[#a1a5b7] text-[15px] px-2 font-medium hover:text-[#009ef7]">
|
||||
Contact Us
|
||||
</Link>
|
||||
<div className="flex items-center">
|
||||
<Link
|
||||
to="#"
|
||||
className="text-[#a1a5b7] text-[15px] px-2 font-medium hover:text-[#009ef7]"
|
||||
>
|
||||
About
|
||||
</Link>
|
||||
<Link
|
||||
to="#"
|
||||
className="text-[#a1a5b7] text-[15px] px-2 font-medium hover:text-[#009ef7]"
|
||||
>
|
||||
Services
|
||||
</Link>
|
||||
<Link
|
||||
to="#"
|
||||
className="text-[#a1a5b7] text-[15px] px-2 font-medium hover:text-[#009ef7]"
|
||||
>
|
||||
Contact Us
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex-1 flex justify-center items-center p-10">
|
||||
<p className="text-black text-[15px] px-2 font-medium flex items-center">
|
||||
<span className="text-3xl mt-2 mr-1">©</span> 2023 -{" "}
|
||||
<Link to="/" className="text-[#009ef7] ml-1">
|
||||
WrenchBoard
|
||||
</Link>{" "}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex-1 flex justify-center items-center p-10">
|
||||
<p className="text-black text-[15px] px-2 font-medium flex items-center">
|
||||
<span className="text-3xl mt-2 mr-1">©</span> 2023 - {" "}
|
||||
<Link to="/" className="text-[#009ef7] ml-1">
|
||||
WrenchBoard
|
||||
</Link>{" "}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -30,10 +30,6 @@ export default function VerifyLink() {
|
||||
|
||||
// if verification is okay. set a complete signup form
|
||||
const completeSignup = async () => {
|
||||
if (email === "" && password === "") {
|
||||
setMsgError("Please fill in fields");
|
||||
}
|
||||
|
||||
try {
|
||||
if (email !== "" && password !== "") {
|
||||
setLinkLoader(true);
|
||||
@@ -45,7 +41,7 @@ export default function VerifyLink() {
|
||||
verify_link: token,
|
||||
action: 11012,
|
||||
};
|
||||
const res = await userApi.CompleteSignUp(postData);
|
||||
const res = await userApi?.CompleteSignUp(postData);
|
||||
|
||||
if (res.status === 200) {
|
||||
const { data } = res;
|
||||
@@ -67,13 +63,15 @@ export default function VerifyLink() {
|
||||
}
|
||||
} else {
|
||||
setLinkLoader(false);
|
||||
setLinkSuccess(false)
|
||||
setLinkSuccess(false);
|
||||
setMsgError("An error occurred");
|
||||
}
|
||||
} else {
|
||||
setMsgError("Please fill in fields");
|
||||
}
|
||||
} catch (error) {
|
||||
setLinkLoader(false);
|
||||
setLinkSuccess(false)
|
||||
setLinkSuccess(false);
|
||||
throw new Error(error);
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
|
||||
@@ -0,0 +1,233 @@
|
||||
import { useState, useEffect, useCallback } from "react";
|
||||
import { useLocation, Link, useNavigate } from "react-router-dom";
|
||||
import AuthLayout from "../AuthLayout";
|
||||
import InputCom from "../../Helpers/Inputs/InputCom";
|
||||
import usersService from "../../../services/UsersService";
|
||||
import WrenchBoard from "../../../assets/images/wrenchboard.png";
|
||||
|
||||
const VerifyPassword = () => {
|
||||
const [password, setPassword] = useState("");
|
||||
const [confirmPassword, setConfirmPassword] = useState("");
|
||||
const [msgError, setMsgError] = useState("");
|
||||
const [linkLoader, setLinkLoader] = useState(false);
|
||||
const [linkSuccess, setLinkSuccess] = useState(true);
|
||||
const [showPassword, setShowPassword] = useState(false);
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const queryParams = new URLSearchParams(location?.search);
|
||||
const token = queryParams.get("passlink");
|
||||
const userApi = new usersService();
|
||||
|
||||
// To Show and Hide Password
|
||||
const togglePasswordVisibility = () => {
|
||||
setShowPassword(!showPassword);
|
||||
};
|
||||
|
||||
// little checker for the validity of the token
|
||||
if (token?.length != 64) {
|
||||
setLinkSuccess(false);
|
||||
}
|
||||
|
||||
// Password
|
||||
const handlePassword = (e) => {
|
||||
let { name, value } = e?.target;
|
||||
if (name == "password") setPassword(value);
|
||||
if (name == "confirm_password") setConfirmPassword(value);
|
||||
};
|
||||
|
||||
const completeReset = async () => {
|
||||
try {
|
||||
if (password !== "" && confirmPassword !== "") {
|
||||
if (password === confirmPassword) {
|
||||
setLinkLoader(true);
|
||||
var reqData = {
|
||||
sessionid: "DUMMY-CANNOT_BE_EMPTY",
|
||||
reset_link: token,
|
||||
newpass: password,
|
||||
step: 300,
|
||||
action: 730,
|
||||
};
|
||||
|
||||
const res = await userApi?.CompleteResetPassword(reqData);
|
||||
|
||||
if (res.status === 200) {
|
||||
const { data } = res;
|
||||
|
||||
if (data?.status > 0 && data?.email) {
|
||||
setTimeout(() => {
|
||||
navigate("/login", { replace: true });
|
||||
setLinkLoader(false);
|
||||
}, 2000);
|
||||
} else if (data && data?.status == "Invalid Request") {
|
||||
setLinkLoader(false);
|
||||
setLinkSuccess(false);
|
||||
} else {
|
||||
setLinkLoader(false);
|
||||
setMsgError("An error occurred");
|
||||
}
|
||||
} else {
|
||||
setLinkLoader(false);
|
||||
setLinkSuccess(false);
|
||||
}
|
||||
} else {
|
||||
setLinkLoader(false);
|
||||
setMsgError("Passwords does not match");
|
||||
}
|
||||
} else {
|
||||
setMsgError("Please fill in fields");
|
||||
}
|
||||
} catch (error) {
|
||||
setLinkLoader(false);
|
||||
setLinkSuccess(false);
|
||||
throw new Error(error);
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
setMsgError(null);
|
||||
}, process.env.REACT_APP_SIGNUP_ERROR_TIMEOUT);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<AuthLayout slogan="Welcome to WrenchBoard">
|
||||
<div className="w-full">
|
||||
<div className="mb-12">
|
||||
<Link to="#">
|
||||
<img
|
||||
src={WrenchBoard}
|
||||
alt="wrenchboard"
|
||||
className="h-10 mx-auto"
|
||||
/>
|
||||
</Link>
|
||||
</div>
|
||||
<div className="content-wrapper login shadow-md w-full lg:max-w-[500px] mx-auto flex justify-center items-center dark:bg-dark-white 2xl:w-[828px] rounded-[0.475rem] sm:p-7 p-5">
|
||||
<div className="w-full">
|
||||
<div className="title-area flex flex-col justify-center items-center relative text-center mb-7">
|
||||
<h1 className="text-[#181c32] font-semibold dark:text-white mb-3 leading-[27.3px] text-[22.75px]">
|
||||
{linkSuccess ? "Password Reset" : "Invalid verification link"}
|
||||
</h1>
|
||||
{linkSuccess && (
|
||||
<span className="text-gray-400 font-medium text-[16.25px] leading-[24.375px]">
|
||||
Enter a new password to reset
|
||||
</span>
|
||||
)}
|
||||
{linkSuccess && (
|
||||
<span className="text-gray-400 font-medium text-[16.25px] leading-[24.375px]">
|
||||
We'll send an email to confirm reset
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
{/* If the verification was a success */}
|
||||
{linkSuccess ? (
|
||||
<SuccessfulComponent
|
||||
password={password}
|
||||
confirmPassword={confirmPassword}
|
||||
handlePassword={handlePassword}
|
||||
onSubmit={completeReset}
|
||||
msgErr={msgError}
|
||||
loader={linkLoader}
|
||||
showPassword={showPassword}
|
||||
onClick={togglePasswordVisibility}
|
||||
navigateHandler={() => navigate("/login")}
|
||||
/>
|
||||
) : (
|
||||
<ErrorComponent onClick={() => navigate("/login")} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</AuthLayout>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default VerifyPassword;
|
||||
|
||||
const SuccessfulComponent = ({
|
||||
onSubmit,
|
||||
navigateHandler,
|
||||
showPassword,
|
||||
onClick,
|
||||
password,
|
||||
confirmPassword,
|
||||
handlePassword,
|
||||
msgErr,
|
||||
loader,
|
||||
}) => (
|
||||
<div className="input-area">
|
||||
{/* INPUT */}
|
||||
<div className="mb-5">
|
||||
<InputCom
|
||||
value={password}
|
||||
inputHandler={handlePassword}
|
||||
placeholder="● ● ● ● ● ●"
|
||||
label="Password"
|
||||
name="password"
|
||||
type={showPassword ? "text" : "password"}
|
||||
onClick={onClick}
|
||||
passIcon={
|
||||
showPassword ? "show-password" : "hide-password"
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<div className="mb-5">
|
||||
<InputCom
|
||||
value={confirmPassword}
|
||||
inputHandler={handlePassword}
|
||||
placeholder="● ● ● ● ● ●"
|
||||
label="Confirm Password"
|
||||
name="confirm_password"
|
||||
type="password"
|
||||
/>
|
||||
</div>
|
||||
{msgErr && (
|
||||
<div className="relative p-4 text-[#912741] bg-[#fcd9e2] border-[#fbc6d3] mb-4 rounded-[0.475rem] text-md font-light leading-[19.5px] text-[13px]">
|
||||
{msgErr}
|
||||
</div>
|
||||
)}
|
||||
<div className="signin-area mb-3.5">
|
||||
<button
|
||||
onClick={onSubmit}
|
||||
type="button"
|
||||
className={`btn-login rounded-[0.475rem] mb-6 text-xl text-white flex justify-center bg-[#4687ba] hover:bg-[#009ef7] transition-all duration-300 items-center text-[15px]`}
|
||||
>
|
||||
{loader ? (
|
||||
<div className="signup btn-loader"></div>
|
||||
) : (
|
||||
<span>Continue</span>
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
<div className="signin-area mb-3.5">
|
||||
<button
|
||||
onClick={navigateHandler}
|
||||
type="button"
|
||||
className={`rounded-[0.475rem] mb-6 text-[15px] font-semibold text-[#009ef7] hover:text-white flex justify-center bg-[#f1faff] hover:bg-[#009ef7] transition-all duration-300 items-center py-[0.8875rem] px-[1.81rem] btn-login`}
|
||||
>
|
||||
<span>Return Home</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
const ErrorComponent = ({ onClick }) => (
|
||||
<div className="input-area">
|
||||
<div className="my-5">
|
||||
<p className="text-[14px] leading-[19px] text-center text-[#181c32]">
|
||||
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.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="signin-area flex justify-center mb-3.5">
|
||||
<button
|
||||
onClick={onClick}
|
||||
type="button"
|
||||
className={`rounded-[0.475rem] mb-6 text-[15px] font-semibold text-[#009ef7] hover:text-white flex justify-center bg-[#f1faff] hover:bg-[#009ef7] transition-all duration-300 items-center py-[0.8875rem] px-[1.81rem]`}
|
||||
>
|
||||
<span>Return Home</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
@@ -1,18 +1,20 @@
|
||||
import { useNavigate, Link } from "react-router-dom";
|
||||
import AuthLayout from "../AuthLayout";
|
||||
import WrenchBoard from "../../../assets/images/wrenchboard.png"
|
||||
import WrenchBoard from "../../../assets/images/wrenchboard.png";
|
||||
|
||||
export default function VerifyYou() {
|
||||
const navigate = useNavigate()
|
||||
const navigate = useNavigate();
|
||||
return (
|
||||
<>
|
||||
<AuthLayout
|
||||
slogan="Welcome to WrenchBoard"
|
||||
>
|
||||
<AuthLayout slogan="Welcome to WrenchBoard">
|
||||
<div className="w-full">
|
||||
<div className='mb-12'>
|
||||
<Link to='#'>
|
||||
<img src={WrenchBoard} alt="wrenchboard" className="h-10 mx-auto" />
|
||||
<div className="mb-12">
|
||||
<Link to="#">
|
||||
<img
|
||||
src={WrenchBoard}
|
||||
alt="wrenchboard"
|
||||
className="h-10 mx-auto"
|
||||
/>
|
||||
</Link>
|
||||
</div>
|
||||
<div className="content-wrapper login shadow-md w-full lg:max-w-[500px] mx-auto flex justify-center items-center dark:bg-dark-white 2xl:w-[828px] rounded-[0.475rem] sm:p-7 p-5">
|
||||
@@ -21,29 +23,38 @@ export default function VerifyYou() {
|
||||
<h1 className="text-[#181c32] font-semibold dark:text-white mb-3 leading-[27.3px] text-[22.75px]">
|
||||
Let's verify your email now
|
||||
</h1>
|
||||
<span className="text-gray-400 font-medium text-[16.25px] leading-[24.375px]">Check your email.</span>
|
||||
<span className="text-gray-400 font-medium text-[16.25px] leading-[24.375px]">
|
||||
Check your email.
|
||||
</span>
|
||||
</div>
|
||||
<div className="input-area">
|
||||
<div className="mb-5">
|
||||
<p className="text-[14px] leading-[19px] text-center text-[#181c32]">
|
||||
<b>Verify Email.</b> Help us secure your WrenchBoard account by verifying your email registration address. Verification will let you access all of WrenchBoard's features.
|
||||
<b>Verify Email.</b> Help us secure your WrenchBoard account
|
||||
by verifying your email registration address. Verification
|
||||
will let you access all of WrenchBoard's features.
|
||||
</p>
|
||||
</div>
|
||||
<div className="mb-5">
|
||||
<p className="text-[14px] leading-[19px] text-center text-[#181c32]">
|
||||
If you do not receive the confirmation message within a few minutes of signing up, please check your Junk E-mail folder just in case the confirmation email got delivered there instead of your inbox. If so, select the confirmation message and click Not Junk, which will allow future messages to get through.
|
||||
If you do not receive the confirmation message within a few
|
||||
minutes of signing up, please check your Junk E-mail folder
|
||||
just in case the confirmation email got delivered there
|
||||
instead of your inbox. If so, select the confirmation
|
||||
message and click Not Junk, which will allow future messages
|
||||
to get through.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="signin-area flex justify-center mb-3.5">
|
||||
<button
|
||||
onClick={() => navigate("/")}
|
||||
type="button"
|
||||
className={`rounded-[0.475rem] mb-6 text-[15px] font-semibold text-[#009ef7] hover:text-white flex justify-center bg-[#f1faff] hover:bg-[#009ef7] transition-all duration-300 items-center py-[0.8875rem] px-[1.81rem]`}
|
||||
>
|
||||
<span>Return Home</span>
|
||||
</button>
|
||||
</div>
|
||||
<div className="signin-area flex justify-center mb-3.5">
|
||||
<button
|
||||
onClick={() => navigate("/")}
|
||||
type="button"
|
||||
className={`rounded-[0.475rem] mb-6 text-[15px] font-semibold text-[#009ef7] hover:text-white flex justify-center bg-[#f1faff] hover:bg-[#009ef7] transition-all duration-300 items-center py-[0.8875rem] px-[1.81rem]`}
|
||||
>
|
||||
<span>Return Home</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from "react";
|
||||
import Lottie from "react-lottie";
|
||||
// import Lottie from "react-lottie";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import * as animationData from "../../assets/images/Lotties/77618-website-404-error-animation.json";
|
||||
|
||||
@@ -16,7 +16,7 @@ export default function FourZeroFour() {
|
||||
return (
|
||||
<div className="flex justify-center items-center w-full h-screen bg-[#232247]">
|
||||
<div>
|
||||
<Lottie options={defaultOptions} width={600} height={600} />
|
||||
{/* <Lottie options={defaultOptions} width={600} height={600} /> */}
|
||||
<div className="flex justify-center">
|
||||
<button
|
||||
onClick={() => navigate(-1)}
|
||||
|
||||
@@ -1,24 +1,39 @@
|
||||
import React, {useState} from 'react'
|
||||
import RecentActivityTable from './WalletComponent/RecentActivityTable'
|
||||
import LoadingSpinner from '../Spinners/LoadingSpinner'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
|
||||
function AddFund({payment}) {
|
||||
|
||||
//STATE FOR CONTROLLED INPUTS
|
||||
let [inputs, setInputs] = useState('0')
|
||||
const navigate = useNavigate()
|
||||
|
||||
//STATE FOR CONTROLLED INPUT
|
||||
let [input, setInput] = useState('0')
|
||||
|
||||
let [inputError, setInputError] = useState('')
|
||||
|
||||
// FUNCTION TO HANDLE INPUT CHANGE
|
||||
const handleChange = ({target:{name, value}}) => {
|
||||
setInputs(value)
|
||||
setInput(value)
|
||||
}
|
||||
|
||||
//FUNCTION TO HANDLE SUBMIT
|
||||
const handleSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
const handleSubmit = () => {
|
||||
setInputError('')
|
||||
if(!input || input == '0'){
|
||||
setInputError('Please Enter Amount')
|
||||
return
|
||||
}
|
||||
|
||||
//valid inputs before submitting. Just for texting remove later
|
||||
if(isNaN(input)){
|
||||
setInputError('Amount must be a Number')
|
||||
return
|
||||
}
|
||||
|
||||
const stateData = {amount: Number(input)}
|
||||
navigate('confirm-add-fund', {state: stateData})
|
||||
|
||||
setInputs('')
|
||||
setInput('')
|
||||
}
|
||||
return (
|
||||
<div className="content-wrapper w-full lg:flex xl:space-x-8 lg:space-x-4 bottomMargin">
|
||||
@@ -30,7 +45,7 @@ function AddFund({payment}) {
|
||||
<div className='md:flex items-center'>
|
||||
<label className='w-full md:w-2/4 text-slate-600 text-lg'>Amount(Naira) <span className='text-red-500'>*</span></label>
|
||||
<input className='w-full md:w-2/4 p-3 text-lg text-right bg-slate-100 rounded-md outline-0 placeholder:text-slate-500 placeholder:text-lg'
|
||||
value={inputs}
|
||||
value={input}
|
||||
name='amount'
|
||||
type="text"
|
||||
placeholder='Amount'
|
||||
@@ -38,6 +53,7 @@ function AddFund({payment}) {
|
||||
onChange={handleChange}
|
||||
/>
|
||||
</div>
|
||||
{inputError && <p className='text-base text-red-500'>{inputError}</p>}
|
||||
</form>
|
||||
<hr />
|
||||
<div className='md:p-8 p-4 add-fund-btn flex justify-end items-center py-4'>
|
||||
|
||||
@@ -108,7 +108,7 @@ function AddRecipient() {
|
||||
}
|
||||
// setRequestStatus({message: 'Recipient Added Successfully!', loading: false, status: true})
|
||||
toast.success("Recipient Added Successfully!");
|
||||
setTimeout(()=>{navigate('../transfer-fund',{replace:true})},1000)
|
||||
setTimeout(()=>{navigate('/my-wallet/transfer-fund',{replace:true})},1000)
|
||||
}).catch((error)=>{
|
||||
setRequestStatus({message: 'Opps! an error occured! Try again later', loading: false, status: false})
|
||||
})
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
import React, {useState, useEffect} from 'react'
|
||||
import RecentActivityTable from './WalletComponent/RecentActivityTable'
|
||||
import LoadingSpinner from '../Spinners/LoadingSpinner'
|
||||
import InputCom from '../Helpers/Inputs/InputCom'
|
||||
import {toast} from 'react-toastify'
|
||||
import { useLocation, useNavigate } from 'react-router-dom'
|
||||
import { useSelector } from 'react-redux'
|
||||
|
||||
import usersService from '../../services/UsersService'
|
||||
|
||||
import { FlutterWaveButton, closePaymentModal } from 'flutterwave-react-v3'
|
||||
|
||||
|
||||
function ConfirmAddFund({payment}) {
|
||||
|
||||
let {userDetails} = useSelector(state => state.userDetails) // TO GET LOGGEDIN USER DETAILS
|
||||
|
||||
let [pageLoading, setPageLoading] = useState(true)
|
||||
|
||||
let [requestStatus, setRequestStatus] = useState({message: '', loading: false, status: false}) // STATE FOR API REQUEST
|
||||
|
||||
const apiURL = new usersService()
|
||||
const navigate = useNavigate()
|
||||
|
||||
let {state} = useLocation()
|
||||
|
||||
|
||||
//FUNCTION TO HANDLE SUBMIT
|
||||
const onSuccessPayment = () => {
|
||||
setRequestStatus({message: '', loading: true, status: false})
|
||||
let reqData = {amount: state?.account, currency: 'NGN'}
|
||||
apiURL.startTopUp(reqData).then((res)=>{
|
||||
if(res.data.internal_return < 0){
|
||||
setRequestStatus({message: 'Could not finish transaction', loading: false, status: false})
|
||||
toast.success('Opps! something went wrong')
|
||||
}
|
||||
// do something
|
||||
setRequestStatus({message: 'Topup successful', loading: false, status: true})
|
||||
toast.success('Account Topup was sucessful')
|
||||
setTimeout(()=>{
|
||||
navigate('/my-wallet', {replace: true})
|
||||
window.location.reload(true)
|
||||
}, 1000)
|
||||
}).catch(err => {
|
||||
// do something
|
||||
setRequestStatus({message: 'Opps! An Error Occured', loading: false, status: false})
|
||||
toast.success('Opps! something went wrong')
|
||||
})
|
||||
}
|
||||
|
||||
const config = {
|
||||
public_key: process.env.REACT_APP_FLUTTERWAVE_APIKEY,
|
||||
tx_ref: Date.now(),
|
||||
amount: state?.amount,
|
||||
currency: 'NGN',
|
||||
payment_options: 'card,mobilemoney,ussd',
|
||||
customer: {
|
||||
email: `${userDetails.email}`,
|
||||
phone_number: userDetails.phone,
|
||||
name: `${userDetails.lastname} ${userDetails.firstname}`
|
||||
},
|
||||
customizations: {
|
||||
title: 'WrenchBoard',
|
||||
description: 'Topup Payment',
|
||||
logo: 'https://st2.depositphotos.com/4403291/7418/v/450/depositphotos_74189661-stock-illustration-online-shop-log.jpg',
|
||||
},
|
||||
};
|
||||
|
||||
const fwConfig = {
|
||||
...config,
|
||||
text: 'Proceed',
|
||||
callback: (response) => {
|
||||
onSuccessPayment()
|
||||
closePaymentModal() // this will close the modal programmatically
|
||||
},
|
||||
onClose: () => {},
|
||||
};
|
||||
|
||||
useEffect(()=>{
|
||||
// what happens if not state redirect user
|
||||
if(!state){
|
||||
navigate('/my-wallet/add-fund',{replace: true})
|
||||
}else{
|
||||
setPageLoading(false)
|
||||
}
|
||||
},[])
|
||||
|
||||
return (
|
||||
<div className="content-wrapper w-full lg:flex xl:space-x-8 lg:space-x-4 bottomMargin">
|
||||
{pageLoading ?
|
||||
<LoadingSpinner size='8' color='sky-blue' />
|
||||
:
|
||||
<div className="lg:w-1/2 w-full mb-10 lg:mb-0">
|
||||
<div className="add-fund w-full bg-white dark:bg-dark-white rounded-2xl shadow">
|
||||
<h2 className='md:p-8 p-4 text-slate-900 dark:text-white text-xl lg:text-2xl font-medium'>Confirm Add Fund To Account</h2>
|
||||
<hr />
|
||||
<div className='px-4 md:px-8 py-4 add-fund-info'>
|
||||
<div className="field w-full mb-3">
|
||||
<InputCom
|
||||
label="Amount (Naira):"
|
||||
type="text"
|
||||
name="amount"
|
||||
value={state.amount || ''}
|
||||
disable={true}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
<div className='md:p-8 p-4 add-fund-btn flex justify-end items-center py-4'>
|
||||
<FlutterWaveButton {...fwConfig} className='text-lg text-white bg-sky-blue px-4 py-2 hover:opacity-90 rounded-md' />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div className="lg:w-1/2 w-full mb-10 lg:mb-0">
|
||||
<div className="wallet w-full md:p-8 p-4 h-full max-h-[600px] bg-white dark:bg-dark-white overflow-y-auto rounded-2xl shadow">
|
||||
<h2 className='text-gray-900 dark:text-white text-xl lg:text-2xl font-medium'>Recent Activity</h2>
|
||||
<p className='text-base text-gray-600 dark:text-white'>Activity Report</p>
|
||||
{payment.loading ?
|
||||
<LoadingSpinner size='16' color='sky-blue' />
|
||||
:
|
||||
<RecentActivityTable payment={payment}/>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ConfirmAddFund
|
||||
@@ -13,10 +13,7 @@ function ConfirmTransfer({payment, wallet}) {
|
||||
const navigate = useNavigate()
|
||||
|
||||
let {state} = useLocation()
|
||||
// what happens if not state redirect user
|
||||
if(!state){
|
||||
navigate('../transfer-fund',{replace: true})
|
||||
}
|
||||
|
||||
|
||||
let [requestStatus, setRequestStatus] = useState({message: '', loading: false, status: false})
|
||||
let [pageLoading, setPageLoading] = useState(true)
|
||||
@@ -37,7 +34,8 @@ function ConfirmTransfer({payment, wallet}) {
|
||||
setRequestStatus({message: 'transfer successful', loading: false, status: true})
|
||||
toast.success('Transfer sucessful')
|
||||
setTimeout(()=>{
|
||||
navigate('/', {replace: true})
|
||||
navigate('/my-wallet', {replace: true})
|
||||
window.location.reload(true)
|
||||
}, 1000)
|
||||
}).catch(error=>{
|
||||
setRequestStatus({message: 'Opps! something went wrong! Try Again', loading: false, status: false})
|
||||
@@ -45,7 +43,12 @@ function ConfirmTransfer({payment, wallet}) {
|
||||
}
|
||||
|
||||
useEffect(()=>{
|
||||
setPageLoading(false)
|
||||
// what happens if not state redirect user
|
||||
if(!state){
|
||||
navigate('/my-wallet/transfer-fund',{replace: true})
|
||||
}else{
|
||||
setPageLoading(false)
|
||||
}
|
||||
},[])
|
||||
return (
|
||||
<div className="content-wrapper w-full lg:flex xl:space-x-8 lg:space-x-4 bottomMargin">
|
||||
|
||||
@@ -9,6 +9,7 @@ import TransferFund from './TransferFund'
|
||||
import AddFund from './AddFund'
|
||||
import AddRecipient from './AddRecipient'
|
||||
import ConfirmTransfer from './ConfirmTransfer'
|
||||
import ConfirmAddFund from './ConfirmAddFund'
|
||||
|
||||
function Wallet() {
|
||||
return (
|
||||
@@ -112,6 +113,7 @@ const WalletRoutes = () => {
|
||||
<Routes>
|
||||
<Route element={<Wallet />}>
|
||||
<Route path='add-fund' element={<AddFund payment={paymentHistory} />} />
|
||||
<Route path='add-fund/confirm-add-fund' element={<ConfirmAddFund payment={paymentHistory} />} />
|
||||
<Route path='transfer-fund' element={<TransferFund payment={paymentHistory} wallet={walletList} />} />
|
||||
<Route index element={<Balance payment={paymentHistory} purchase={purchaseHistory} coupon={couponHistory} wallet={walletList} />} />
|
||||
<Route path='transfer-fund/add-recipient' element={<AddRecipient />} />
|
||||
|
||||
@@ -4,6 +4,7 @@ import InputCom from "../../Helpers/Inputs/InputCom";
|
||||
import {Link, useNavigate} from 'react-router-dom'
|
||||
import usersService from "../../../services/UsersService";
|
||||
import LoadingSpinner from "../../Spinners/LoadingSpinner";
|
||||
import { useSelector } from "react-redux";
|
||||
|
||||
import {toast} from 'react-toastify'
|
||||
|
||||
@@ -34,14 +35,6 @@ const validationSchema = Yup.object().shape({
|
||||
.required('State is required'),
|
||||
})
|
||||
|
||||
const initialValues = {
|
||||
firstname: '',
|
||||
lastname: '',
|
||||
state: '',
|
||||
city: '',
|
||||
email: ''
|
||||
}
|
||||
|
||||
export default function PersonalInfoTab({
|
||||
datas,
|
||||
frstNmeHndlr,
|
||||
@@ -57,13 +50,23 @@ export default function PersonalInfoTab({
|
||||
coverImgChangHandler,
|
||||
}) {
|
||||
|
||||
let {userDetails} = useSelector((state) => state.userDetails)
|
||||
|
||||
const apiCall = new usersService()
|
||||
|
||||
let navigate = useNavigate()
|
||||
|
||||
let [togglePromotion, setTogglePromotion] = useState(false)
|
||||
|
||||
const initialValues = {
|
||||
firstname: userDetails?.firstname,
|
||||
lastname: userDetails?.lastname,
|
||||
state: userDetails?.state,
|
||||
city: userDetails?.city,
|
||||
email: userDetails?.email
|
||||
}
|
||||
|
||||
let [profile, setProfile] = useState({ // state for requesting from load profile API
|
||||
data: [],
|
||||
loading: true,
|
||||
status: false
|
||||
})
|
||||
@@ -74,55 +77,27 @@ export default function PersonalInfoTab({
|
||||
status: false
|
||||
})
|
||||
|
||||
let [inputs, setInputs] = useState({ // State for input fields
|
||||
firstname: '',
|
||||
lastname: '',
|
||||
state: '',
|
||||
city: '',
|
||||
email: ''
|
||||
})
|
||||
|
||||
// const handleChange = ({target:{name, value}}) => {
|
||||
// setInputs(prev => ({...prev, [name]:value}))
|
||||
// }
|
||||
|
||||
const handleUpdateUser = (values, helpers)=> {
|
||||
setRequestState({message: '', loading: true, status: false})
|
||||
|
||||
apiCall.updateProfile(values).then((res)=>{
|
||||
apiCall.updateProfile(values).then((res)=>{ // API CALL TO UPDATE USER DETAILS
|
||||
if(res.data.internal_return < 0){
|
||||
setRequestState({message: 'Profile Was unable to update', loading: false, status: false})
|
||||
return
|
||||
}
|
||||
// setRequestState({message: 'Profile update successfully', loading: false, status: true})
|
||||
toast.success("Update Successful");
|
||||
setTimeout(()=>{navigate('/',{replace:true})},1000)
|
||||
setTimeout(()=>{
|
||||
navigate('/',{replace:true})
|
||||
window.location.reload(true)
|
||||
},1000)
|
||||
}).catch(error => {
|
||||
setRequestState({message: 'Opps! an error occurred. Try Agian', loading: false, status: false})
|
||||
})
|
||||
}
|
||||
|
||||
const loadProfile = ()=>{ // function to load user profile
|
||||
apiCall.loadProfile().then((res)=>{
|
||||
if(res.data.internal_return < 0){
|
||||
setProfile(prev => ({...prev, loading: false, status: true}))
|
||||
return
|
||||
}
|
||||
setProfile(prev => ({...prev, data: [res.data], loading: false, status: true}))
|
||||
setInputs({
|
||||
firstname: res.data.firstname,
|
||||
lastname: res.data.lastname,
|
||||
state: res.data.state,
|
||||
city: res.data.city,
|
||||
email: res.data.email
|
||||
})
|
||||
}).catch(error =>{
|
||||
setProfile(prev => ({...prev, loading: false, status: false}))
|
||||
})
|
||||
}
|
||||
|
||||
useEffect(()=>{
|
||||
loadProfile() // loads user profile unto the page
|
||||
setProfile({loading: false, status: true})
|
||||
},[])
|
||||
|
||||
return (
|
||||
@@ -135,14 +110,12 @@ export default function PersonalInfoTab({
|
||||
</div>
|
||||
:
|
||||
<div className="personal-info-tab w-full flex flex-col justify-between">
|
||||
<Formik initialValues={inputs} validationSchema={validationSchema} onSubmit={handleUpdateUser}>
|
||||
<Formik initialValues={initialValues} validationSchema={validationSchema} onSubmit={handleUpdateUser}>
|
||||
{(props => {
|
||||
return (
|
||||
<Form>
|
||||
{
|
||||
profile.data.length ?
|
||||
profile.data.map((item, index) => (
|
||||
<div key={index} className="flex flex-col-reverse sm:flex-row">
|
||||
|
||||
<div className="flex flex-col-reverse sm:flex-row">
|
||||
<div className="flex-1 sm:mr-10">
|
||||
<div className="fields w-full">
|
||||
{/* inputs starts here */}
|
||||
@@ -153,7 +126,7 @@ export default function PersonalInfoTab({
|
||||
type="text"
|
||||
name="username"
|
||||
placeholder=""
|
||||
value={item.username}
|
||||
value={userDetails.username}
|
||||
disable={true}
|
||||
/>
|
||||
</div>
|
||||
@@ -205,7 +178,7 @@ export default function PersonalInfoTab({
|
||||
label="Country"
|
||||
type="text"
|
||||
name="country"
|
||||
value={item.country}
|
||||
value={userDetails.country}
|
||||
disable={true}
|
||||
/>
|
||||
</div>
|
||||
@@ -324,41 +297,35 @@ export default function PersonalInfoTab({
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
:
|
||||
profile.status ?
|
||||
<div className="py-3 text-slate-500">No User Information Found!</div>
|
||||
:
|
||||
<div className="py-3 text-slate-500">Opps! something went wrong. Try Again Later!</div>
|
||||
}
|
||||
<div className="content-footer w-full">
|
||||
{requestStatus.message != '' && <p className={`text-center text-base ${requestStatus.status ? 'text-green-800' : 'text-red-600'}`}>{requestStatus.message}</p>}
|
||||
<div className="w-full h-[120px] border-t border-light-purple dark:border-[#5356fb29] flex justify-end items-center">
|
||||
<div className="flex items-center space-x-4 mr-9">
|
||||
<Link
|
||||
to='/'
|
||||
className="text-18 text-light-red tracking-wide "
|
||||
>
|
||||
<span className="border-b dark:border-[#5356fb29] border-light-red">
|
||||
{" "}
|
||||
Cancel
|
||||
</span>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
{requestStatus.loading ?
|
||||
<LoadingSpinner size='8' color='sky-blue' />
|
||||
:
|
||||
<button
|
||||
type="submit"
|
||||
className="w-[152px] h-[46px] flex justify-center items-center btn-gradient text-base rounded-full text-white"
|
||||
>
|
||||
Update Profile
|
||||
</button>
|
||||
}
|
||||
<div className="content-footer w-full">
|
||||
{requestStatus.message != '' && <p className={`text-center text-base ${requestStatus.status ? 'text-green-800' : 'text-red-600'}`}>{requestStatus.message}</p>}
|
||||
<div className="w-full h-[120px] border-t border-light-purple dark:border-[#5356fb29] flex justify-end items-center">
|
||||
<div className="flex items-center space-x-4 mr-9">
|
||||
<Link
|
||||
to='/'
|
||||
className="text-18 text-light-red tracking-wide "
|
||||
>
|
||||
<span className="border-b dark:border-[#5356fb29] border-light-red">
|
||||
{" "}
|
||||
Cancel
|
||||
</span>
|
||||
</Link>
|
||||
|
||||
{requestStatus.loading ?
|
||||
<LoadingSpinner size='8' color='sky-blue' />
|
||||
:
|
||||
<button
|
||||
type="submit"
|
||||
className="w-[152px] h-[46px] flex justify-center items-center btn-gradient text-base rounded-full text-white"
|
||||
>
|
||||
Update Profile
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Form>
|
||||
)
|
||||
})}
|
||||
|
||||
@@ -46,13 +46,10 @@ const AuthRoute = ({ redirectPath = "/login", children }) => {
|
||||
setIsLogin({loading: false, status: false})
|
||||
})
|
||||
}
|
||||
const getProfile = useCallback(()=>{
|
||||
loadProfile() // API CALL TO GET USER PROFILE
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if(!isLogin.status){
|
||||
getProfile()
|
||||
loadProfile() // LOADS USER PROFILE DETAILS AND CALLS DISPATCH UPDATEUSERDETAILS TO UPDATE USERDETAILS SLICE IN STORE
|
||||
}
|
||||
|
||||
const checkInactivity = setInterval(() => {
|
||||
|
||||
@@ -279,6 +279,18 @@ class usersService {
|
||||
return this.postAuxEnd("/loadprofile", postData);
|
||||
}
|
||||
|
||||
//END POINT CALL FOR ACCOUNT TOP
|
||||
startTopUp(post){
|
||||
var postData = {
|
||||
uid: localStorage.getItem("uid"),
|
||||
member_id: localStorage.getItem("member_id"),
|
||||
sessionid: localStorage.getItem("session_token"),
|
||||
action: 11062,
|
||||
...post
|
||||
};
|
||||
return this.postAuxEnd("/starttopup", postData);
|
||||
}
|
||||
|
||||
//END POINT CALL FOR SENDING REFERRAL MESSAGE
|
||||
sendReferralMsg(postData){
|
||||
return this.postAuxEnd("/sendreferral", postData);
|
||||
@@ -288,6 +300,10 @@ class usersService {
|
||||
return this.postAuxEnd("/startresetpasword", reqData)
|
||||
}
|
||||
|
||||
CompleteResetPassword(reqData){
|
||||
return this.postAuxEnd("/stepresetpass", reqData)
|
||||
}
|
||||
|
||||
getCouponRedeem(){
|
||||
var postData = {
|
||||
uuid: localStorage.getItem("uid"),
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import React from "react";
|
||||
import VerifyPassword from "../components/AuthPages/VerifyPassword";
|
||||
|
||||
export default function VerifyPasswordPages() {
|
||||
return <VerifyPassword />;
|
||||
}
|
||||
Reference in New Issue
Block a user