do fetch newest balance after post data on dibursement and topup request

This commit is contained in:
Wikzyy
2025-04-30 16:41:57 +07:00
parent b1b0892d4e
commit 45974aaa97
2 changed files with 51 additions and 50 deletions

View File

@ -34,25 +34,21 @@ const TransactionTopup = () => {
const API_URL = apiConfig.transaction;
const API_URL_WALLET = apiConfig.service_wallet;
useEffect(() => {
const fetchWallets = async () => {
try {
const response = await GetData(
`${API_URL_WALLET}/dashboard/balance/account/${parsedUser.customer.id}`,
{}
);
if (response?.status === true) {
setWallets(response.data || []);
} else {
toast.warning(response?.message || 'Failed to fetch wallet data');
}
} catch (error) {
toast.warning('Failed to fetch wallet data');
const fetchWallets = async () => {
try {
const response = await GetData(
`${API_URL_WALLET}/dashboard/balance/account/${parsedUser.customer.id}`,
{}
);
if (response?.status === true) {
setWallets(response.data || []);
} else {
toast.warning(response?.message || 'Failed to fetch wallet data');
}
};
fetchWallets();
}, []);
} catch (error) {
toast.warning('Failed to fetch wallet data');
}
};
const doPostData = async (form: typeof initialState) => {
setIsSubmitting(true);
@ -75,6 +71,7 @@ const TransactionTopup = () => {
} finally {
setIsSubmitting(false);
setShowConfirmation(false);
fetchWallets();
ResetForm();
}
};
@ -103,6 +100,10 @@ const TransactionTopup = () => {
setAlert({ show: false, message: '' });
};
useEffect(() => {
fetchWallets();
}, []);
return (
<>
<Helmet>