"use client" import { useParams } from "next/dist/client/components/navigation" import { memo, useCallback } from "react" import { useIntl } from "react-intl" import { selectRate } from "@/constants/routes/hotelReservation" import { useHotelsMapStore } from "@/stores/hotels-map" import { mapFacilityToIcon } from "@/components/ContentType/HotelPage/data" import { PriceTagIcon } from "@/components/Icons" import HotelLogo from "@/components/Icons/Logos" import ImageGallery from "@/components/ImageGallery" import Button from "@/components/TempDesignSystem/Button" import Divider from "@/components/TempDesignSystem/Divider" import Link from "@/components/TempDesignSystem/Link" import Body from "@/components/TempDesignSystem/Text/Body" import Caption from "@/components/TempDesignSystem/Text/Caption" import Subtitle from "@/components/TempDesignSystem/Text/Subtitle" import { mapApiImagesToGalleryImages } from "@/utils/imageGallery" import { getSingleDecimal } from "@/utils/numberFormatting" import ReadMore from "../ReadMore" import TripAdvisorChip from "../TripAdvisorChip" import HotelPriceCard from "./HotelPriceCard" import NoPriceAvailableCard from "./NoPriceAvailableCard" import { hotelCardVariants } from "./variants" import styles from "./hotelCard.module.css" import { HotelCardListingTypeEnum } from "@/types/components/hotelReservation/selectHotel/hotelCardListingProps" import type { HotelCardProps } from "@/types/components/hotelReservation/selectHotel/hotelCardProps" import type { Lang } from "@/constants/languages" function HotelCard({ hotel, isUserLoggedIn, state = "default", type = HotelCardListingTypeEnum.PageListing, bookingCode = "", }: HotelCardProps) { const params = useParams() const lang = params.lang as Lang const intl = useIntl() const { setActiveHotelPin, setActiveHotelCard } = useHotelsMapStore() const { hotelData } = hotel const { price } = hotel const handleMouseEnter = useCallback(() => { if (hotelData) { setActiveHotelPin(hotelData.name) } }, [setActiveHotelPin, hotelData]) const handleMouseLeave = useCallback(() => { if (hotelData) { setActiveHotelPin(null) setActiveHotelCard(null) } }, [setActiveHotelPin, hotelData, setActiveHotelCard]) if (!hotel || !hotelData) return null const amenities = hotelData.detailedFacilities.slice(0, 5) const classNames = hotelCardVariants({ type, state, }) const addressStr = `${hotelData.address.streetAddress}, ${hotelData.address.city}` const galleryImages = mapApiImagesToGalleryImages( hotelData.galleryImages || [] ) const fullPrice = hotel.price?.public?.rateType?.toLowerCase() === "regular" return (
{hotelData.ratings?.tripAdvisor && ( )}
{hotelData.name}
{addressStr}
{addressStr}
{intl.formatMessage( { id: "{number} km to city center" }, { number: getSingleDecimal( hotelData.location.distanceToCentre / 1000 ), } )}
{hotelData.hotelContent.texts.descriptions.short}
{amenities.map((facility) => { const IconComponent = mapFacilityToIcon(facility.id) return (
{IconComponent && } {facility.name}
) })}
{!price ? ( ) : ( <> {bookingCode && ( {bookingCode} )} {(!isUserLoggedIn || (bookingCode && !fullPrice)) && price.public && ( )} {price.member && ( )} )}
) } export default memo(HotelCard)