complete popup fixed

This commit is contained in:
2023-08-01 11:37:56 +01:00
parent e91b4a4424
commit a7bbcfdc1b
2 changed files with 37 additions and 28 deletions
@@ -1,12 +1,11 @@
import { FlutterWaveButton, closePaymentModal } from "flutterwave-react-v3";
import React, { useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { useNavigate } from "react-router-dom";
import { toast } from "react-toastify";
import debounce from "../../../hooks/debounce";
import usersService from "../../../services/UsersService";
import { tableReload } from "../../../store/TableReloads";
import LoadingSpinner from "../../Spinners/LoadingSpinner";
import debounce from "../../../hooks/debounce";
function ThePaymentText({ value, type }) {
const cardDetails = value;
@@ -133,11 +132,18 @@ function ConfirmAddFund({
...config,
text: "Proceed",
callback: (response) => {
debouncedSuccessPayment();
debouncedSuccessPayment(); //delays the call for 5 secs
setTimeout(() => {
dispatch(tableReload({ type: "WALLETTABLE" }));
onClose()
closePaymentModal();
setConfirmCredit((prev) => ({
...prev,
show: {
awaitConfirm: { loader: false, state: false },
acceptConfirm: { loader: false, state: true },
},
data: response,
}));
console.log("**** checking fw res **** ", response);
}, 1500);
},
};
@@ -150,33 +156,25 @@ function ConfirmAddFund({
.resultTopUp(reqData)
.then((res) => {
if (res.data.internal_return < 0) {
console.log("**** internal return **** THIS WAS REACHED");
console.log("**** internal return **** THIS WAS REACHED");
setRequestStatus({
message: "Could not finish transaction",
loading: false,
status: false,
});
setTimeout(() => {
setConfirmCredit((prev) => ({
...prev,
show: {
awaitConfirm: { loader: false, state: false },
acceptConfirm: { loader: false, state: true },
},
data: res,
}));
}, 1500);
// setConfirmCredit((prev) => ({
// ...prev,
// show: {
// awaitConfirm: { loader: false, state: false },
// acceptConfirm: { loader: false, state: true },
// },
// data: res,
// }));
// toast.success("Opps! something went wrong");
} else return dispatch(tableReload({ type: "WALLETTABLE" }));
toast.success("Opps! something went wrong");
} else {
setRequestStatus({
message: "Topup successful",
loading: false,
status: true,
});
}
})
.catch((err) => {
setRequestStatus({
@@ -184,11 +182,22 @@ function ConfirmAddFund({
loading: false,
status: false,
});
setTimeout(() => {
setConfirmCredit((prev) => ({
...prev,
show: {
awaitConfirm: { loader: false, state: false },
acceptConfirm: { loader: false, state: true },
},
data: err,
}));
}, 1500);
toast.success("Opps! something went wrong");
});
};
const debouncedSuccessPayment = debounce(onSuccessPayment, 5000)
const debouncedSuccessPayment = debounce(onSuccessPayment, 5000);
const handlePrevCard = async () => {
const { amount, credit_reference, currency } = __confirmData;