MCPcopy Create free account
hub / github.com/Source-Controller/eCommerce-Fullstack / onRemove

Function onRemove

context/StateContext.js:40–47  ·  view source on GitHub ↗
(product)

Source from the content-addressed store, hash-verified

38 }
39
40 const onRemove = (product) => {
41 foundProduct = cartItems.find((item) => item._id === product._id);
42 const newCartItems = cartItems.filter((item) => item._id !== product._id);
43
44 setTotalPrice((prevTotalPrice) => prevTotalPrice -foundProduct.price * foundProduct.quantity);
45 setTotalQty(prevTotalQty => prevTotalQty - foundProduct.quantity);
46 setCartItems(newCartItems);
47 }
48
49 const toggleCartItemQuantity = (id, value) => {
50 foundProduct = cartItems.find((item) => item._id === id)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected