Bug Fixes..Notification load, Withdraw css fix

This commit is contained in:
2023-07-22 12:23:14 +01:00
parent 98aef302de
commit f3b1a42819
5 changed files with 653 additions and 480 deletions
+93 -89
View File
@@ -1,5 +1,5 @@
import React, { useEffect, useLayoutEffect, useState } from "react";
import { Link, useNavigate, useLocation } from "react-router-dom";
import { Link, useLocation, useNavigate } from "react-router-dom";
import linkedInLogo from "../../../assets/images/Linkedin.png";
import appleLogo from "../../../assets/images/apple-black.svg";
import facebookLogo from "../../../assets/images/facebook-4.svg";
@@ -9,18 +9,17 @@ import usersService from "../../../services/UsersService";
import InputCom from "../../Helpers/Inputs/InputCom";
import AuthLayout from "../AuthLayout";
// import { GoogleOAuthProvider } from '@react-oauth/google';
import { googleLogout, useGoogleLogin } from "@react-oauth/google";
import { useGoogleLogin } from "@react-oauth/google";
import { useDispatch } from "react-redux";
import { updateUserDetails } from "../../../store/UserDetails";
export default function Login() {
const dispatch = useDispatch();
const {state} = useLocation()
const { state } = useLocation();
let [loginType, setLoginType] = useState('');
let [loginType, setLoginType] = useState("");
const [checked, setValue] = useState(false);
const [loginLoading, setLoginLoading] = useState(false);
const [showPassword, setShowPassword] = useState(false);
@@ -30,12 +29,8 @@ export default function Login() {
// for the catch error
const [msgError, setMsgError] = useState("");
const rememberMe = () => {
setValue(!checked);
};
// To Show and Hide Password
const togglePasswordVisibility = () => {
// To Show and Hide Password
const togglePasswordVisibility = () => {
setShowPassword(!showPassword);
};
@@ -43,7 +38,7 @@ export default function Login() {
const handleLoginType = ({ target: { name } }) => {
setLoginType(name);
let currentDate = new Date();
let expirationDate = new Date(currentDate.getTime() + (24 * 60 * 60 * 1000));
let expirationDate = new Date(currentDate.getTime() + 24 * 60 * 60 * 1000);
// Convert the expiration date to the appropriate format
let expirationDateString = expirationDate.toUTCString();
document.cookie = `loginType=${name}; expires=${expirationDateString}; path=/;`;
@@ -83,7 +78,9 @@ export default function Login() {
if (regEx.test(email) == false) {
setLoginLoading(false);
setMsgError("Invalid Email");
return setTimeout(()=>{setMsgError("");},3000)
return setTimeout(() => {
setMsgError("");
}, 3000);
}
// Post Data Info for normal Login
postData = {
@@ -113,7 +110,13 @@ export default function Login() {
userApi
.logInUser(postData)
.then((res) => {
if (res.status != 200 || res.data.internal_return < 0 || !res.data.member_id || !res.data.uid || !res.data.session) {
if (
res.status != 200 ||
res.data.internal_return < 0 ||
!res.data.member_id ||
!res.data.uid ||
!res.data.session
) {
// setMsgError("Wrong, email/password");
setLoginError(true);
setLoginLoading(false);
@@ -123,7 +126,7 @@ export default function Login() {
localStorage.setItem("uid", `${res.data.uid}`);
localStorage.setItem("session_token", `${res.data.session}`);
// localStorage.setItem("session", `${res.data.session}`);
dispatch(updateUserDetails({...res.data}));
dispatch(updateUserDetails({ ...res.data }));
setTimeout(() => {
navigate("/", { replace: true });
setLoginLoading(false);
@@ -154,11 +157,12 @@ export default function Login() {
// In order to update the selected login type whenever the component renders
// useEffect(() => {
// Clear the loginType cookie if the user switches to loginfull
// document.cookie ="loginType=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
// Clear the loginType cookie if the user switches to loginfull
// document.cookie ="loginType=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
// }, []);
useLayoutEffect(()=>{ // checks the cookie in order to set the login type before components mounts
useLayoutEffect(() => {
// checks the cookie in order to set the login type before components mounts
// if(document.cookie.includes("loginType=family")){
// setLoginType('family')
// }else if(document.cookie.includes("loginType=full")){
@@ -166,33 +170,34 @@ export default function Login() {
// }else{
// setLoginType('full')
// }
function readCookie(cname) { // checks the cookie in order to set the login type before components mounts
function readCookie(cname) {
// checks the cookie in order to set the login type before components mounts
let name = cname + "=";
let decoded_cookie = decodeURIComponent(document.cookie);
let carr = decoded_cookie.split(';');
for(let i=0; i<carr.length;i++){
let carr = decoded_cookie.split(";");
for (let i = 0; i < carr.length; i++) {
let c = carr[i];
while(c.charAt(0)==' '){
c=c.substring(1);
while (c.charAt(0) == " ") {
c = c.substring(1);
}
if(c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return 'full'
return "full";
}
let loginValue = readCookie('loginType')
setLoginType(loginValue)
let loginValue = readCookie("loginType");
setLoginType(loginValue);
if(state?.error){ //check if the login path has an error state indicating any social handle login with error
if (state?.error) {
//check if the login path has an error state indicating any social handle login with error
setMsgError("Unexpected Error, Please try again soon.");
setTimeout(()=>{
setTimeout(() => {
setMsgError("");
navigate('/login', {replace: true})
},4000)
navigate("/login", { replace: true });
}, 4000);
}
},[])
}, []);
useEffect(() => {
setMail("");
@@ -234,7 +239,9 @@ export default function Login() {
<button
name="full"
className={`login-type-btn px-4 py-1 rounded-t-2xl ${
loginType=='full' ? "bg-[#4687ba] border-[2px] border-[#4687ba] text-white" : "bg-white text-[#000] border-t-[2px]"
loginType == "full"
? "bg-[#4687ba] border-[2px] border-[#4687ba] text-white"
: "bg-white text-[#000] border-t-[2px]"
}`}
onClick={handleLoginType}
>
@@ -243,7 +250,9 @@ export default function Login() {
<button
name="family"
className={`login-type-btn px-4 py-1 rounded-t-2xl ${
loginType=='family' ? "bg-[#4687ba] border-[2px] border-[#4687ba] text-white" : "bg-white text-[#000] border-t-[2px]"
loginType == "family"
? "bg-[#4687ba] border-[2px] border-[#4687ba] text-white"
: "bg-white text-[#000] border-t-[2px]"
}`}
onClick={handleLoginType}
>
@@ -255,7 +264,7 @@ export default function Login() {
{/* for login component */}
{
loginType == 'full' ? (
loginType == "full" ? (
//user login component
<div className="p-6 input-area login-area border-2 border-[#4687ba] rounded-2xl">
<div className="input-item mb-5">
@@ -321,33 +330,33 @@ export default function Login() {
</button>
</div>
<div className="sm:flex sm:justify-between sm:items-center sm:space-x-2">
<BrandBtn
link="#"
imgSrc={googleLogo}
brand="Google"
onClick={googleLogin}
/>
<BrandBtn
// link={`https://appleid.apple.com/auth/authorize?response_type=code&response_mode=form_post&client_id=${process.env.REACT_APP_APPLE_CLIENT_ID}&redirect_uri=https%3A%2F%2Fwork.wrenchboard.com%2Flogin%2Fauth%2Fapple&state=4b2c4456b7&scope=name+email`}
link={`https://appleid.apple.com/auth/authorize?response_type=code&response_mode=form_post&client_id=${process.env.REACT_APP_APPLE_CLIENT_ID}&redirect_uri=${process.env.REACT_APP_APPLE_REDIRECT_URL}&state=4b2c4456b7&scope=name+email`}
imgSrc={appleLogo}
brand="Apple"
isAnchor={true}
/>
<BrandBtn
link="#"
imgSrc={googleLogo}
brand="Google"
onClick={googleLogin}
/>
<BrandBtn
// link={`https://appleid.apple.com/auth/authorize?response_type=code&response_mode=form_post&client_id=${process.env.REACT_APP_APPLE_CLIENT_ID}&redirect_uri=https%3A%2F%2Fwork.wrenchboard.com%2Flogin%2Fauth%2Fapple&state=4b2c4456b7&scope=name+email`}
link={`https://appleid.apple.com/auth/authorize?response_type=code&response_mode=form_post&client_id=${process.env.REACT_APP_APPLE_CLIENT_ID}&redirect_uri=${process.env.REACT_APP_APPLE_REDIRECT_URL}&state=4b2c4456b7&scope=name+email`}
imgSrc={appleLogo}
brand="Apple"
isAnchor={true}
/>
</div>
<div className="sm:flex sm:justify-between sm:items-center sm:space-x-2">
<BrandBtn
link={`https://www.facebook.com/v14.0/dialog/oauth?client_id=${process.env.REACT_APP_FACEBOOK_CLIENT_ID}&redirect_uri=${process.env.REACT_APP_FACEBOOK_REDIRECT_URL}&scope=${process.env.REACT_APP_FACEBOOK_CLIENT_SCOPE}`}
imgSrc={facebookLogo}
brand="Facebook"
isAnchor={true}
/>
<BrandBtn
// link="https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id=YOUR_CLIENT_ID&redirect_uri=YOUR_REDIRECT_URI&scope=comma-separated-list-of-scopes&state=YOUR_STATE_VALUE"
imgSrc={linkedInLogo}
brand="LinkedIn"
isAnchor={true}
/>
<BrandBtn
link={`https://www.facebook.com/v14.0/dialog/oauth?client_id=${process.env.REACT_APP_FACEBOOK_CLIENT_ID}&redirect_uri=${process.env.REACT_APP_FACEBOOK_REDIRECT_URL}&scope=${process.env.REACT_APP_FACEBOOK_CLIENT_SCOPE}`}
imgSrc={facebookLogo}
brand="Facebook"
isAnchor={true}
/>
<BrandBtn
// link="https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id=YOUR_CLIENT_ID&redirect_uri=YOUR_REDIRECT_URI&scope=comma-separated-list-of-scopes&state=YOUR_STATE_VALUE"
imgSrc={linkedInLogo}
brand="LinkedIn"
isAnchor={true}
/>
</div>
</div>
</div>
@@ -435,7 +444,7 @@ export default function Login() {
);
}
const BrandBtn = ({ link, imgSrc, brand, onClick, isAnchor=false }) => {
const BrandBtn = ({ link, imgSrc, brand, onClick, isAnchor = false }) => {
// const doGoogle = async () => {
// alert("start google");
// };
@@ -456,33 +465,28 @@ const BrandBtn = ({ link, imgSrc, brand, onClick, isAnchor=false }) => {
// };
return (
<div className="w-full sm:w-1/2 flex justify-center bottomMargin">
{isAnchor ?
(
{isAnchor ? (
<a
href={link}
className="w-full border border-light-purple dark:border-[#5356fb29] rounded-[0.475rem] h-[48px] flex justify-center bg-[#FAFAFA] hover:bg-[#eff2f5] hover:text-[#7e8299] transition duration-300 dark:bg-[#11131F] items-center font-medium cursor-pointer"
>
<img className="mr-3 h-6" src={imgSrc} alt="logo-icon(s)" />
<span className="text-lg text-thin-light-gray font-normal text-[15px]">
Continue with {brand}
</span>
</a>
)
:
(
href={link}
className="w-full border border-light-purple dark:border-[#5356fb29] rounded-[0.475rem] h-[48px] flex justify-center bg-[#FAFAFA] hover:bg-[#eff2f5] hover:text-[#7e8299] transition duration-300 dark:bg-[#11131F] items-center font-medium cursor-pointer"
>
<img className="mr-3 h-6" src={imgSrc} alt="logo-icon(s)" />
<span className="text-lg text-thin-light-gray font-normal text-[15px]">
Continue with {brand}
</span>
</a>
) : (
<button
onClick={onClick}
// href="#dd"
className="w-full border border-light-purple dark:border-[#5356fb29] rounded-[0.475rem] h-[48px] flex justify-center bg-[#FAFAFA] hover:bg-[#eff2f5] hover:text-[#7e8299] transition duration-300 dark:bg-[#11131F] items-center font-medium cursor-pointer"
>
<img className="mr-3 h-6" src={imgSrc} alt="logo-icon(s)" />
<span className="text-lg text-thin-light-gray font-normal text-[15px]">
Continue with {brand}
</span>
</button>
)
}
onClick={onClick}
// href="#dd"
className="w-full border border-light-purple dark:border-[#5356fb29] rounded-[0.475rem] h-[48px] flex justify-center bg-[#FAFAFA] hover:bg-[#eff2f5] hover:text-[#7e8299] transition duration-300 dark:bg-[#11131F] items-center font-medium cursor-pointer"
>
<img className="mr-3 h-6" src={imgSrc} alt="logo-icon(s)" />
<span className="text-lg text-thin-light-gray font-normal text-[15px]">
Continue with {brand}
</span>
</button>
)}
</div>
)
);
};
+229 -148
View File
@@ -1,5 +1,6 @@
import { Form, Formik } from "formik";
import React, { useEffect, useState } from "react";
import { useSelector } from "react-redux";
import { useNavigate } from "react-router-dom";
import * as Yup from "yup";
import usersService from "../../../services/UsersService";
@@ -9,64 +10,55 @@ import LoadingSpinner from "../../Spinners/LoadingSpinner";
const validationSchema = Yup.object().shape({
amount: Yup.number()
.typeError("you must specify a number")
.typeError("You must specify a number")
.min(1, "Amount must be greater than 0")
.required("Amount is required"),
comment: Yup.string().max(50, "Maximum 50 characters"),
choice: Yup.string().required("Please select an option"),
recipientID: Yup.string().when("choice", {
is: "previous",
then: Yup.string().required("Recipient is required"),
choice: Yup.string(),
previousAccount: Yup.object().shape({
recipientID: Yup.string().when("choice", {
is: "previous",
then: Yup.string().required("Recipient is required"),
}),
}),
country: Yup.string().when("choice", {
is: "new",
then: Yup.string().required("Country is required"),
}),
bank: Yup.string().when("choice", {
is: "new",
then: Yup.string().required("Bank name is required"),
}),
accountNumber: Yup.string().when("choice", {
is: "new",
then: Yup.string()
.matches(/\d/, "must be a number")
.min(3, "Minimum 3 characters")
.max(25, "Maximum 25 characters")
.required("Account Number is required"),
}),
accountType: Yup.string().when("choice", {
is: "new",
then: Yup.string().required("Please select an account type"),
}),
city: Yup.string().when("choice", {
is: "new",
then: Yup.string()
.min(3, "Minimum 3 characters")
.max(25, "Maximum 25 characters")
.required("City is required"),
}),
state: Yup.string().when("choice", {
is: "new",
then: Yup.string()
.min(3, "Minimum 3 characters")
.max(25, "Maximum 25 characters")
.required("State is required"),
newAccount: Yup.object().shape({
country: Yup.string().when("choice", {
is: "new",
then: Yup.string().required("Country is required"),
}),
bank: Yup.string().when("choice", {
is: "new",
then: Yup.string().required("Bank name is required"),
}),
accountNumber: Yup.string().when("choice", {
is: "new",
then: Yup.string()
.matches(/\d/, "Must be a number")
.min(3, "Minimum 3 characters")
.max(25, "Maximum 25 characters")
.required("Account Number is required"),
}),
accountType: Yup.string().when("choice", {
is: "new",
then: Yup.string().required("Please select an account type"),
}),
city: Yup.string().when("choice", {
is: "new",
then: Yup.string()
.min(3, "Minimum 3 characters")
.max(25, "Maximum 25 characters")
.required("City is required"),
}),
state: Yup.string().when("choice", {
is: "new",
then: Yup.string()
.min(3, "Minimum 3 characters")
.max(25, "Maximum 25 characters")
.required("State is required"),
}),
}),
});
const initialValues = {
amount: "",
comment: "",
choice: "",
recipientID: "",
country: "",
bank: "",
accountNumber: "",
accountType: "",
state: "",
city: "",
};
function NairaWithdraw({
wallet,
action,
@@ -77,7 +69,25 @@ function NairaWithdraw({
const navigate = useNavigate();
const [tab, setTab] = useState("previous");
let [requestStatus, setRequestStatus] = useState(false);
const [bankNameHandler, setBankNameHandler] = useState({});
const initialValues = {
amount: "",
comment: "",
choice: tab === "previous" ? "previous" : "new" ,
previousAccount: {
recipientID: "",
},
newAccount: {
country: "",
bank: "",
accountNumber: "",
accountType: "",
state: "",
city: "",
},
};
let [sendMoneyFee, setSendMoneyFee] = useState({
loading: false,
fee: 0,
@@ -98,7 +108,7 @@ function NairaWithdraw({
});
let [bankName, setBankName] = useState({
// STATE TO HOLD LIST OF BANK NAME
loading: true,
loading: false,
data: [],
});
let [accType, setAccType] = useState({
@@ -108,13 +118,21 @@ function NairaWithdraw({
});
// Handling card change
const handleInputChange = (event) => {
const handleBankOptions = (event) => {
const { name, value } = event.target;
if (tab === "new") setBankNameHandler((prevState) => ({
...prevState,
[name]: value,
}));
setBankName((prev) => ({ loading: true, data: [] }));
apiCall
.getCountryBank({ country: value })
.then((res) => {
if (res.data.internal_return < 0) {
setBankName((prev) => ({ loading: false, data: [] }));
return;
}
setBankName((prev) => ({ loading: false, data: res.data.result_list }));
})
.catch((error) => {
setBankName((prev) => ({ loading: false, data: [] }));
});
};
//FUNCTION TO GET RECIPIENT LIST
@@ -157,22 +175,6 @@ function NairaWithdraw({
});
};
// FUNCTION TO GET COUNTRY BANK
const getCountryBank = () => {
apiCall
.getCountryBank(bankNameHandler)
.then((res) => {
if (res.data.internal_return < 0) {
setBankName((prev) => ({ loading: false, data: [] }));
return;
}
setBankName((prev) => ({ loading: false, data: res.data.result_list }));
})
.catch((error) => {
setBankName((prev) => ({ loading: false, data: [] }));
});
};
// FUNCTION TO GET ACCOUNT TYPES
const getAccountTypes = () => {
apiCall
@@ -191,7 +193,6 @@ function NairaWithdraw({
useEffect(() => {
getCountry(); // TO LOAD LIST COUNTRY
getCountryBank(); // TO LOAD LIST COUNTRY BANK
getAccountTypes(); // TO LOAD LIST ACCOUNT TYPES
}, []);
@@ -216,32 +217,66 @@ function NairaWithdraw({
setSendMoneyFee({ loading: false, fee: 0, total: 0 });
});
};
console.log("TESTING", sendMoneyFee);
//FUNCTION TO HANDLE SUBMIT
const handleSubmit = (values, helpers) => {
if (!values?.amount && !values.recipientID) return;
setRequestStatus(true);
let recipientDetails = recipients.data?.filter(
(item) => item.recipient_id == values.recipientID
);
let stateData = {
...values,
...sendMoneyFee,
details: { ...recipientDetails[0] },
};
setTimeout(() => {
setRequestStatus(false);
// navigate("confirm-withdraw-naira", { state: stateData });
action();
setShowConfirmNairaWithdraw({ show: true, state: stateData });
}, 1000);
//FUNCTION TO HANDLE SUBMIT
const handleSubmit = async (values, helpers) => {
try {
// Validate the form using Yup validation schema
await validationSchema.validate(values, { abortEarly: false });
// If validation passes, proceed with form submission
// throw new Response("Form data is valid!", values);
// ... Your form submission logic here ...
if (values?.choice === "previous") {
if (!values?.amount && !values?.previousAccount?.recipientID) return;
setRequestStatus(true);
// Ensure recipientDetails is an array and not undefined
const recipientDetails = recipients.data?.filter(
(item) => item.recipient_id === values.previousAccount?.recipientID
);
// Ensure recipientDetails is not empty
if (!recipientDetails || recipientDetails.length === 0) {
// Handle the case when recipientDetails is empty or undefined
setRequestStatus(false);
return;
}
const stateData = {
amount: values.amount,
comment: values.comment,
...values.previousAccount,
...sendMoneyFee,
details: { ...recipientDetails[0] },
};
setTimeout(() => {
setRequestStatus(false);
// navigate("confirm-withdraw-naira", { state: stateData });
action();
setShowConfirmNairaWithdraw({ show: true, state: stateData });
}, 1000);
}
if(values?.choice === "new"){
}
} catch (errors) {
// If validation fails, handle the validation errors
console.log("Validation errors:", errors);
//
}
};
useEffect(() => {
getRecipients();
}, []);
console.log(tab)
return (
<ModalCom action={action} situation={situation} className="edit-popup">
<div className="content-wrapper w-[90%] md:w-[768px]">
@@ -249,17 +284,44 @@ function NairaWithdraw({
<div className="add-fund w-full md:p-8 p-4 bg-white dark:bg-dark-white rounded-2xl shadow h-full">
<Formik
initialValues={initialValues}
validationSchema={validationSchema}
// validationSchema={validationSchema}
onSubmit={handleSubmit}
>
{(props) => {
return (
<Form className="transfer-fund-info">
<h2 className="py-2 text-slate-900 dark:text-white text-xl lg:text-2xl font-medium">
{`Withdraw from ${wallet.description} Wallet : ${
wallet.symbol
}${(wallet.amount * 0.01).toFixed(2)}`}
</h2>
<div className="flex w-full justify-between items-center">
<h2 className="py-2 text-slate-900 dark:text-white text-xl lg:text-2xl font-medium">
{`Withdraw from ${wallet.description} Wallet : ${
wallet.symbol
}${(wallet.amount * 0.01).toFixed(2)}`}
</h2>
<button
type="button"
className="text-[#374557] dark:text-red-500"
onClick={action}
>
<svg
width="36"
height="36"
viewBox="0 0 36 36"
fill="none"
className="fill-current"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M36 16.16C36 17.4399 36 18.7199 36 20.0001C35.7911 20.0709 35.8636 20.2554 35.8385 20.4001C34.5321 27.9453 30.246 32.9248 22.9603 35.2822C21.9006 35.6251 20.7753 35.7657 19.6802 35.9997C18.4003 35.9997 17.1204 35.9997 15.8401 35.9997C15.5896 35.7086 15.2189 35.7732 14.9034 35.7093C7.77231 34.2621 3.08728 30.0725 0.769671 23.187C0.435002 22.1926 0.445997 21.1199 0 20.1599C0 18.7198 0 17.2798 0 15.8398C0.291376 15.6195 0.214408 15.2656 0.270759 14.9808C1.71321 7.69774 6.02611 2.99691 13.0428 0.700951C14.0118 0.383805 15.0509 0.386897 15.9999 0C17.2265 0 18.4532 0 19.6799 0C19.7156 0.124041 19.8125 0.136067 19.9225 0.146719C27.3 0.868973 33.5322 6.21922 35.3801 13.427C35.6121 14.3313 35.7945 15.2484 36 16.16ZM33.011 18.0787C33.0433 9.77105 26.3423 3.00309 18.077 2.9945C9.78479 2.98626 3.00344 9.658 2.98523 17.8426C2.96667 26.1633 9.58859 32.9601 17.7602 33.0079C26.197 33.0577 32.9787 26.4186 33.011 18.0787Z"
fill=""
fillOpacity="0.6"
/>
<path
d="M15.9309 18.023C13.9329 16.037 12.007 14.1207 10.0787 12.2072C9.60071 11.733 9.26398 11.2162 9.51996 10.506C9.945 9.32677 11.1954 9.0811 12.1437 10.0174C13.9067 11.7585 15.6766 13.494 17.385 15.2879C17.9108 15.8401 18.1633 15.7487 18.6375 15.258C20.3586 13.4761 22.1199 11.7327 23.8822 9.99096C24.8175 9.06632 26.1095 9.33639 26.4967 10.517C26.7286 11.2241 26.3919 11.7413 25.9133 12.2178C24.1757 13.9472 22.4477 15.6855 20.7104 17.4148C20.5228 17.6018 20.2964 17.7495 20.0466 17.9485C22.0831 19.974 24.0372 21.8992 25.9689 23.8468C26.9262 24.8119 26.6489 26.1101 25.4336 26.4987C24.712 26.7292 24.2131 26.3441 23.7455 25.8757C21.9945 24.1227 20.2232 22.3892 18.5045 20.6049C18.0698 20.1534 17.8716 20.2269 17.4802 20.6282C15.732 22.4215 13.9493 24.1807 12.1777 25.951C11.7022 26.4262 11.193 26.7471 10.4738 26.4537C9.31345 25.9798 9.06881 24.8398 9.98589 23.8952C11.285 22.5576 12.6138 21.2484 13.9387 19.9355C14.5792 19.3005 15.2399 18.6852 15.9309 18.023Z"
fill="#"
fillOpacity="0.6"
/>
</svg>
</button>
</div>
{/* Amount Form */}
<div className="flex flex-col">
<div className="field w-full">
@@ -278,8 +340,6 @@ function NairaWithdraw({
blurHandler={(e) => {
getSendMoneyFee(e);
}}
// props.handleBlur
// onMouseLeave={(e)=>{getSendMoneyFee(e)}}
/>
{props.errors.amount && props.touched.amount && (
<p className="sm:text-sm text-[12px] text-red-500 sm:text-left text-right sm:translate-y-0 translate-y-1">
@@ -358,6 +418,7 @@ function NairaWithdraw({
type="radio"
id="previous"
name="choice"
value="previous"
checked={tab === "previous"}
className={`p-2 text-lg font-bold text-slate-600 dark:text-white border pointer-events-none w-7 h-7 ${
tab == "previous" ? "" : ""
@@ -374,6 +435,7 @@ function NairaWithdraw({
id="new"
type="radio"
name="choice"
value="new"
checked={tab === "new"}
className={`p-2 text-lg font-bold text-slate-600 dark:text-white border pointer-events-none w-7 h-7 ${
tab == "new" ? "" : ""
@@ -394,8 +456,10 @@ function NairaWithdraw({
<div className="flex flex-col gap-3 flex-[0.8] items-center">
<select
className="sm:w-full w-48 text-base p-2 text-dark-gray dark:text-white rounded-md border border-slate-300 outline-0 flex-[0.8]"
value={props.values.recipientID}
name="recipientID"
value={
props.values.previousAccount.recipientID
}
name="previousAccount.recipientID"
onChange={props.handleChange}
onBlur={props.handleBlur}
>
@@ -441,10 +505,15 @@ function NairaWithdraw({
)}
</select>
<div className="flex justify-end relative w-full">
{props.errors.recipientID &&
props.touched.recipientID && (
{props.errors.previousAccount
?.recipientID &&
props.touched.previousAccount
?.recipientID && (
<p className="sm:text-sm text-[12px] text-red-500 absolute sm:top-1 -top-20 sm:left-0 left-[160px]">
{props.errors.recipientID}
{
props.errors.previousAccount
?.recipientID
}
</p>
)}
{/* <Link
@@ -468,18 +537,20 @@ function NairaWithdraw({
<div className="flex flex-[2] min-h-[52px]">
{/* country */}
<div className="add-recipient w-full flex items-center flex-1 xl:mb-0">
<label className="input-label text-[#181c32] dark:text-white text-base font-semibold inline-flex flex-[0.3]">
<label
htmlFor="newAccount.country"
className="input-label text-[#181c32] dark:text-white text-base font-semibold inline-flex flex-[0.3]"
>
Country{" "}
<span className="text-red-500">*</span>
</label>
<select
className="w-full text-base p-2 text-dark-gray dark:text-white border border-slate-300 outline-0 flex-[0.6] rounded-full h-[42px] overflow-hidden relative font-medium leading-6 bg-clip-padding"
name="country"
value={props.values.country}
name="newAccount.country"
value={props.values.newAccount?.country}
onChange={
props.handleChange || handleInputChange
props.handleChange || handleBankOptions
}
onBlur={props.handleBlur}
>
{allCountries.loading ? (
<option
@@ -488,7 +559,7 @@ function NairaWithdraw({
>
Loading...
</option>
) : allCountries.data.length ? (
) : allCountries.data?.length ? (
<>
<option
className="text-slate-500 text-lg"
@@ -525,14 +596,17 @@ function NairaWithdraw({
{/* bank name */}
<div className="add-recipient w-full flex items-center flex-1">
<label className="input-label text-[#181c32] dark:text-white text-base font-semibold inline-flex flex-[0.4]">
<label
htmlFor="newAccount.bank"
className="input-label text-[#181c32] dark:text-white text-base font-semibold inline-flex flex-[0.4]"
>
Bank Name{" "}
<span className="text-red-500">*</span>
</label>
<select
className="w-full text-base p-2 text-dark-gray dark:text-white border border-slate-300 outline-0 flex-[0.6] rounded-full h-[42px] overflow-hidden relative font-medium leading-6 bg-clip-padding "
name="bank"
value={props.values.bank}
name="newAccount.bank"
value={props.values.newAccount?.bank}
onChange={props.handleChange}
onBlur={props.handleBlur}
>
@@ -543,7 +617,7 @@ function NairaWithdraw({
>
Loading...
</option>
) : bankName.data.length ? (
) : bankName.data?.length ? (
<>
<option
className="text-slate-500 text-lg"
@@ -551,7 +625,7 @@ function NairaWithdraw({
>
Select...
</option>
{bankName.data.map((item, index) => (
{bankName.data?.map((item, index) => (
<option
key={index}
className="text-slate-500 text-lg"
@@ -581,7 +655,10 @@ function NairaWithdraw({
<div className="flex flex-[2] gap-4">
{/* ACCOUNT NUMBER */}
<div className="field w-full flex-[1.4] flex items-center gap-2">
<label className="input-label text-[#181c32] dark:text-white text-base font-semibold inline-flex items-center flex-1">
<label
htmlFor="newAccount.accountNumber"
className="input-label text-[#181c32] dark:text-white text-base font-semibold inline-flex items-center flex-1"
>
Account Number{" "}
<span className="text-red-500">*</span>
</label>
@@ -589,9 +666,9 @@ function NairaWithdraw({
fieldClass="px-6"
inputClass="flex items-center max-w-[15rem]"
type="text"
name="accountNumber"
name="newAccount.accountNumber"
placeholder="Account No"
value={props.values.accountNumber}
value={props.values.newAccount?.accountNumber}
inputHandler={props.handleChange}
blurHandler={props.handleBlur}
/>
@@ -605,13 +682,16 @@ function NairaWithdraw({
{/* Account Type */}
<div className="add-recipient w-full flex flex-1 items-center">
<label className="input-label text-[#181c32] dark:text-white text-base font-semibold inline-flex flex-[0.3]">
<label
htmlFor="newAccount.accountType"
className="input-label text-[#181c32] dark:text-white text-base font-semibold inline-flex flex-[0.3]"
>
Type <span className="text-red-500">*</span>
</label>
<select
className="w-full text-base p-2 text-dark-gray dark:text-white border border-slate-300 outline-0 flex-[0.6] rounded-full h-[42px] overflow-hidden relative font-medium leading-6 bg-clip-padding flex-grow"
name="accountType"
value={props.values.accountType}
name="newAccount.accountType"
value={props.values.newAccount?.accountType}
onChange={props.handleChange}
onBlur={props.handleBlur}
>
@@ -622,7 +702,7 @@ function NairaWithdraw({
>
Loading...
</option>
) : accType.data.length ? (
) : accType.data?.length ? (
<>
<option
className="text-slate-500 text-lg"
@@ -630,7 +710,7 @@ function NairaWithdraw({
>
Select...
</option>
{accType.data.map((item, index) => (
{accType.data?.map((item, index) => (
<option
key={index}
className="text-slate-500 text-lg"
@@ -662,7 +742,7 @@ function NairaWithdraw({
{/* state */}
<div className="field w-full flex items-center gap-4 flex-[0.4]">
<label
htmlFor="state"
htmlFor="newAccount.state"
className="input-label text-[#181c32] dark:text-white text-base font-semibold inline-flex flex-[0.4]"
>
State <span className="text-red-500">*</span>
@@ -671,9 +751,9 @@ function NairaWithdraw({
fieldClass="px-6"
inputClass="max-w-[10rem]"
type="text"
name="state"
name="newAccount.state"
placeholder="State/Province"
value={props.values.state}
value={props.values.newAccount?.state}
inputHandler={props.handleChange}
blurHandler={props.handleBlur}
/>
@@ -687,7 +767,7 @@ function NairaWithdraw({
{/* city */}
<div className="field w-full flex items-center flex-[0.4]">
<label
htmlFor="city"
htmlFor="newAccount.city"
className="input-label text-[#181c32] dark:text-white text-base font-semibold inline-flex flex-[0.4]"
>
City <span className="text-red-500">*</span>
@@ -696,9 +776,9 @@ function NairaWithdraw({
fieldClass="px-6"
type="text"
inputClass="max-w-[10rem]"
name="city"
name="newAccount.city"
placeholder="City"
value={props.values.city}
value={props.values.newAccount?.city}
inputHandler={props.handleChange}
blurHandler={props.handleBlur}
/>
@@ -724,21 +804,22 @@ function NairaWithdraw({
>
<span className="text-gradient">Cancel</span>
</button>
{requestStatus ? (
<LoadingSpinner size="8" color="sky-blue" />
) : (
<button
type="submit"
disabled={
props.isSubmitting || sendMoneyFee.loading
? true
: false
}
className="btn-gradient text-base tracking-wide px-4 py-2 rounded-full text-white cursor-pointer"
>
Continue
</button>
)}
<button
type="submit"
disabled={
props.isSubmitting || sendMoneyFee.loading
? true
: false
}
className="btn-gradient text-base tracking-wide px-4 py-2 rounded-full text-white cursor-pointer"
>
{requestStatus ? (
<LoadingSpinner size="8" color="sky-blue" />
) : (
"Continue"
)}
</button>
</div>
</Form>
);
+89 -5
View File
@@ -12,9 +12,11 @@ import Icons from "../Helpers/Icons";
import ModalCom from "../Helpers/ModalCom";
import WalletHeader from "../MyWallet/WalletHeader";
import { useSelector } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
import Flag from "../../assets/images/united-states.svg";
import siteLogo from "../../assets/images/wrenchboard.png";
import formattedDate from "../../lib/fomattedDate";
import { updateNotifications } from "../../store/notifications";
import TimeDifference from "../Helpers/TimeDifference";
export default function Header({ logoutModalHandler, sidebarHandler }) {
@@ -24,9 +26,16 @@ export default function Header({ logoutModalHandler, sidebarHandler }) {
const [moneyPopup, setPopup] = useToggle(false);
const darkMode = useContext(DarkModeContext);
const { userDetails } = useSelector((state) => state?.userDetails);
const { notifications } = useSelector((state) => state?.notifications);
const [myWalletList, setMyWalletList] = useState([]);
const api = useMemo(() => new usersService(), []);
const dispatch = useDispatch();
const [notificationData, setNotificationData] = useState({
loader: false,
data: {
raw: [],
header: [],
},
});
const getMyWalletList = async () => {
try {
@@ -93,6 +102,79 @@ export default function Header({ logoutModalHandler, sidebarHandler }) {
} else return balanceDropdown;
};
useEffect(() => {
if (!userDetails?.loggedIn) {
const getNotifications = () => {
// function to load user notification
setNotificationData({
loader: true,
data: {
header: null,
raw: null
},
});
api
.getMyNotifications()
.then((res) => {
if (res.data.internal_return < 0) {
setNotificationData({ loader: false });
return;
}
const _raw = res.data?.result_list;
//Sort the notifications in ascending order based on the API time
const _sorted = _raw?.sort((a, b) => {
const timeA = new Date(a?.date)?.getTime();
const timeB = new Date(b?.date)?.getTime();
return timeA - timeB;
});
// header component
const _header = _sorted?.slice(0, 5);
// Notification Layout
const _today = _sorted?.slice(0, 7);
const _days = () => {
const sevenDaysAgo = new Date();
sevenDaysAgo.setDate(new Date() - 7);
return _sorted?.filter((notification) => {
const notificationDate = new Date(
formattedDate(notification?.date)
);
return notificationDate >= sevenDaysAgo;
});
};
setNotificationData({
loader: false,
data: {
raw: _raw,
header: _header,
},
});
// Dispatch all notifications, sorted, and recent based on their filter type
dispatch(
updateNotifications({
loading: false,
data: {
raw: _raw,
today: _today,
// days: _days(),
sort: _sorted,
},
})
);
})
.catch((error) => {
setNotificationData({ loader: false });
throw new Error(error);
});
};
getNotifications();
}
}, [api, userDetails?.loggedIn]);
// User Profile
let { firstname, lastname, email, profile_pic } = userDetails;
let userEmail = email?.split("@")[0];
@@ -249,7 +331,9 @@ export default function Header({ logoutModalHandler, sidebarHandler }) {
>
<Icons name="notification" />
<span className="absolute right-2 top-2 z-10 text-xs lg:w-5 lg:h-5 w-4 h-4 flex justify-center items-center rounded-full primary-gradient text-white cursor-default">
{notifications?.data?.raw?.length}
{notificationData.loader
? "●"
: notificationData.data.raw?.length}
</span>
</div>
<div
@@ -265,10 +349,10 @@ export default function Header({ logoutModalHandler, sidebarHandler }) {
<div className="content px-7 pb-7">
<ul>
{notifications?.data?.header?.map((item, idx) => (
{notificationData.data.header?.map((item, idx) => (
<li
className={`content-item ${
idx === notifications?.data?.header?.length - 1
idx === notificationData.data?.header?.length - 1
? "py-5 "
: "py-4 border-b dark:border-[#5356fb29] border-light-purple hover:border-purple dark:hover:border-purple"
}`}
+241 -237
View File
@@ -5,265 +5,269 @@ import LoadingSpinner from "../components/Spinners/LoadingSpinner";
import formattedDate from "../lib/fomattedDate";
import usersService from "../services/UsersService";
import { commonHeadBanner } from "../store/CommonHeadBanner";
import { recentActivitiesData } from "../store/RecentActivitiesData";
import { updateUserDetails } from "../store/UserDetails";
import { updateJobs } from "../store/jobLists";
import { updateNotifications } from "../store/notifications";
import { updateUserJobList } from "../store/userJobList";
import { recentActivitiesData } from "../store/RecentActivitiesData";
const AuthRoute = ({ redirectPath = "/login", children }) => {
const apiCall = useMemo(() => new usersService(), []);
const dispatch = useDispatch();
const [lastActivityTime, setLastActivityTime] = useState(Date.now());
const [isLogin, setIsLogin] = useState({ loading: true, status: false });
const [loadProfileDetails, setLoadProfileDetails] = useState([]);
const navigate = useNavigate();
const apiCall = useMemo(() => new usersService(), []);
const dispatch = useDispatch();
const [lastActivityTime, setLastActivityTime] = useState(Date.now());
const [isLogin, setIsLogin] = useState({ loading: true, status: false });
const [loadProfileDetails, setLoadProfileDetails] = useState([]);
const navigate = useNavigate();
const { jobListTable } = useSelector((state) => state.tableReload);
const { jobListTable } = useSelector((state) => state.tableReload);
const {
userDetails: { username, uid },
} = useSelector((state) => state?.userDetails); // CHECKS IF USER Details are avaliable, to determine if user is active
const {
userDetails: { username, uid },
} = useSelector((state) => state?.userDetails); // CHECKS IF USER Details are avaliable, to determine if user is active
let loggedIn = username && uid ? true : false; // variable to determine if user is logged in
let loggedIn = username && uid ? true : false; // variable to determine if user is logged in
useEffect(() => {
//Removing Data stored at localStorage after session expires
const expireSession = () => {
localStorage.removeItem("uid");
localStorage.removeItem("member_id");
localStorage.removeItem("session_token");
navigate("/login", { replace: true }); // redirects user to login page after session expires
};
useEffect(() => {
//Removing Data stored at localStorage after session expires
const expireSession = () => {
localStorage.removeItem("uid");
localStorage.removeItem("member_id");
localStorage.removeItem("session_token");
navigate("/login", { replace: true }); // redirects user to login page after session expires
};
const checkInactivity = setInterval(() => {
let { account_type } = loadProfileDetails;
if (account_type === "FAMILY") {
if (
Date.now() - lastActivityTime >
process.env.REACT_APP_SESSION_EXPIRE_MINUTES_FAMILY
) {
expireSession();
}
} else {
if (
Date.now() - lastActivityTime >
process.env.REACT_APP_SESSION_EXPIRE_MINUTES
) {
expireSession();
}
}
}, process.env.REACT_APP_SESSION_EXPIRE_CHECKER); // Checks for inactivity every minute
// cleaning up listeners
return () => {
clearInterval(checkInactivity);
};
}, [lastActivityTime, navigate]);
// Reset last activity time on user input
const resetTime = useCallback(() => {
setLastActivityTime(Date.now());
}, []);
useEffect(() => {
window.addEventListener("mousemove", resetTime);
window.addEventListener("keydown", resetTime);
return () => {
window.removeEventListener("mousemove", resetTime);
window.removeEventListener("keydown", resetTime);
};
}, [resetTime]);
useEffect(() => {
if (!loggedIn) {
const loadProfile = () => {
// function to load user profile
setIsLogin({ loading: true, status: false });
apiCall
.loadProfile()
.then((res) => {
if (res.data.internal_return < 0) {
setIsLogin({ loading: false, status: false });
return;
}
setLoadProfileDetails(res.data);
dispatch(updateUserDetails({ ...res.data, loggedIn: true }));
setIsLogin({ loading: false, status: true });
})
.catch((error) => {
setIsLogin({ loading: false, status: false });
});
};
loadProfile();
const checkInactivity = setInterval(() => {
let { account_type } = loadProfileDetails;
if (account_type === "FAMILY") {
if (
Date.now() - lastActivityTime >
process.env.REACT_APP_SESSION_EXPIRE_MINUTES_FAMILY
) {
expireSession();
}
}, []);
// const filterNotifications = (notifications, filterType) => {
// const currentDate = new Date();
// if (filterType === "today") {
// return notifications?.filter((notification) => {
// const notificationDate = new Date(notification?.date);
// console.log(notificationDate)
// // return (
// // notificationDate.getDate() === currentDate.getDate() &&
// // notificationDate.getMonth() === currentDate.getMonth() &&
// // notificationDate.getFullYear() === currentDate.getFullYear()
// // );
// });
// } else if (filterType === "days") {
// const sevenDaysAgo = new Date(currentDate);
// sevenDaysAgo.setDate(currentDate.getDate() - 7);
// return notifications?.filter((notification) => {
// const notificationDate = new Date(notification?.date);
// return notificationDate >= sevenDaysAgo;
// });
// } else {
// return notifications;
// }
// };
useEffect(() => {
if (!loggedIn) {
const getNotifications = () => {
// function to load user notification
dispatch(updateNotifications({ loading: true }));
apiCall
.getMyNotifications()
.then((res) => {
if (res.data.internal_return < 0) {
dispatch(updateNotifications({ loading: false }));
return;
}
setLoadProfileDetails(res.data);
const _raw = res.data?.result_list;
//Sort the notifications in ascending order based on the API time
const _sorted = _raw?.sort((a, b) => {
const timeA = new Date(a?.date)?.getTime();
const timeB = new Date(b?.date)?.getTime();
return timeA - timeB;
});
// header component
const _header = _sorted?.slice(0, 5);
// Notification Layout
const _today = _sorted?.slice(0, 7);
const _days = () => {
const sevenDaysAgo = new Date();
sevenDaysAgo.setDate(new Date() - 7);
return _sorted?.filter((notification) => {
const notificationDate = new Date(
formattedDate(notification?.date)
);
return notificationDate >= sevenDaysAgo;
});
};
// Dispatch all notifications, sorted, and recent based on their filter type
dispatch(
updateNotifications({
loading: false,
data: {
raw: _raw,
today: _today,
// days: _days(),
sort: _sorted,
header: _header,
},
})
);
})
.catch((error) => {
dispatch(updateNotifications({ loading: false }));
});
};
getNotifications();
} else {
if (
Date.now() - lastActivityTime >
process.env.REACT_APP_SESSION_EXPIRE_MINUTES
) {
expireSession();
}
}, []);
}
}, process.env.REACT_APP_SESSION_EXPIRE_CHECKER); // Checks for inactivity every minute
useEffect(() => {
const getMyJobList = async () => {
dispatch(updateUserJobList({ loading: true, data: [] }));
try {
const res = await apiCall.getMyJobList();
// setMyJobList({loading: false, data:res.data})
// setMyJobList(res.data);
dispatch(updateUserJobList({ loading: false, data: res.data }));
} catch (error) {
dispatch(updateUserJobList({ loading: false, data: [] }));
// setMyJobList({loading: false, data:[]})
console.log("Error getting mode");
}
};
getMyJobList();
}, [jobListTable]);
// cleaning up listeners
return () => {
clearInterval(checkInactivity);
};
}, [lastActivityTime, navigate]);
useEffect(() => {
// Getting market data
const getMarketActiveJobList = async () => {
try {
const res = await apiCall.getActiveJobList();
dispatch(updateJobs(res.data));
} catch (error) {
console.log("Error getting mode");
}
};
getMarketActiveJobList();
}, [apiCall, dispatch]);
// Reset last activity time on user input
const resetTime = useCallback(() => {
setLastActivityTime(Date.now());
}, []);
//FUNCTION TO GET COMMON HEAD DATA
useEffect(()=>{
apiCall.getHeroJBanners().then((res) => {
useEffect(() => {
window.addEventListener("mousemove", resetTime);
window.addEventListener("keydown", resetTime);
return () => {
window.removeEventListener("mousemove", resetTime);
window.removeEventListener("keydown", resetTime);
};
}, [resetTime]);
useEffect(() => {
if (!loggedIn) {
const loadProfile = () => {
// function to load user profile
setIsLogin({ loading: true, status: false });
apiCall
.loadProfile()
.then((res) => {
if (res.data.internal_return < 0) {
return;
setIsLogin({ loading: false, status: false });
return;
}
dispatch(commonHeadBanner(res.data));
})
.catch((error) => {
console.log('ERROR ', error)
});
},[])
//
//FUNCTION TO GET COMMON HEAD DATA
useEffect(()=>{
apiCall.getRecentActivitiedData().then((res) => {
// debugger;
if (res.data?.internal_return < 0) {
return;
setLoadProfileDetails(res.data);
dispatch(updateUserDetails({ ...res.data, loggedIn: true }));
setIsLogin({ loading: false, status: true });
})
.catch((error) => {
setIsLogin({ loading: false, status: false });
});
};
loadProfile();
}
}, []);
// const filterNotifications = (notifications, filterType) => {
// const currentDate = new Date();
// if (filterType === "today") {
// return notifications?.filter((notification) => {
// const notificationDate = new Date(notification?.date);
// console.log(notificationDate)
// // return (
// // notificationDate.getDate() === currentDate.getDate() &&
// // notificationDate.getMonth() === currentDate.getMonth() &&
// // notificationDate.getFullYear() === currentDate.getFullYear()
// // );
// });
// } else if (filterType === "days") {
// const sevenDaysAgo = new Date(currentDate);
// sevenDaysAgo.setDate(currentDate.getDate() - 7);
// return notifications?.filter((notification) => {
// const notificationDate = new Date(notification?.date);
// return notificationDate >= sevenDaysAgo;
// });
// } else {
// return notifications;
// }
// };
useEffect(() => {
if (!loggedIn) {
const getNotifications = () => {
// function to load user notification
dispatch(updateNotifications({ loading: true }));
apiCall
.getMyNotifications()
.then((res) => {
if (res.data.internal_return < 0) {
dispatch(updateNotifications({ loading: false }));
return;
}
dispatch(recentActivitiesData(res.data));
})
.catch((error) => {
console.log('ERROR ', error)
setLoadProfileDetails(res.data);
const _raw = res.data?.result_list;
//Sort the notifications in ascending order based on the API time
const _sorted = _raw?.sort((a, b) => {
const timeA = new Date(a?.date)?.getTime();
const timeB = new Date(b?.date)?.getTime();
return timeA - timeB;
});
},[])
// useEffect(() => {
// apiCall
// .getHeroJBanners()
// .then((res) => {
// if (res.data.internal_return < 0) {
// return;
// }
// dispatch(commonHeadBanner(res.data));
// })
// .catch((error) => {
// console.log("ERROR ", error);
// });
// }, []);
//
// header component
const _header = _sorted?.slice(0, 5);
// Notification Layout
const _today = _sorted?.slice(0, 7);
return isLogin.loading && !loggedIn ? (
<LoadingSpinner size="32" color="sky-blue" height="h-screen" />
) : !isLogin.status && !loggedIn ? (
<Navigate to={redirectPath} replace />
) : (
children || <Outlet />
);
const _days = () => {
const sevenDaysAgo = new Date();
sevenDaysAgo.setDate(new Date() - 7);
return _sorted?.filter((notification) => {
const notificationDate = new Date(
formattedDate(notification?.date)
);
return notificationDate >= sevenDaysAgo;
});
};
// Dispatch all notifications, sorted, and recent based on their filter type
dispatch(
updateNotifications({
loading: false,
data: {
raw: _raw,
today: _today,
// days: _days(),
sort: _sorted,
header: _header,
},
})
);
})
.catch((error) => {
dispatch(updateNotifications({ loading: false }));
});
};
getNotifications();
}
}, []);
useEffect(() => {
const getMyJobList = async () => {
dispatch(updateUserJobList({ loading: true, data: [] }));
try {
const res = await apiCall.getMyJobList();
// setMyJobList({loading: false, data:res.data})
// setMyJobList(res.data);
dispatch(updateUserJobList({ loading: false, data: res.data }));
} catch (error) {
dispatch(updateUserJobList({ loading: false, data: [] }));
// setMyJobList({loading: false, data:[]})
console.log("Error getting mode");
}
};
getMyJobList();
}, [jobListTable]);
useEffect(() => {
// Getting market data
const getMarketActiveJobList = async () => {
try {
const res = await apiCall.getActiveJobList();
dispatch(updateJobs(res.data));
} catch (error) {
console.log("Error getting mode");
}
};
getMarketActiveJobList();
}, [apiCall, dispatch]);
//FUNCTION TO GET COMMON HEAD DATA
useEffect(() => {
apiCall
.getHeroJBanners()
.then((res) => {
if (res.data.internal_return < 0) {
return;
}
dispatch(commonHeadBanner(res.data));
})
.catch((error) => {
console.log("ERROR ", error);
});
}, []);
//
//FUNCTION TO GET COMMON HEAD DATA
useEffect(() => {
apiCall
.getRecentActivitiedData()
.then((res) => {
// debugger;
if (res.data?.internal_return < 0) {
return;
}
dispatch(recentActivitiesData(res.data));
})
.catch((error) => {
console.log("ERROR ", error);
});
}, []);
// useEffect(() => {
// apiCall
// .getHeroJBanners()
// .then((res) => {
// if (res.data.internal_return < 0) {
// return;
// }
// dispatch(commonHeadBanner(res.data));
// })
// .catch((error) => {
// console.log("ERROR ", error);
// });
// }, []);
//
return isLogin.loading && !loggedIn ? (
<LoadingSpinner size="32" color="sky-blue" height="h-screen" />
) : !isLogin.status && !loggedIn ? (
<Navigate to={redirectPath} replace />
) : (
children || <Outlet />
);
};
export default AuthRoute;
+1 -1
View File
@@ -620,7 +620,7 @@ class usersService {
member_id: localStorage.getItem("member_id"),
sessionid: localStorage.getItem("session_token"),
action: 11183,
country: value,
...value,
};
return this.postAuxEnd("/countrybanks", postData);
}