import { useState } from 'react'; export default function Cart({ isOpen, onClose, cartItems, onRemoveFromCart, onUpdateQuantity }) { const [isLoading, setIsLoading] = useState(false); const subtotal = cartItems.reduce((acc, item) => acc + item.price * item.quantity, 0); const shipping = subtotal > 35 ? 0 : 5.99; const total = subtotal + shipping; const handleCheckout = async () => { setIsLoading(true); // Simulate checkout await new Promise(resolve => setTimeout(resolve, 2000)); setIsLoading(false); alert('Thank you for your order! This is a demo.'); }; if (!isOpen) return null; return ( <> {/* Backdrop */}
{/* Cart Sidebar */}Looks like you haven't added anything yet
${item.price.toFixed(2)}
In Stock
{/* Quantity Controls */}Add ${(35 - subtotal).toFixed(2)} more for FREE shipping
)}