diff --git a/src/CartItem.jsx b/src/CartItem.jsx index e06317433..968a5a9d7 100644 --- a/src/CartItem.jsx +++ b/src/CartItem.jsx @@ -9,31 +9,38 @@ const CartItem = ({ onContinueShopping }) => { // Calculate total amount for all products in the cart const calculateTotalAmount = () => { + return cart.reduce((total, item) => total + Number(item.cost.substring(1)) * item.quantity, 0); }; const handleContinueShopping = (e) => { + onContinueShopping(e); }; const handleIncrement = (item) => { + dispatch(updateQuantity({ name: item.name, quantity: item.quantity + 1 })); }; const handleDecrement = (item) => { + dispatch(updateQuantity({ name: item.name, quantity: item.quantity - 1 })); }; const handleRemove = (item) => { + dispatch(removeItem(item)); }; // Calculate total cost based on quantity for an item const calculateTotalCost = (item) => { + return Number(item.cost.substring(1)) * item.quantity; }; return (
{plant.description}
+{plant.cost}
+ +