Implementing the ShoppingCart component
As we venture into the implementation of the ShoppingCart
component, we will aim to provide a seamless interface for users to review their selected items before proceeding to the checkout. Besides displaying the items, we also intend to reward our customers with some appealing discount policies.
In Chapter 7, we defined a rudimentary ShoppingCart
component, as shown here:
export const ShoppingCart = ({ cartItems }: { cartItems: string[] }) => { return ( <div data-testid="shopping-cart"> <ol> {cartItems.map((item) => ( <li key={item}>{item}</li> ))} </ol> <button disabled={cartItems.length === 0...