'use client'; import { Navigation } from '@/components/ui'; import { useCart } from '@/contexts/CartContext'; import type { EventName } from '@/lib/events'; const dispatchInteraction = (eventName: EventName, productId?: string, metadata?: Record) => { const e = new CustomEvent('definedInteraction', { detail: { eventName, productId, metadata }, }); document.dispatchEvent(e); }; export default function CartPage() { const { items, removeItem, clearCart, itemCount } = useCart(); const handleRemove = (id: string, type: string) => { removeItem(id); dispatchInteraction('remove_item', id, { type }); }; let itemTypes = Array.from(new Set(items.map(item => item.type)))[0] || 'items'; const total = items.reduce((sum, item) => sum + item.price, 0); return ( <>

Shopping Cart

{itemCount > 0 && ( )}
{itemCount === 0 ? (

Your cart is empty

Browse our selection
) : ( <>
{items.map(item => (
{item.type}

{item.name}

{item.type === 'hotel' && (

{String(item.metadata.roomType)}

{String(item.metadata.checkIn)} - {String(item.metadata.checkOut)}

{String(item.metadata.nights)} night{Number(item.metadata.nights) > 1 ? 's' : ''}

)} {item.type === 'airline' && (

{String(item.metadata.cabinClass)} Class

{String((item.metadata.departure as any)?.airport)} → {String((item.metadata.arrival as any)?.airport)}

Duration: {String(item.metadata.duration)}

)}

${item.price}

))}
Total ${total.toFixed(2)}
)}
); }