'use client'; import type { EventName } from '@/lib/events'; import type { Hotel } from '@/lib/hotel-utils'; import { getHotelImageUrl } from '@/lib/hotel-utils'; import { useHoverTracking } from '@/hooks/useHoverTracking'; import PriceDisplay from '@/components/ui/PriceDisplay'; const dispatchInteraction = (eventName: EventName, productId?: string, metadata?: Record) => { const e = new CustomEvent('definedInteraction', { detail: { eventName, productId, metadata }, }); document.dispatchEvent(e); }; const AmenityIcon = ({ name }: { name: string }) => { const iconMap: Record = { wifi: 'Wi-Fi', pool: 'Pool', gym: 'Gym', parking: 'Parking', breakfast: 'Breakfast', spa: 'Spa', }; return {iconMap[name.toLowerCase()] || name.replaceAll("_", " ")}; }; export default function HotelCard({ hotel }: { hotel: Hotel }) { const titleRef = useHoverTracking({ eventName: 'hover_over_title', productId: hotel.id, metadata: { elementText: hotel.name, dateIndex: hotel.dateIndex }, }); const priceRef = useHoverTracking({ eventName: 'hover_over_paragraph', productId: hotel.id, metadata: { elementText: 'price', dateIndex: hotel.dateIndex }, }); const handleCardClick = () => { dispatchInteraction('view_item_page', hotel.id, { roomType: hotel.roomType, price: hotel.pricePerNight, nights: hotel.nights, dateIndex: hotel.dateIndex, }); window.location.href = `/hotel/products/${hotel.id}`; }; return (
{hotel.name} { e.currentTarget.style.display = 'none'; const fallback = e.currentTarget.nextElementSibling as HTMLElement; if (fallback) fallback.style.display = 'flex'; }} />
Image

{hotel.name}

{hotel.checkIn} - {hotel.checkOut}
{hotel.amenities.map((a) => ( ))}
Total for {hotel.nights} night{hotel.nights > 1 ? 's' : ''}
); }