"use client" import { useEffect } from "react" import { useIntl } from "react-intl" import useRoomAvailableStore from "@/stores/roomAvailability" import { mapFacilityToIcon } from "@/components/ContentType/HotelPage/data" import ImageGallery from "@/components/ImageGallery" import Alert from "@/components/TempDesignSystem/Alert" import Divider from "@/components/TempDesignSystem/Divider" import Body from "@/components/TempDesignSystem/Text/Body" import Caption from "@/components/TempDesignSystem/Text/Caption" import Title from "@/components/TempDesignSystem/Text/Title" import ReadMore from "../../ReadMore" import TripAdvisorChip from "../../TripAdvisorChip" import styles from "./hotelInfoCard.module.css" import type { HotelInfoCardProps } from "@/types/components/hotelReservation/selectRate/hotelInfoCardProps" import { AlertTypeEnum } from "@/types/enums/alert" export default function HotelInfoCard({ hotelData, noAvailability = false, }: HotelInfoCardProps) { const hotelAttributes = hotelData?.data.attributes const intl = useIntl() const noRoomsAvailable = useRoomAvailableStore( (state) => state.noRoomsAvailable ) const setNoRoomsAvailable = useRoomAvailableStore( (state) => state.setNoRoomsAvailable ) const sortedFacilities = hotelAttributes?.detailedFacilities .sort((a, b) => b.sortOrder - a.sortOrder) .slice(0, 5) useEffect(() => { if (noAvailability) { setNoRoomsAvailable() } }, [noAvailability, setNoRoomsAvailable]) return (
{hotelAttributes && (
{hotelAttributes.ratings?.tripAdvisor && ( )}
{hotelAttributes.name}
{`${hotelAttributes.address.streetAddress}, ${hotelAttributes.address.city} ∙ ${hotelAttributes.location.distanceToCentre} ${intl.formatMessage({ id: "km to city center" })}`} {hotelAttributes.hotelContent.texts.descriptions.medium}
{intl.formatMessage({ id: "At the hotel" })} {sortedFacilities?.map((facility) => { const IconComponent = mapFacilityToIcon(facility.id) return (
{IconComponent && ( )} {facility.name}
) })}
)} {hotelAttributes?.specialAlerts.map((alert) => { return (
) })} {noRoomsAvailable ? (
) : null}
) }