diff --git a/src/components/MyWallet/AddFundDollars.jsx b/src/components/MyWallet/AddFundDollars.jsx index 9033972..17aa615 100644 --- a/src/components/MyWallet/AddFundDollars.jsx +++ b/src/components/MyWallet/AddFundDollars.jsx @@ -2,10 +2,10 @@ import React, { useEffect, useState } from "react"; import { useNavigate } from "react-router-dom"; import usersService from "../../services/UsersService"; import InputCom from "../Helpers/Inputs/InputCom"; -import { handlePagingFunc } from "../Pagination/HandlePagination"; import LoadingSpinner from "../Spinners/LoadingSpinner"; import { Form, Formik } from "formik"; +import { useSelector } from "react-redux"; import * as Yup from "yup"; const validationSchema = Yup.object().shape({ @@ -60,24 +60,28 @@ function AddFundDollars(props) { let [tab, setTab] = useState("previous"); //STATE FOR SWITCHING BETWEEN TABS const [loader, setLoader] = useState(false); + const { userDetails } = useSelector((state) => state?.userDetails); + let { firstname, lastname } = userDetails; + let [prevCardDetails, setPrevCardDetails] = useState({}); // STATE TO HOLD PREVIOUS CARD SELECTED + let [payListCards, setPayListCards] = useState({ loading: true, data: [] }); //USER PREVIOUS CARDS + // const [payListCard, setPayListCard] = useState({ data: "" }); //USER PAYLIST - let [prevCardDetails, setPrevCardDetails] = useState(null); // STATE TO HOLD PREVIOUS CARD SELECTED + const handleInputChange = (event) => { + const { name, value } = event.target; + setPrevCardDetails((prevState) => ({ + ...prevState, + [name]: value, + })); + }; - let [payListCard, setPayListCard] = useState({ loading: true, data: [] }); //USER PREVIOUS CARDS - - const [currentPage, setCurrentPage] = useState(0); - const indexOfFirstItem = Number(currentPage); + const indexOfFirstItem = 0; const indexOfLastItem = - Number(indexOfFirstItem) + Number(process.env.REACT_APP_ITEM_PER_PAGE); - const currentPreviousCards = payListCard?.data?.slice( + indexOfFirstItem + Number(process.env.REACT_APP_ITEM_PER_PAGE); + const currentPreviousCards = payListCards?.data?.slice( indexOfFirstItem, indexOfLastItem ); - const handlePagination = (e) => { - handlePagingFunc(e, setCurrentPage); - }; - // FUNCTION TO SUBMIT const handleSubmit = (values, helpers) => { props.setInputError(""); @@ -95,10 +99,17 @@ function AddFundDollars(props) { }, 5000); } if (tab == "previous") { + if (!prevCardDetails) { + // return setTimeout(() => { + // props.setInputError(""); + // }, 5000); + return; + } setLoader(true); const stateData = { amount: Number(props.input), currency: props.currency, + card: prevCardDetails["payment-card"], }; setTimeout(() => { @@ -111,7 +122,7 @@ function AddFundDollars(props) { const stateData = { amount: Number(props.input), currency: props.currency, - ...values, + values, }; // navigate("confirm-add-fund", { state: stateData }); // State will change later dummy for now } @@ -121,11 +132,11 @@ function AddFundDollars(props) { apiCall .payListCard() .then((res) => { - setPayListCard({ loading: false, data: res.data.result_list }); + setPayListCards({ loading: false, data: res.data.result_list }); }) .catch((err) => { console.log("PAYCARDLIST ERROR", err); - setPayListCard({ loading: false, data: [] }); + setPayListCards({ loading: false, data: [] }); }); }, []); @@ -133,63 +144,97 @@ function AddFundDollars(props) { <>
{/* switch button */} -
- - +
+
+

+ {props.currency == "US Dollars" && "Payment Method"} +

+
+ + +
+
+
+

+ {props.currency == "US Dollars" + ? "Amount (USD)" + : "Amount (Naira)"} +

+
+ +

+ {props.inputError && props.inputError} +

+
+
+
{/* END OF switch button */} {/* previous tab */} {tab == "previous" ? ( -
- {payListCard.loading ? ( +
+ {payListCards.loading ? ( - ) : payListCard?.data?.length ? ( - {currentPreviousCards.map((item, index) => (
{/* - - */} + + */} ))} @@ -233,26 +278,9 @@ function AddFundDollars(props) {
)} - {/* PAGINATION BUTTON */} - {/*
- = - payListCard?.data?.length - ? true - : false - } - data={payListCard?.data} - start={indexOfFirstItem} - stop={indexOfLastItem} - /> -
*/} - {/* END OF PAGINATION BUTTON */}
) : ( -
+
{/* inputs starts here */} {/* Name */} +
+ +

{`${firstname} ${lastname}`}

+
+
{/*

Add Credit with Account Deposit

*/} {/*
*/} -
-
- - {inputError && ( -

{inputError}

- )} -
-
-

- {currency == "US Dollars" && "Payment Method"} -

-
- {/* SHOWS THIS IF USER CURRENCY IS DOLLARS */} {currency == "US Dollars" && (
@@ -91,6 +68,7 @@ function AddFundPop({ _payment, input, setInput, onClose, setConfirmCredit }) { setInput={setInput} currency={currency} onClose={onClose} + handleChange={handleChange} setConfirmCredit={setConfirmCredit} />
diff --git a/src/components/MyWallet/ConfirmAddFund.jsx b/src/components/MyWallet/ConfirmAddFund.jsx index 5f1ba20..a8b90ee 100644 --- a/src/components/MyWallet/ConfirmAddFund.jsx +++ b/src/components/MyWallet/ConfirmAddFund.jsx @@ -96,30 +96,39 @@ function ConfirmAddFund({ confirmCredit, onClose, walletItem }) { // } // }, []); - console.log("data on confirm", confirmCredit); + let __confirmCard = JSON.parse(confirmCredit?.data.card); + const ThePaymentText = ({ value }) => ( +
+
+

+ {value.description} Card +

+

+ Bank **************{value.digits} +

+
+
+ ); return ( -
+
-
+
{/*

Confirm Add Fund To Account


*/} -
-
+
+
{confirmCredit?.show ? ( -
+
-
+ {/*

*/} - - Coming Soon... + + {__confirmCard && ( + + )}

@@ -158,10 +170,10 @@ function ConfirmAddFund({ confirmCredit, onClose, walletItem }) { {confirmCredit?.data?.currency && "Payment Method"} */} {/*
*/} -
+