import React from 'react'; import { X, Minus, Plus, ShoppingBag, Trash2 } from 'lucide-react'; import { BillingCycle, BasketItem } from '@/proxy/order/models'; interface CartState { items: BasketItem[]; total: number; globalBillingCycle: BillingCycle; globalPeriod: number; } interface CartProps { isOpen: boolean; onClose: () => void; onCheckout: () => void; cartState: CartState; updateQuantity: (id: string, quantity: number) => void; removeItem: (id: string) => void; clearCart: () => void; } export const Cart: React.FC = ({ isOpen, onClose, onCheckout, cartState, updateQuantity, removeItem, clearCart }) => { const handleClearCart = () => { if (window.confirm('Sepetteki tüm ürünleri silmek istediğinizden emin misiniz?')) { clearCart(); } }; const formatPrice = (price: number) => { return new Intl.NumberFormat('tr-TR', { style: 'currency', currency: 'TRY', minimumFractionDigits: 0 }).format(price); }; if (!isOpen) return null; return (

Sepetim

{cartState.items.length > 0 && ( )}
{cartState.items.length === 0 ? (

Sepetiniz boş

Ürün eklemek için katalogdan seçim yapın

) : (
{cartState.items.map((item: BasketItem, index: number) => (

{item.product.name}

{item.product.isQuantityBased && item.quantity > 1 && ( {item.quantity}x - )} {item.billingCycle === 'monthly' ? 'Aylık' : item.billingCycle === 'yearly' ? 'Yıllık' : 'Aylık'} {cartState.globalPeriod > 1 && item.product.isQuantityBased && ( ({cartState.globalPeriod} {item.billingCycle === 'monthly' ? 'Ay' : 'Yıl'}) )}
{item.product.isQuantityBased && (
{item.quantity}
)}
{formatPrice(item.totalPrice)}
))}
)}
{cartState.items.length > 0 && (
Toplam: {formatPrice(cartState.total)}
)}
); };