diff --git a/src/components/AuthPages/ForgotPassword/index.jsx b/src/components/AuthPages/ForgotPassword/index.jsx index 8c53d50..ad6ebb5 100644 --- a/src/components/AuthPages/ForgotPassword/index.jsx +++ b/src/components/AuthPages/ForgotPassword/index.jsx @@ -59,7 +59,7 @@ export default function ForgotPassword() { } if (email !== "" && checked) { - const reqData = { email, action:11013 }; + const reqData = { email }; setResetLoading(true); try { const res = await userApi.StartResetPassword(reqData); diff --git a/src/components/AuthPages/ForgotPassword/index2.jsx b/src/components/AuthPages/ForgotPassword/index2.jsx index 032645e..ae7e77f 100644 --- a/src/components/AuthPages/ForgotPassword/index2.jsx +++ b/src/components/AuthPages/ForgotPassword/index2.jsx @@ -59,7 +59,7 @@ export default function ForgotPassword() { } if (email !== "" && checked) { - const reqData = { email, action:11013 }; + const reqData = { email }; setResetLoading(true); try { const res = await userApi.StartResetPassword(reqData); diff --git a/src/components/AuthPages/Login/index.jsx b/src/components/AuthPages/Login/index.jsx index 1e329cf..d1cf2d8 100644 --- a/src/components/AuthPages/Login/index.jsx +++ b/src/components/AuthPages/Login/index.jsx @@ -98,7 +98,6 @@ export default function Login() { password: password, sessionid: "STARTING", login_mode: 1100, - action: 11025, }; } else if (name == "family") { // Post Data Info for family Login @@ -107,7 +106,6 @@ export default function Login() { pin: password, sessionid: "20067A92714", login_mode: 1105, - action: 11025, }; } else { setLoginLoading(false); diff --git a/src/components/AuthPages/Login/index2.jsx b/src/components/AuthPages/Login/index2.jsx index afe5af2..9763c86 100644 --- a/src/components/AuthPages/Login/index2.jsx +++ b/src/components/AuthPages/Login/index2.jsx @@ -97,8 +97,7 @@ export default function Login() { username: email, password: password, sessionid: "STARTING", - login_mode: 1100, - action: 11025, + login_mode: 1100 }; } else if (name == "family") { // Post Data Info for family Login @@ -106,8 +105,7 @@ export default function Login() { username: email, pin: password, sessionid: "20067A92714", - login_mode: 1105, - action: 11025, + login_mode: 1105 }; } else { setLoginLoading(false); diff --git a/src/components/AuthPages/VerifyLink/index.jsx b/src/components/AuthPages/VerifyLink/index.jsx index fcfd9c5..0ce4a88 100644 --- a/src/components/AuthPages/VerifyLink/index.jsx +++ b/src/components/AuthPages/VerifyLink/index.jsx @@ -36,10 +36,7 @@ export default function VerifyLink() { var postData = { username: email, password: password, - login_mode: 100, - sessionid: "STARTER-NOTREAL", verify_link: token, - action: 11012, }; const res = await userApi?.CompleteSignUp(postData); diff --git a/src/components/AuthPages/VerifyLink/index2.jsx b/src/components/AuthPages/VerifyLink/index2.jsx index 2e50339..c305b04 100644 --- a/src/components/AuthPages/VerifyLink/index2.jsx +++ b/src/components/AuthPages/VerifyLink/index2.jsx @@ -36,10 +36,7 @@ export default function VerifyLink() { var postData = { username: email, password: password, - login_mode: 100, - sessionid: "STARTER-NOTREAL", verify_link: token, - action: 11012, }; const res = await userApi?.CompleteSignUp(postData); diff --git a/src/components/AuthPages/VerifyPassword/index.jsx b/src/components/AuthPages/VerifyPassword/index.jsx index f628899..c80b322 100644 --- a/src/components/AuthPages/VerifyPassword/index.jsx +++ b/src/components/AuthPages/VerifyPassword/index.jsx @@ -11,7 +11,11 @@ import LoadingSpinner from "../../Spinners/LoadingSpinner"; const VerifyPassword = () => { const [password, setPassword] = useState(""); const [confirmPassword, setConfirmPassword] = useState(""); - const [requestStatus, setRequestStatus] = useState({loading: true, status:false, data: []}) + const [requestStatus, setRequestStatus] = useState({ + loading: true, + status: false, + data: [], + }); const [msgError, setMsgError] = useState(""); const [linkLoader, setLinkLoader] = useState(false); const [linkSuccess, setLinkSuccess] = useState(null); @@ -35,60 +39,64 @@ const VerifyPassword = () => { }; const completeReset = async () => { - if(!password || !confirmPassword){ // CHECKS IF PASSWORD IS EMPTY + if (!password || !confirmPassword) { + // CHECKS IF PASSWORD IS EMPTY setMsgError("Please fill in fields"); return setTimeout(() => { setMsgError(null); }, process.env.REACT_APP_RESET_START_ERROR_TIMEOUT); } - if(password != confirmPassword){ // CHECKS IF PASSWORD EQUALS CONFIRM PASSWORD + if (password != confirmPassword) { + // CHECKS IF PASSWORD EQUALS CONFIRM PASSWORD setMsgError("Passwords does not match"); return setTimeout(() => { setMsgError(null); }, process.env.REACT_APP_RESET_START_ERROR_TIMEOUT); } - if(password.length < 6){ // CHECKS IF PASSWORD LENGTH IS UPTO 6 CHARACTERS + if (password.length < 6) { + // CHECKS IF PASSWORD LENGTH IS UPTO 6 CHARACTERS setMsgError("Password must be upto six characters"); return setTimeout(() => { setMsgError(null); }, process.env.REACT_APP_RESET_START_ERROR_TIMEOUT); } - if(!PasswordValidator(password)){ // CHECKS IF PASSWORD IS VALID - setMsgError("Password must contain alphanumeric, uppercase and special character: eg: Password1@"); + if (!PasswordValidator(password)) { + // CHECKS IF PASSWORD IS VALID + setMsgError( + "Password must contain alphanumeric, uppercase and special character: eg: Password1@" + ); return setTimeout(() => { setMsgError(null); }, process.env.REACT_APP_RESET_START_ERROR_TIMEOUT); } try { - setLinkLoader(true); - var reqData = { - sessionid: "DUMMY-CANNOT_BE_EMPTY", - reset_link: token, - newpass: password, - m_uid: requestStatus.data?.m_uid || '', - reset_uid: requestStatus.data?.reset_uid || '', - step: 300, - action: 730, - }; - const res = await userApi?.CompleteResetPassword(reqData); + setLinkLoader(true); + var reqData = { + reset_link: token, + newpass: password, + m_uid: requestStatus.data?.m_uid || "", + reset_uid: requestStatus.data?.reset_uid || "", + step: 300, + }; + const res = await userApi?.CompleteResetPassword(reqData); - if (res.status == 200) { - const { data } = res; - if (data?.internal_return >= 0) { - // setTimeout(() => { - // navigate("/login", { replace: true }); - // setLinkLoader(false); - // }, 2000); - setLinkSuccess(true); - } else { - setLinkLoader(false); - setMsgError("An error occurred"); - setLinkSuccess(false); - } - } else { - setLinkLoader(false); - setLinkSuccess(false); - } + if (res.status == 200) { + const { data } = res; + if (data?.internal_return >= 0) { + // setTimeout(() => { + // navigate("/login", { replace: true }); + // setLinkLoader(false); + // }, 2000); + setLinkSuccess(true); + } else { + setLinkLoader(false); + setMsgError("An error occurred"); + setLinkSuccess(false); + } + } else { + setLinkLoader(false); + setLinkSuccess(false); + } } catch (error) { setLinkLoader(false); setLinkSuccess(false); @@ -100,31 +108,33 @@ const VerifyPassword = () => { } }; - const verifyResetPwd = () => { // FUNCTION TO VERIFY RESET PASSWORD LINK - setRequestStatus({loading: true, status:false, data: []}) + const verifyResetPwd = () => { + // FUNCTION TO VERIFY RESET PASSWORD LINK + setRequestStatus({ loading: true, status: false, data: [] }); var reqData = { - sessionid: "DUMMY-CANNOT_BE_EMPTY", reset_link: token, step: 200, - action: 730, }; - userApi.CompleteResetPassword(reqData).then(res => { - if(res.status != 200 || res.data.internal_return < 0){ - return setRequestStatus({loading: false, status:false, data: []}) - } - setRequestStatus({loading: false, status:true, data: res.data}) - }).catch(error => { - setRequestStatus({loading: false, status:false, data: []}) - }) - } + userApi + .CompleteResetPassword(reqData) + .then((res) => { + if (res.status != 200 || res.data.internal_return < 0) { + return setRequestStatus({ loading: false, status: false, data: [] }); + } + setRequestStatus({ loading: false, status: true, data: res.data }); + }) + .catch((error) => { + setRequestStatus({ loading: false, status: false, data: [] }); + }); + }; - useEffect(()=>{ + useEffect(() => { // little checker for the validity of the token - if (token==null || token?.length != 64) { - return setRequestStatus({loading: false, status:false, data: []}); - } - verifyResetPwd() - },[]) + if (token == null || token?.length != 64) { + return setRequestStatus({ loading: false, status: false, data: [] }); + } + verifyResetPwd(); + }, []); return ( <> @@ -139,59 +149,68 @@ const VerifyPassword = () => {
- {requestStatus.loading ? - - : - !requestStatus.loading && requestStatus.status ? -
- {linkSuccess == null ? - <> -
-

- Password Reset -

- - Enter a new password to reset - - - We'll send an email to confirm reset - -
-
-

- Must include a special, numeric, uppercase and lowercase character -

-
- navigate("/login")} + {requestStatus.loading ? ( + + ) : !requestStatus.loading && requestStatus.status ? ( +
+ {linkSuccess == null ? ( + <> +
+

+ Password Reset +

+ + Enter a new password to reset + + + We'll send an email to confirm reset + +
+
+

+ Must include a special, numeric, uppercase and lowercase + character +

+
+ navigate("/login")} + /> + + ) : ( + - - : - - } -
- : -
- -
- } + )} +
+ ) : ( +
+ +
+ )}
diff --git a/src/components/AuthPages/VerifyPassword/index2.jsx b/src/components/AuthPages/VerifyPassword/index2.jsx index 70564e7..47b220a 100644 --- a/src/components/AuthPages/VerifyPassword/index2.jsx +++ b/src/components/AuthPages/VerifyPassword/index2.jsx @@ -11,7 +11,11 @@ import LoadingSpinner from "../../Spinners/LoadingSpinner"; const VerifyPassword = () => { const [password, setPassword] = useState(""); const [confirmPassword, setConfirmPassword] = useState(""); - const [requestStatus, setRequestStatus] = useState({loading: true, status:false, data: []}) + const [requestStatus, setRequestStatus] = useState({ + loading: true, + status: false, + data: [], + }); const [msgError, setMsgError] = useState(""); const [linkLoader, setLinkLoader] = useState(false); const [linkSuccess, setLinkSuccess] = useState(null); @@ -35,60 +39,64 @@ const VerifyPassword = () => { }; const completeReset = async () => { - if(!password || !confirmPassword){ // CHECKS IF PASSWORD IS EMPTY + if (!password || !confirmPassword) { + // CHECKS IF PASSWORD IS EMPTY setMsgError("Please fill in fields"); return setTimeout(() => { setMsgError(null); }, process.env.REACT_APP_RESET_START_ERROR_TIMEOUT); } - if(password != confirmPassword){ // CHECKS IF PASSWORD EQUALS CONFIRM PASSWORD + if (password != confirmPassword) { + // CHECKS IF PASSWORD EQUALS CONFIRM PASSWORD setMsgError("Passwords does not match"); return setTimeout(() => { setMsgError(null); }, process.env.REACT_APP_RESET_START_ERROR_TIMEOUT); } - if(password.length < 6){ // CHECKS IF PASSWORD LENGTH IS UPTO 6 CHARACTERS + if (password.length < 6) { + // CHECKS IF PASSWORD LENGTH IS UPTO 6 CHARACTERS setMsgError("Password must be upto six characters"); return setTimeout(() => { setMsgError(null); }, process.env.REACT_APP_RESET_START_ERROR_TIMEOUT); } - if(!PasswordValidator(password)){ // CHECKS IF PASSWORD IS VALID - setMsgError("Password must contain alphanumeric, uppercase and special character: eg: Password1@"); + if (!PasswordValidator(password)) { + // CHECKS IF PASSWORD IS VALID + setMsgError( + "Password must contain alphanumeric, uppercase and special character: eg: Password1@" + ); return setTimeout(() => { setMsgError(null); }, process.env.REACT_APP_RESET_START_ERROR_TIMEOUT); } try { - setLinkLoader(true); - var reqData = { - sessionid: "DUMMY-CANNOT_BE_EMPTY", - reset_link: token, - newpass: password, - m_uid: requestStatus.data?.m_uid || '', - reset_uid: requestStatus.data?.reset_uid || '', - step: 300, - action: 730, - }; - const res = await userApi?.CompleteResetPassword(reqData); + setLinkLoader(true); + var reqData = { + reset_link: token, + newpass: password, + m_uid: requestStatus.data?.m_uid || "", + reset_uid: requestStatus.data?.reset_uid || "", + step: 300, + }; + const res = await userApi?.CompleteResetPassword(reqData); - if (res.status == 200) { - const { data } = res; - if (data?.internal_return >= 0) { - // setTimeout(() => { - // navigate("/login", { replace: true }); - // setLinkLoader(false); - // }, 2000); - setLinkSuccess(true); - } else { - setLinkLoader(false); - setMsgError("An error occurred"); - setLinkSuccess(false); - } - } else { - setLinkLoader(false); - setLinkSuccess(false); - } + if (res.status == 200) { + const { data } = res; + if (data?.internal_return >= 0) { + // setTimeout(() => { + // navigate("/login", { replace: true }); + // setLinkLoader(false); + // }, 2000); + setLinkSuccess(true); + } else { + setLinkLoader(false); + setMsgError("An error occurred"); + setLinkSuccess(false); + } + } else { + setLinkLoader(false); + setLinkSuccess(false); + } } catch (error) { setLinkLoader(false); setLinkSuccess(false); @@ -100,31 +108,33 @@ const VerifyPassword = () => { } }; - const verifyResetPwd = () => { // FUNCTION TO VERIFY RESET PASSWORD LINK - setRequestStatus({loading: true, status:false, data: []}) + const verifyResetPwd = () => { + // FUNCTION TO VERIFY RESET PASSWORD LINK + setRequestStatus({ loading: true, status: false, data: [] }); var reqData = { - sessionid: "DUMMY-CANNOT_BE_EMPTY", reset_link: token, step: 200, - action: 730, }; - userApi.CompleteResetPassword(reqData).then(res => { - if(res.status != 200 || res.data.internal_return < 0){ - return setRequestStatus({loading: false, status:false, data: []}) - } - setRequestStatus({loading: false, status:true, data: res.data}) - }).catch(error => { - setRequestStatus({loading: false, status:false, data: []}) - }) - } + userApi + .CompleteResetPassword(reqData) + .then((res) => { + if (res.status != 200 || res.data.internal_return < 0) { + return setRequestStatus({ loading: false, status: false, data: [] }); + } + setRequestStatus({ loading: false, status: true, data: res.data }); + }) + .catch((error) => { + setRequestStatus({ loading: false, status: false, data: [] }); + }); + }; - useEffect(()=>{ + useEffect(() => { // little checker for the validity of the token - if (token==null || token?.length != 64) { - return setRequestStatus({loading: false, status:false, data: []}); - } - verifyResetPwd() - },[]) + if (token == null || token?.length != 64) { + return setRequestStatus({ loading: false, status: false, data: [] }); + } + verifyResetPwd(); + }, []); return ( <> @@ -139,59 +149,68 @@ const VerifyPassword = () => {
- {requestStatus.loading ? - - : - !requestStatus.loading && requestStatus.status ? -
- {linkSuccess == null ? - <> -
-

- Password Reset -

- - Enter a new password to reset - - - We'll send an email to confirm reset - -
-
-

- Must include a special, numeric, uppercase and lowercase character -

-
- navigate("/login")} + {requestStatus.loading ? ( + + ) : !requestStatus.loading && requestStatus.status ? ( +
+ {linkSuccess == null ? ( + <> +
+

+ Password Reset +

+ + Enter a new password to reset + + + We'll send an email to confirm reset + +
+
+

+ Must include a special, numeric, uppercase and lowercase + character +

+
+ navigate("/login")} + /> + + ) : ( + - - : - - } -
- : -
- -
- } + )} +
+ ) : ( +
+ +
+ )}
diff --git a/src/components/FamilyAcc/FamilyManageTabs.jsx b/src/components/FamilyAcc/FamilyManageTabs.jsx index ff745c5..e9ad72d 100644 --- a/src/components/FamilyAcc/FamilyManageTabs.jsx +++ b/src/components/FamilyAcc/FamilyManageTabs.jsx @@ -13,6 +13,7 @@ import usersService from "../../services/UsersService"; import LoadingSpinner from "../Spinners/LoadingSpinner"; import AssignTaskPopout from "./FamilyPopout/AssignTaskPopout"; import FamilyWallet from "./Tabs/FamilyWallet"; +import { apiConst } from "../../lib/apiConst"; // Lazy Imports for components const FamilyWaitlist = lazy(() => import("./Tabs/FamilyWaitlist")); @@ -127,7 +128,7 @@ export default function FamilyManageTabs({ file_type: uploadedFile?.type?.split("/")[0]?.toLowerCase(), file_data: base64Img, msg_type: 'FILE', - action: 11305 + action: apiConst.WRENCHBOARD_PICTURE_FAMMEMBER } setUploadStatus({loading: true, status: false, message:'Loading...'}) apiCall.sendFiles(reqData).then(res=>{ @@ -285,7 +286,7 @@ export default function FamilyManageTabs({ limit: 30, offset: 0, job_type: "FAMILY", - action: 13005, + action: apiConst.WRENCHBOARD_PICTURE_FAMMEMBER, }; if (checkFamilyTask) { diff --git a/src/components/FamilyAcc/FamilySettings/Tabs/FamilyBanner.jsx b/src/components/FamilyAcc/FamilySettings/Tabs/FamilyBanner.jsx index f4476ae..e23de15 100644 --- a/src/components/FamilyAcc/FamilySettings/Tabs/FamilyBanner.jsx +++ b/src/components/FamilyAcc/FamilySettings/Tabs/FamilyBanner.jsx @@ -1,5 +1,6 @@ import React, { useMemo, useRef, useState } from "react"; import usersService from "../../../../services/UsersService"; +import { apiConst } from "../../../../lib/apiConst"; const FamilyBanner = ({ imageServer }) => { const uploadedImage = `${imageServer}${localStorage.getItem( @@ -65,7 +66,7 @@ const FamilyBanner = ({ imageServer }) => { file_type: uploadedFile?.type?.split("/")[0]?.toLowerCase(), file_data: base64Img, msg_type: "FILE", - action: 11303, + action: apiConst.WRENCHBOARD_PICTURE_JOB, }; setUploadStatus({ loading: true, diff --git a/src/components/FamilyAcc/Tabs/FamilyProfile.jsx b/src/components/FamilyAcc/Tabs/FamilyProfile.jsx index 64aa27e..90b9a5e 100644 --- a/src/components/FamilyAcc/Tabs/FamilyProfile.jsx +++ b/src/components/FamilyAcc/Tabs/FamilyProfile.jsx @@ -55,7 +55,6 @@ export default function FamilyProfile({ familyData, className }) { year: familyData?.year, month: familyData?.month, enable_traking: familyData?.enable_traking, - action: 22020, }; // const handleChange = ({ target: { name, value } }) => { diff --git a/src/components/FamilyAcc/Tabs/wallet/FamilyAddFundPopout.jsx b/src/components/FamilyAcc/Tabs/wallet/FamilyAddFundPopout.jsx index 5e0bbac..5793e06 100644 --- a/src/components/FamilyAcc/Tabs/wallet/FamilyAddFundPopout.jsx +++ b/src/components/FamilyAcc/Tabs/wallet/FamilyAddFundPopout.jsx @@ -1,15 +1,16 @@ -import React, { useEffect, useState } from 'react' -import ModalCom from '../../../Helpers/ModalCom' -import InputCom from '../../../Helpers/Inputs/InputCom' +import React, { useEffect, useState } from "react"; +import ModalCom from "../../../Helpers/ModalCom"; +import InputCom from "../../../Helpers/Inputs/InputCom"; import { Form, Formik } from "formik"; import * as Yup from "yup"; -import {AmountTo2DP} from '../../../Helpers/PriceFormatter' -import usersService from '../../../../services/UsersService'; -import LoadingSpinner from '../../../Spinners/LoadingSpinner'; -import { PriceFormatter } from '../../../Helpers/PriceFormatter'; -import { tableReload } from '../../../../store/TableReloads'; -import { useDispatch } from 'react-redux'; +import { AmountTo2DP } from "../../../Helpers/PriceFormatter"; +import usersService from "../../../../services/UsersService"; +import LoadingSpinner from "../../../Spinners/LoadingSpinner"; +import { PriceFormatter } from "../../../Helpers/PriceFormatter"; +import { tableReload } from "../../../../store/TableReloads"; +import { useDispatch } from "react-redux"; +import { apiConst } from "../../../../lib/apiConst"; const validationSchema = Yup.object().shape({ // amount: Yup.string() @@ -22,104 +23,149 @@ const validationSchema = Yup.object().shape({ // return true; // }) // .required("Amount is required"), - amount: Yup.number('Please enter a number') - .min(1, "Price must be greater than 0") - .required("Amount is required"), - comment: Yup.string() - .required("Comment is required"), + amount: Yup.number("Please enter a number") + .min(1, "Price must be greater than 0") + .required("Amount is required"), + comment: Yup.string().required("Comment is required"), }); -function FamilyAddFundPopout({action, situation, wallet, familyData}) { +function FamilyAddFundPopout({ action, situation, wallet, familyData }) { + const dispatch = useDispatch(); - const dispatch = useDispatch() + const apiUrl = new usersService(); - const apiUrl = new usersService() - - const [startTransfer, setStartTransfer] = useState({loading:true, data: {}}) - - const [requestStatus, setRequestStatus] = useState({loading:false, status:false, message:''}) + const [startTransfer, setStartTransfer] = useState({ + loading: true, + data: {}, + }); + const [requestStatus, setRequestStatus] = useState({ + loading: false, + status: false, + message: "", + }); // initial values for formik let initialValues = { - amount: '', - from : AmountTo2DP(startTransfer?.data?.origing_current_balance*0.01), + amount: "", + from: AmountTo2DP(startTransfer?.data?.origing_current_balance * 0.01), to: `${familyData.firstname} ${familyData.lastname}`, - comment: '' + comment: "", }; // FUNCTION TO PERFORM FAMILY TRANSFER const handleAddFund = (values) => { - setRequestStatus({loading:true, status:false, message:''}) + setRequestStatus({ loading: true, status: false, message: "" }); - let senderBal = startTransfer?.data?.origing_current_balance || '' // SENDER'S ACCOUNT BALANCE - let senderLimit = startTransfer?.data?.origing_transfer_limit || '' // SENDER'S TRANSFER LIMIT + let senderBal = startTransfer?.data?.origing_current_balance || ""; // SENDER'S ACCOUNT BALANCE + let senderLimit = startTransfer?.data?.origing_transfer_limit || ""; // SENDER'S TRANSFER LIMIT - let reqData = { // API REQUEST DATA - family_uid : familyData.uid, - wallet_uid : wallet.wallet_uid, - origing_wallet_uid : startTransfer?.data?.origing_wallet_uid, - currency : startTransfer?.data?.currency, - amount : values.amount*100, - description : values.comment, - family_transfer_mode : 100, - action : 22014 + let reqData = { + // API REQUEST DATA + family_uid: familyData.uid, + wallet_uid: wallet.wallet_uid, + origing_wallet_uid: startTransfer?.data?.origing_wallet_uid, + currency: startTransfer?.data?.currency, + amount: values.amount * 100, + description: values.comment, + family_transfer_mode: 100, + action: apiConst.WRENCHBOARD_FAMILY_TRANSFER, + }; + + if (!senderBal || !senderLimit) { + // RETURNS UNAUTHORIZED, IF SENDER BAL OR LIMIT IS NOT AVAILABLE + setRequestStatus({ + loading: false, + status: false, + message: "Unauthorized, try again later", + }); + return setTimeout(() => { + setRequestStatus({ loading: false, status: false, message: "" }); + }, 5000); } - if(!senderBal || !senderLimit){ // RETURNS UNAUTHORIZED, IF SENDER BAL OR LIMIT IS NOT AVAILABLE - setRequestStatus({loading:false, status:false, message:'Unauthorized, try again later'}) - return setTimeout(()=>{ - setRequestStatus({loading:false, status:false, message:''}) - }, 5000) + if (values.amount > senderBal * 0.01) { + // CHECKS TO SEE IF SENDER IS SENDING MORE THAN HIS BALANCE + setRequestStatus({ + loading: false, + status: false, + message: "You cannot send more than your balance", + }); + return setTimeout(() => { + setRequestStatus({ loading: false, status: false, message: "" }); + }, 5000); } - if(values.amount > senderBal*0.01){ // CHECKS TO SEE IF SENDER IS SENDING MORE THAN HIS BALANCE - setRequestStatus({loading:false, status:false, message:'You cannot send more than your balance'}) - return setTimeout(()=>{ - setRequestStatus({loading:false, status:false, message:''}) - }, 5000) + if (values.amount > senderLimit * 0.01) { + // CHECKS TO SEE IF SENDER IS SENDING MORE THAN HIS LIMIT + setRequestStatus({ + loading: false, + status: false, + message: `You cannot exceed ${senderLimit * 0.01} ${ + startTransfer?.data?.origing_currency.charAt(0).toUpperCase() + + startTransfer?.data?.origing_currency.slice(1).toLowerCase() + }`, + }); + return setTimeout(() => { + setRequestStatus({ loading: false, status: false, message: "" }); + }, 5000); } - if(values.amount > senderLimit*0.01){ // CHECKS TO SEE IF SENDER IS SENDING MORE THAN HIS LIMIT - setRequestStatus({loading:false, status:false, message:`You cannot exceed ${senderLimit*0.01} ${startTransfer?.data?.origing_currency.charAt(0).toUpperCase() + startTransfer?.data?.origing_currency.slice(1).toLowerCase()}`}) - return setTimeout(()=>{ - setRequestStatus({loading:false, status:false, message:''}) - }, 5000) - } - - apiUrl.familyTransfer(reqData).then(({data}) => { - if(data.internal_return < 0 || data.credit_confirm == '' || data.pay_confirm == ''){ - setRequestStatus({loading:false, status:false, message:'Transfer Failed'}) - return setTimeout(()=>{ - setRequestStatus({loading:false, status:false, message:''}) - }, 5000) - } - setRequestStatus({loading:false, status:true, message:'Transfer Successful'}) - setTimeout(()=>{ - setRequestStatus({loading:false, status:false, message:''}) - dispatch(tableReload({ type: "WALLETTABLE" })); // UPDATES PARENT WALLET ACCOUNT - action() // TO CLOSE THE MODAL - }, 5000) - }).catch(error => { - setRequestStatus({loading:false, status:false, message:'Network Error, try again'}) - setTimeout(()=>{ - setRequestStatus({loading:false, status:false, message:''}) - }, 5000) - }) - } + apiUrl + .familyTransfer(reqData) + .then(({ data }) => { + if ( + data.internal_return < 0 || + data.credit_confirm == "" || + data.pay_confirm == "" + ) { + setRequestStatus({ + loading: false, + status: false, + message: "Transfer Failed", + }); + return setTimeout(() => { + setRequestStatus({ loading: false, status: false, message: "" }); + }, 5000); + } + setRequestStatus({ + loading: false, + status: true, + message: "Transfer Successful", + }); + setTimeout(() => { + setRequestStatus({ loading: false, status: false, message: "" }); + dispatch(tableReload({ type: "WALLETTABLE" })); // UPDATES PARENT WALLET ACCOUNT + action(); // TO CLOSE THE MODAL + }, 5000); + }) + .catch((error) => { + setRequestStatus({ + loading: false, + status: false, + message: "Network Error, try again", + }); + setTimeout(() => { + setRequestStatus({ loading: false, status: false, message: "" }); + }, 5000); + }); + }; // LOAD FAMILY START TRANSFER - useEffect(()=>{ + useEffect(() => { let reqData = { family_uid: familyData.uid, wallet_uid: wallet.wallet_uid, - action: 22013 - } - apiUrl.familyTransferStart(reqData).then(response => { - setStartTransfer({loading:false, data:response?.data }) - }).catch(err => { - setStartTransfer({loading:false, data: {}}) - }) - },[]) + action: apiConst.WRENCHBOARD_FAMILY_TRANSFERSTART, + }; + apiUrl + .familyTransferStart(reqData) + .then((response) => { + setStartTransfer({ loading: false, data: response?.data }); + }) + .catch((err) => { + setStartTransfer({ loading: false, data: {} }); + }); + }, []); return ( @@ -155,116 +201,125 @@ function FamilyAddFundPopout({action, situation, wallet, familyData}) {
- {startTransfer.loading && } - - { !startTransfer.loading && - - {(props) => ( -
-
-
- {/* AMOUNT */} -
- -
+ {startTransfer.loading && ( + + )} - {/* FROM */} -
- -
- - {/* TO */} -
- -
- - {/* COMMENT */} -
-
- -