fix(orders,wallet): implement full-stack wallet deduction in PostgreSQL and sync charity donation total in user profile

This commit is contained in:
parsa aghaei committed 2026-07-26 20:40:01 +03:30
1 parent 51b2f811fa
commit 377ec7fb34
7 files changed
+76 -18

No files matched your search

@@ -114,19 +114,15 @@ export default function CheckoutPage() {
items: [...items],
total: totalAmount,
charityDonation: charityDonation,
paymentMethod: paymentMethod,
isRefill: isSubscribed,
petId: activePet?.id,
shippingAddress: shippingAddressStr
});
// 3. Update user charity total
if (charityDonation > 0) {
useUserStore.setState((state) => ({
profile: {
...state.profile,
charityDonationTotal: (state.profile.charityDonationTotal || 0) + charityDonation
}
}));
}
// Re-fetch user profile from backend to sync PostgreSQL wallet balance and charity donation total
const { fetchProfile } = useUserStore.getState();
await fetchProfile();
// 4. Update pet consumptions and charity contributions for active pet
if (activePet) {