import React, { useState } from 'react'; import { Card } from '../ui/card'; import { Button } from '../ui/button'; import { CartItem } from '../commerce/CartItem'; import { PromoCodeModal } from '../commerce/modals/PromoCodeModal'; import { useCart } from '../../context/CartContext'; import { ShoppingCart, ArrowRight, Tag, ShieldCheck, ChevronLeft, } from 'lucide-react'; interface CartViewProps { onCheckout: () => void; onContinueShopping: () => void; } export const CartView: React.FC = ({ onCheckout, onContinueShopping, }) => { const { cart, removeFromCart, cartTotal } = useCart(); const [showPromo, setShowPromo] = useState(false); const [discount, setDiscount] = useState<{ code: string; amount: number; } | null>(null); const discountAmount = discount ? cartTotal * (discount.amount / 100) : 0; const total = cartTotal - discountAmount; const tax = total * 0.08; // Mock tax 8% const finalTotal = total + tax; const handleApplyPromo = (percent: number, code: string) => { setDiscount({ code, amount: percent }); }; if (cart.length === 0) { return (

Your cart is empty

Looks like you haven't added any sounds yet. Explore the marketplace to find your next inspiration.

); } return (

Your Cart ({cart.length})

{/* Cart Items List */}
{cart.map((item) => ( ))}
{/* Summary Sidebar */}

Order Summary

Subtotal ${cartTotal.toFixed(2)}
{discount && (
Discount ({discount.code}) -${discountAmount.toFixed(2)}
)}
Estimated Tax (8%) ${tax.toFixed(2)}
Total ${finalTotal.toFixed(2)}
{!discount && ( )}

Secure Checkout

All transactions are encrypted and secure. We accept major credit cards and crypto.

{showPromo && ( setShowPromo(false)} onApply={handleApplyPromo} /> )}
); };