import React from 'react' import { FaTimes, FaMinus, FaPlus, FaShoppingBag, FaTrash } from 'react-icons/fa' import { BillingCycle, BasketItem } from '@/proxy/order/models' import { useLocalization } from '@/utils/hooks/useLocalization' 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 { translate } = useLocalization() 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 (

{translate('::Public.cart.title')}

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

{translate('::Public.cart.empty.title')}

{translate('::Public.cart.empty.subtitle')}

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

{translate('::' + item.product.name)}

{item.product.isQuantityBased && item.quantity > 1 && ( {item.quantity}x - )} {item.billingCycle === 'monthly' ? translate('::Public.cart.monthly') : item.billingCycle === 'yearly' ? translate('::Public.cart.yearly') : translate('::Public.cart.monthly')} {cartState.globalPeriod > 1 && item.product.isQuantityBased && ( ({cartState.globalPeriod}{' '} {item.billingCycle === 'monthly' ? translate('::Public.cart.month') : translate('::Public.cart.year')} ) )}
{item.product.isQuantityBased && (
{item.quantity}
)}
{formatPrice(item.totalPrice)}
))}
)}
{cartState.items.length > 0 && (
{translate('::Public.cart.total')} {formatPrice(cartState.total)}
)}
) }