refactor: simplify success toast handling and refresh logic in CreditsBalanceCard
This commit is contained in:
parent
5e877bf45e
commit
1adf3d5dc3
@ -86,18 +86,15 @@ export default function CreditsBalanceCard() {
|
|||||||
if (sessionId && !hasHandledSession.current) {
|
if (sessionId && !hasHandledSession.current) {
|
||||||
hasHandledSession.current = true;
|
hasHandledSession.current = true;
|
||||||
|
|
||||||
// Show success toast (delayed to avoid React lifecycle conflicts)
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
// Show success toast and refresh data after payment
|
||||||
toast.success(t('creditsAdded'));
|
toast.success(t('creditsAdded'));
|
||||||
}, 0);
|
|
||||||
|
|
||||||
// Use setTimeout to ensure async operations complete properly
|
|
||||||
setTimeout(() => {
|
|
||||||
// Force refresh credits data to show updated balance
|
// Force refresh credits data to show updated balance
|
||||||
fetchCredits(true);
|
fetchCredits(true);
|
||||||
// Refresh credit stats
|
// Refresh credit stats
|
||||||
fetchCreditStats();
|
fetchCreditStats();
|
||||||
}, 100);
|
}, 0);
|
||||||
|
|
||||||
// Clean up URL parameters
|
// Clean up URL parameters
|
||||||
const url = new URL(window.location.href);
|
const url = new URL(window.location.href);
|
||||||
|
Loading…
Reference in New Issue
Block a user