Skip to content

Commit 2d2e1e9

Browse files
authored
Merge pull request #591 from Priyanka0205-CSE/fix/hubcoin-balance-ui-update
fix: update HubCoin balance in UI immediately after purchase
2 parents 01b0b47 + 5d322a8 commit 2d2e1e9

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/context/AuthContext.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,11 @@ export const AuthProvider = ({ children }) => {
354354
updatedAt: new Date().toISOString()
355355
});
356356
});
357+
setUserData(prev => ({
358+
...prev,
359+
hubCoins: (prev.hubCoins ?? 0) - price,
360+
inventory: [...(prev.inventory || ["oliver"]), mascotId],
361+
}));
357362
} catch (err) {
358363
console.error("Failed to purchase mascot:", err);
359364
throw err;

0 commit comments

Comments
 (0)