diff --git a/ordering/src/components/Cart/Cart.js b/ordering/src/components/Cart/Cart.js index 6eab667..d4f17d2 100644 --- a/ordering/src/components/Cart/Cart.js +++ b/ordering/src/components/Cart/Cart.js @@ -1,15 +1,33 @@ -import React from "react" +import React, { useContext } from "react" import classes from "./Cart.module.css" +import CartItem from "./CartItem" + import Modal from "../UI/Modal" +import CartContext from "../../store/cart-context" function Cart(props) { + const cartCtx = useContext(CartContext) + + const totalAmount = `$${cartCtx.totalAmount.toFixed(2)}` + const hasItems = cartCtx.items.length > 0 + + const cartItemRemoveHandler = id => {} + const cartItemAddHandler = items => {} + const cartItems = ( ) @@ -18,7 +36,7 @@ function Cart(props) { {cartItems}
Total Amount - 35.62 + {totalAmount}
- + {hasItems && }
) diff --git a/ordering/src/components/Cart/Cart.module.css b/ordering/src/components/Cart/Cart.module.css index f6ffe47..b9687f8 100644 --- a/ordering/src/components/Cart/Cart.module.css +++ b/ordering/src/components/Cart/Cart.module.css @@ -3,7 +3,7 @@ margin: 0; padding: 0; max-height: 20rem; - overflow: auto; + overflow: scroll; } .total {