import "./CartPage.css"; import { CartButton } from "./ProductPaga"; import { useContext, useEffect, useState } from "react"; import CartContext from "../ContextApi/CartContext"; const CartPage = () => { const { productList } = useContext(CartContext); function getTotalPrice() { let totalPrice = 0; for (let i = 0; i < productList.length; i++) { totalPrice += parseInt(productList[i].price); } return totalPrice; } return (

{ productList.length > 0 ? ('Shopping Cart') : ('Your Amazon Cart is empty.') }

{productList.map((product) => ( ))}

Subtotal ({productList.length} items):$ {getTotalPrice()}

Your order is eligible for FREE Delivery. {" "} Select this option at checkout. Details

Subtotal ({productList.length} items):$ {getTotalPrice()}

); }; export default CartPage; const Cart = (props) => { const { id, name, price, status, image } = props; const { removeCart, handleQytChange } = useContext(CartContext); return (

{name}

in {status} Eligible for FREE Shipping Colour : Midnight Blue Size: 4GB + 64GB
removeCart(id)}> Delete Save for later See more like this Share
$ {price}
); };