From ce7158fc15e510a4c99f7878be4b8e78cba6efb8 Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Mon, 26 Sep 2022 13:26:51 -0400 Subject: [PATCH] carttem and funcs --- ordering/src/components/Cart/Cart.js | 34 +++++++++++++++----- ordering/src/components/Cart/Cart.module.css | 2 +- 2 files changed, 27 insertions(+), 9 deletions(-) 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 {