From 1c7f8958729e6a2f4495f83601a6d662e5016f28 Mon Sep 17 00:00:00 2001 From: Jose Rios Date: Fri, 22 Nov 2024 16:31:35 -0600 Subject: [PATCH] update cart-slice to set the correct totalPrice when decreasing quantity --- .../02-refresher-practice-finished/src/store/cart-slice.js | 1 + 1 file changed, 1 insertion(+) diff --git a/code/20 Advanced Redux/02-refresher-practice-finished/src/store/cart-slice.js b/code/20 Advanced Redux/02-refresher-practice-finished/src/store/cart-slice.js index dce632d86..1d26d83aa 100644 --- a/code/20 Advanced Redux/02-refresher-practice-finished/src/store/cart-slice.js +++ b/code/20 Advanced Redux/02-refresher-practice-finished/src/store/cart-slice.js @@ -32,6 +32,7 @@ const cartSlice = createSlice({ state.items = state.items.filter(item => item.id !== id); } else { existingItem.quantity--; + existingItem.totalPrice = existingItem.totalPrice - newItem.price; } }, },