wallet refresh
This commit was merged in pull request #349.
This commit is contained in:
@@ -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 (
|
||||
<Layout>
|
||||
<Suspense fallback={<LoadingSpinner size="16" color="sky-blue" />}>
|
||||
|
||||
Reference in New Issue
Block a user