From 2aa1219ea90311c15c933a4a0afd5925b73b11c3 Mon Sep 17 00:00:00 2001 From: Ebube Date: Mon, 24 Jul 2023 06:15:22 +0100 Subject: [PATCH 1/7] updated payload for new account --- .../MyWallet/Popup/ConfirmNairaWithdraw.jsx | 31 +++++++++++++------ .../MyWallet/Popup/NairaWithdraw.jsx | 2 -- src/services/UsersService.js | 1 - 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/components/MyWallet/Popup/ConfirmNairaWithdraw.jsx b/src/components/MyWallet/Popup/ConfirmNairaWithdraw.jsx index 0452182..8b392a0 100644 --- a/src/components/MyWallet/Popup/ConfirmNairaWithdraw.jsx +++ b/src/components/MyWallet/Popup/ConfirmNairaWithdraw.jsx @@ -22,7 +22,6 @@ function ConfirmNairaWithdraw({ loading: false, status: false, }); - let [pageLoading, setPageLoading] = useState(true); //FUNCTION TO HANDLE SUBMIT const handleSubmit = () => { @@ -35,15 +34,17 @@ function ConfirmNairaWithdraw({ if (state?.choice === "prev") { reqData.recipient_uid = state.details?.recipient_uid; + reqData.mode = 100; } if (state?.choice === "new") { - reqData.account_no = state?.accountNumber; - reqData.account_type = state?.accountType; - reqData.bank_uid = state?.bank_uid; - reqData.country = state?.country; - reqData.state = state?.state; - reqData.city = state?.city; + reqData.account_no = state?.details?.accountNumber; + reqData.account_type = Number(state?.details?.accountType); + reqData.bank_uid = state?.details?.bank_uid; + reqData.country = state?.details?.country; + reqData.state = state?.details?.state; + reqData.city = state?.details?.city; + reqData.mode = 500; } apiURL @@ -64,6 +65,16 @@ function ConfirmNairaWithdraw({ loading: false, status: false, }); + } else if ( + res.data?.status_message + ?.toLowerCase() + .includes("recipient_add_error") + ) { + setRequestStatus({ + message: res.data?.error, + loading: false, + status: false, + }); } else { setRequestStatus({ message: "Could not perform transaction", @@ -105,7 +116,7 @@ function ConfirmNairaWithdraw({ action(); setShowNairaWithdraw({ show: true, - data: state, + data: {}, }); }; @@ -249,7 +260,9 @@ function ConfirmNairaWithdraw({ onClick={state?.choice === "prev" ? getBack : action} className="border-gradient text-base tracking-wide px-4 py-2 rounded-full" > - {state?.choice === "prev" ? "Back" : "Cancel"} + + {state?.choice === "prev" ? "Back" : "Cancel"} + From 6b473b5dc6b1209a7b755483cf1989b3d1abb66a Mon Sep 17 00:00:00 2001 From: victorAnumudu Date: Mon, 24 Jul 2023 11:58:09 +0100 Subject: [PATCH 3/7] wallet refresh --- .../MyWallet/Popup/ConfirmAddFund.jsx | 27 ++++++++---- src/components/MyWallet/Wallet.jsx | 42 +++++++++---------- src/components/Partials/Header.jsx | 3 +- 3 files changed, 41 insertions(+), 31 deletions(-) diff --git a/src/components/MyWallet/Popup/ConfirmAddFund.jsx b/src/components/MyWallet/Popup/ConfirmAddFund.jsx index 10a672a..9f402b3 100644 --- a/src/components/MyWallet/Popup/ConfirmAddFund.jsx +++ b/src/components/MyWallet/Popup/ConfirmAddFund.jsx @@ -1,6 +1,6 @@ import { FlutterWaveButton, closePaymentModal } from "flutterwave-react-v3"; import React, { useState } from "react"; -import { useDispatch } from "react-redux"; +import { useDispatch, useSelector } from "react-redux"; import { useNavigate } from "react-router-dom"; import { toast } from "react-toastify"; import usersService from "../../../services/UsersService"; @@ -99,6 +99,9 @@ function ConfirmAddFund({ : __confirmData.card; const apiURL = new usersService(); + + const { userDetails } = useSelector((state) => state?.userDetails); + const navigate = useNavigate(); const dispatch = useDispatch(); @@ -112,7 +115,13 @@ function ConfirmAddFund({ public_key: process.env.REACT_APP_FLUTTERWAVE_APIKEY, tx_ref: Date.now(), currency: "NGN", + amount: Number(__confirmData.amount), payment_options: "card,mobilemoney,ussd", + customer: { + email: userDetails.email, + phone_number: userDetails.phone, + name: `${userDetails.lastname} ${userDetails.firstname}`, + }, customizations: { title: "WrenchBoard", description: "Topup Payment", @@ -132,7 +141,7 @@ function ConfirmAddFund({ const onSuccessPayment = () => { setRequestStatus({ message: "", loading: true, status: false }); - const reqData = { amount: __confirmData?.account, currency: "NGN" }; + const reqData = { amount: Number(__confirmData?.amount), currency: "NGN" }; apiURL .startTopUp(reqData) @@ -151,9 +160,12 @@ function ConfirmAddFund({ status: true, }); toast.success("Account Topup was successful"); - setTimeout(() => { - navigate("/my-wallet", { replace: true }); - }, 1000); + onClose() + dispatch(tableReload({ type: "WALLETTABLE" })); + navigate("/my-wallet", { replace: true }); + // setTimeout(() => { + // navigate("/my-wallet", { replace: true }); + // }, 1000); } }) .catch((err) => { @@ -205,6 +217,7 @@ function ConfirmAddFund({ }, data: _response, })); + dispatch(tableReload({ type: "WALLETTABLE" })); }, 1500); } catch (error) { setConfirmCredit((prev) => ({ @@ -256,7 +269,6 @@ function ConfirmAddFund({ } setTimeout(() => { - dispatch(tableReload({ type: "WALLETTABLE" })); setConfirmCredit((prev) => ({ ...prev, show: { @@ -265,6 +277,7 @@ function ConfirmAddFund({ }, data: _response, })); + dispatch(tableReload({ type: "WALLETTABLE" })); }, 1500); } catch (error) { setConfirmCredit((prev) => ({ @@ -278,8 +291,6 @@ function ConfirmAddFund({ } }; - // console.log(confirmCredit?.data); - return (
diff --git a/src/components/MyWallet/Wallet.jsx b/src/components/MyWallet/Wallet.jsx index 0826462..01dcc96 100644 --- a/src/components/MyWallet/Wallet.jsx +++ b/src/components/MyWallet/Wallet.jsx @@ -13,7 +13,7 @@ import LoadingSpinner from "../Spinners/LoadingSpinner"; const WalletBox = lazy(() => import("./WalletBox")); const WalletRoutes = () => { - const apiCall = useMemo(() => new usersService(), []); + const apiCall = new usersService(); const { walletTable } = useSelector((state) => state.tableReload); const [walletList, setWalletList] = useState({ loading: true, @@ -25,29 +25,23 @@ const WalletRoutes = () => { data: [], }); - const getWalletList = useCallback(() => { - return apiCall + const getWalletList = () => { + apiCall .getUserWallets() .then((res) => { if (res.data.internal_return < 0) { setWalletList({ loading: false, data: [] }); } else { - setWalletList({ loading: true, data: [] }); - - setTimeout( - () => - setWalletList({ loading: false, data: res.data?.result_list }), - 500 - ); + setWalletList({ loading: false, data: res.data?.result_list }); } }) .catch(() => { setWalletList({ loading: false, data: [] }); }); - }, [apiCall]); + } - const getPaymentHistory = useCallback(() => { - return apiCall + const getPaymentHistory = () => { + apiCall .getPaymentHx() .then((res) => { if (res.data.internal_return < 0) { @@ -59,19 +53,23 @@ const WalletRoutes = () => { .catch(() => { setPaymentHistory({ loading: false, data: [] }); }); - }, [apiCall]); + } useEffect(() => { - const fetchData = async () => { - await Promise.all([getWalletList(), getPaymentHistory()]); - }; + // const fetchData = async () => { + // await Promise.all([getWalletList(), getPaymentHistory()]); + // }; - if (walletList.loading) { - fetchData(); - } - }, [walletTable, walletList.loading]); + // if (walletList.loading) { + // fetchData(); + // } + getWalletList() + getPaymentHistory() + }, [walletTable]); - console.log(walletTable); + + + console.log('TESTING',walletTable); return ( }> diff --git a/src/components/Partials/Header.jsx b/src/components/Partials/Header.jsx index cbb8156..8a9e4f4 100644 --- a/src/components/Partials/Header.jsx +++ b/src/components/Partials/Header.jsx @@ -26,6 +26,7 @@ export default function Header({ logoutModalHandler, sidebarHandler }) { const [moneyPopup, setPopup] = useToggle(false); const darkMode = useContext(DarkModeContext); const { userDetails } = useSelector((state) => state?.userDetails); + const { walletTable } = useSelector((state) => state.tableReload); // DETERMINES WHEN WALLET RELOADS const [myWalletList, setMyWalletList] = useState([]); const api = useMemo(() => new usersService(), []); const dispatch = useDispatch(); @@ -44,7 +45,7 @@ export default function Header({ logoutModalHandler, sidebarHandler }) { }; useEffect(() => { getMyWalletList(); - }, []); + }, [walletTable]); const handlerBalance = () => { setbalanceValue.toggle(); From 71f799d157261a0a5450f0973cc7ae0b5a577c9e Mon Sep 17 00:00:00 2001 From: Ebube Date: Mon, 24 Jul 2023 15:01:03 +0100 Subject: [PATCH 4/7] Checked Errors in Wallet Page and made some tiny fixes --- src/components/MyWallet/Popup/AddFundDollars.jsx | 4 ++-- src/components/MyWallet/Popup/ConfirmAddFund.jsx | 13 ++++++++++++- .../MyWallet/Popup/ConfirmNairaWithdraw.jsx | 4 ++-- src/components/MyWallet/Popup/ConfirmTransfer.jsx | 8 -------- src/components/MyWallet/Popup/NairaWithdraw.jsx | 7 ++++--- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/components/MyWallet/Popup/AddFundDollars.jsx b/src/components/MyWallet/Popup/AddFundDollars.jsx index c933d58..3cc0dd2 100644 --- a/src/components/MyWallet/Popup/AddFundDollars.jsx +++ b/src/components/MyWallet/Popup/AddFundDollars.jsx @@ -487,7 +487,7 @@ function AddFundDollars(props) { {/* Postal Code and State */}
-
+
-
+
diff --git a/src/components/MyWallet/Popup/ConfirmNairaWithdraw.jsx b/src/components/MyWallet/Popup/ConfirmNairaWithdraw.jsx index 8b392a0..16d3ffe 100644 --- a/src/components/MyWallet/Popup/ConfirmNairaWithdraw.jsx +++ b/src/components/MyWallet/Popup/ConfirmNairaWithdraw.jsx @@ -89,11 +89,11 @@ function ConfirmNairaWithdraw({ loading: false, status: false, }), - 1500 + 5000 ); } setRequestStatus({ - message: "transfer successful", + message: "Transfer Successful!", loading: false, status: true, }); diff --git a/src/components/MyWallet/Popup/ConfirmTransfer.jsx b/src/components/MyWallet/Popup/ConfirmTransfer.jsx index 95a4f4c..d6c772e 100644 --- a/src/components/MyWallet/Popup/ConfirmTransfer.jsx +++ b/src/components/MyWallet/Popup/ConfirmTransfer.jsx @@ -60,14 +60,6 @@ function ConfirmTransfer({ payment, wallet }) { }); }; - useEffect(() => { - // what happens if not state redirect user - if (!state) { - navigate("/my-wallet/transfer-fund", { replace: true }); - } else { - setPageLoading(false); - } - }, []); return (
{pageLoading ? ( diff --git a/src/components/MyWallet/Popup/NairaWithdraw.jsx b/src/components/MyWallet/Popup/NairaWithdraw.jsx index 585bb9b..6e52033 100644 --- a/src/components/MyWallet/Popup/NairaWithdraw.jsx +++ b/src/components/MyWallet/Popup/NairaWithdraw.jsx @@ -1,6 +1,5 @@ import { Form, Formik } from "formik"; import React, { useEffect, useState } from "react"; -import { useNavigate } from "react-router-dom"; import usersService from "../../../services/UsersService"; import InputCom from "../../Helpers/Inputs/InputCom"; import ModalCom from "../../Helpers/ModalCom"; @@ -13,7 +12,7 @@ function NairaWithdraw({ state, setShowConfirmNairaWithdraw, }) { - const apiCall = new usersService(); + const apiCall = new usersService(); const [tab, setTab] = useState("previous"); let [requestStatus, setRequestStatus] = useState(false); @@ -630,7 +629,9 @@ function NairaWithdraw({ className="text-slate-500 text-lg" value="" > - No Options Found! + {allCountries.data?.length + ? "Select..." + : "No Options Found!"} )} From 4876ba80c1b6291a592891554cf240dea4b6dfb4 Mon Sep 17 00:00:00 2001 From: Ebube Date: Mon, 24 Jul 2023 15:07:22 +0100 Subject: [PATCH 5/7] Changed name to back --- src/components/MyWallet/Popup/ConfirmAddFund.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/MyWallet/Popup/ConfirmAddFund.jsx b/src/components/MyWallet/Popup/ConfirmAddFund.jsx index b1f12ff..b826916 100644 --- a/src/components/MyWallet/Popup/ConfirmAddFund.jsx +++ b/src/components/MyWallet/Popup/ConfirmAddFund.jsx @@ -372,7 +372,7 @@ function ConfirmAddFund({ className="px-4 h-11 flex justify-center items-center border-gradient text-base rounded-full" onClick={getBack} > - Cancel + Back {__confirmCountry === "US" && (
+
+ {requestStatus.loading ? + + : +

{requestStatus.message}

+ } +
-
- {/*
-
-
-
*/}
diff --git a/src/components/UserHeader/RecomendedSliders.jsx b/src/components/UserHeader/RecomendedSliders.jsx index cec4982..223fbee 100644 --- a/src/components/UserHeader/RecomendedSliders.jsx +++ b/src/components/UserHeader/RecomendedSliders.jsx @@ -100,7 +100,7 @@ export default function RecomendedSliders({ className, bannerData }) {
{bannerData.map((item, index) => ( - +
Date: Mon, 24 Jul 2023 20:06:25 +0100 Subject: [PATCH 7/7] links to blog page added --- src/components/Blogs/index.jsx | 15 ++++++++++++--- src/components/Cards/HomeBannerOffersCard.jsx | 3 ++- src/components/Cards/ResourceBlogCard.jsx | 13 +++++++------ 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/components/Blogs/index.jsx b/src/components/Blogs/index.jsx index d5c952b..0876ce8 100644 --- a/src/components/Blogs/index.jsx +++ b/src/components/Blogs/index.jsx @@ -36,7 +36,16 @@ export default function BlogItem(props) { commonHeadData={props.commonHeadData} />
-
+
+

+ + {blogdata.data?.blogdata?.[0]?.post_title} + +

+
+
{blogdata.loading ? : @@ -44,7 +53,7 @@ export default function BlogItem(props) {
{/* heading */}
-
+ {/*

-
+
*/} {/*
*/}
diff --git a/src/components/Cards/HomeBannerOffersCard.jsx b/src/components/Cards/HomeBannerOffersCard.jsx index 72f4a58..1532d2a 100644 --- a/src/components/Cards/HomeBannerOffersCard.jsx +++ b/src/components/Cards/HomeBannerOffersCard.jsx @@ -16,7 +16,8 @@ export default function HomeBannerOffersCard(props) { return (