Compare commits

..

10 Commits

15 changed files with 443 additions and 191 deletions
+6 -6
View File
@@ -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
View File
@@ -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 */}
+64 -38
View File
@@ -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>
)
}
);
};
+34 -27
View File
@@ -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>
);
+31 -20
View File
@@ -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>
+2 -2
View File
@@ -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 -1
View File
@@ -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})
})
+2 -1
View File
@@ -39,6 +39,7 @@ function ConfirmAddFund({payment}) {
toast.success('Account Topup was sucessful')
setTimeout(()=>{
navigate('/my-wallet', {replace: true})
window.location.reload(true)
}, 1000)
}).catch(err => {
// do something
@@ -78,7 +79,7 @@ function ConfirmAddFund({payment}) {
useEffect(()=>{
// what happens if not state redirect user
if(!state){
navigate('../add-fund',{replace: true})
navigate('/my-wallet/add-fund',{replace: true})
}else{
setPageLoading(false)
}
+3 -2
View File
@@ -34,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})
@@ -44,7 +45,7 @@ function ConfirmTransfer({payment, wallet}) {
useEffect(()=>{
// what happens if not state redirect user
if(!state){
navigate('../transfer-fund',{replace: true})
navigate('/my-wallet/transfer-fund',{replace: true})
}else{
setPageLoading(false)
}
@@ -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>
)
})}
+1 -4
View File
@@ -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(() => {
+4
View File
@@ -300,6 +300,10 @@ class usersService {
return this.postAuxEnd("/startresetpasword", reqData)
}
CompleteResetPassword(reqData){
return this.postAuxEnd("/stepresetpass", reqData)
}
getCouponRedeem(){
var postData = {
uuid: localStorage.getItem("uid"),
+6
View File
@@ -0,0 +1,6 @@
import React from "react";
import VerifyPassword from "../components/AuthPages/VerifyPassword";
export default function VerifyPasswordPages() {
return <VerifyPassword />;
}