fix(pets): persist supplement consumptions array in usePetStore and update target pet on checkout

This commit is contained in:
parsa aghaei committed 2026-07-26 20:44:55 +03:30
1 parent 5be2b9693d
commit a0145ffd9a
4 files changed
+68 -44

No files matched your search

@@ -125,8 +125,9 @@ export default function CheckoutPage() {
await fetchProfile();
// 4. Update pet consumptions and charity contributions for active pet
if (activePet) {
const newConsumptions = [...(activePet.consumptions || [])];
const targetPet = activePet || usePetStore.getState().pets[0];
if (targetPet) {
const newConsumptions = [...(targetPet.consumptions || [])];
items.forEach(item => {
const existing = newConsumptions.find(c => c.productId === item.product.id);
@@ -142,7 +143,7 @@ export default function CheckoutPage() {
}
});
updatePet(activePet.id, {
updatePet(targetPet.id, {
consumptions: newConsumptions
});
}