productAssignment (1)
productAssignment (1)
ProductList Component
function ProductList() {
dispatch(addToCart(id));
};
dispatch(removeFromCart(id));
};
return (
<div className="product-list">
<h2>Product Listing</h2>
<div className="products">
{products.map((product) => (
<h3>{product.name}</h3>
<p>${product.price}</p>
<div className="product-actions">
</div>
</div>
))}
</div>
</div>
);
2. CartSidebar Component
function CartSidebar() {
);
return (
<div className="cart-sidebar">
<h3>Shopping Cart</h3>
<ul>
{products
.filter((product) => product.quantity > 0)
.map((product) => (
<li key={product.id}>
</li>
))}
</ul>
<h4>Total: ${totalPrice}</h4>
</div>
);
3. CheckoutButton Component
function CheckoutButton() {
);
};
return (
<div>
Checkout
</button>
</div>
);
function App() {
return (
<div className="app">
<div className="main-content">
<ProductList />
<CartSidebar />
</div>
<CheckoutButton />
</div>
);
}
export default App;