Skip to content

Commit 3d92c57

Browse files
committed
feat: add profile data refresh aftername update
1 parent 9524fd8 commit 3d92c57

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

web-marketplace/src/pages/BuyCredits/BuyCredits.Form.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ import {
1818
switchWalletModalAtom,
1919
} from 'lib/atoms/modals.atoms';
2020
import { useAuth } from 'lib/auth/auth';
21+
import { reactQueryClient } from 'lib/clients/reactQueryClient';
2122
import { apiServerUrl } from 'lib/env';
2223
import { NormalizeProject } from 'lib/normalizers/projects/normalizeProjectsWithMetadata';
2324
import { getCreditTypeQuery } from 'lib/queries/react-query/ecocredit/getCreditTypeQuery/getCreditTypeQuery';
2425
import { getAllowedDenomQuery } from 'lib/queries/react-query/ecocredit/marketplace/getAllowedDenomQuery/getAllowedDenomQuery';
2526
import { getPaymentMethodsQuery } from 'lib/queries/react-query/registry-server/getPaymentMethodsQuery/getPaymentMethodsQuery';
2627
import { getSubscribersStatusQuery } from 'lib/queries/react-query/registry-server/getSubscribersStatusQuery/getSubscribersStatusQuery';
28+
import { getAccountByIdQueryKey } from 'lib/queries/react-query/registry-server/graphql/getAccountByIdQuery/getAccountByIdQuery.utils';
2729
import { useWallet } from 'lib/wallet/wallet';
2830

2931
import { useFetchUserBalance } from 'pages/BuyCredits/hooks/useFetchUserBalance';
@@ -224,6 +226,14 @@ export const BuyCreditsForm = ({
224226
[data, handleSaveNext, setPaymentMethodId],
225227
);
226228

229+
const refreshProfileData = useCallback(async () => {
230+
if (activeAccount) {
231+
await reactQueryClient.invalidateQueries({
232+
queryKey: getAccountByIdQueryKey({ id: activeAccount.id }),
233+
});
234+
}
235+
}, [activeAccount]);
236+
227237
const allowedDenoms = useMemo(
228238
() => allowedDenomsData?.allowedDenoms,
229239
[allowedDenomsData?.allowedDenoms],
@@ -325,6 +335,7 @@ export const BuyCreditsForm = ({
325335
},
326336
},
327337
});
338+
refreshProfileData();
328339
}
329340

330341
if (selectedSellOrders && creditsAmount)
@@ -362,14 +373,15 @@ export const BuyCreditsForm = ({
362373
project,
363374
refetchSellOrders,
364375
data,
365-
activeAccount?.name,
366376
activeAccount?.id,
377+
activeAccount?.name,
367378
creditsAmount,
368379
purchase,
369380
retiring,
370381
paymentMethodId,
371382
confirmationTokenId,
372383
updateAccountById,
384+
refreshProfileData,
373385
currency,
374386
_,
375387
allowedDenomsData,

0 commit comments

Comments
 (0)