import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import HotelCardListing from "@/components/HotelReservation/HotelCardListing" import BookingCodeFilter from "@/components/HotelReservation/SelectHotel/BookingCodeFilter" import HotelCount from "@/components/HotelReservation/SelectHotel/HotelCount" import HotelFilter from "@/components/HotelReservation/SelectHotel/HotelFilter" import HotelSorter from "@/components/HotelReservation/SelectHotel/HotelSorter" import MobileMapButtonContainer from "@/components/HotelReservation/SelectHotel/MobileMapButtonContainer" import NoAvailabilityAlert from "@/components/HotelReservation/SelectHotel/NoAvailabilityAlert" import StaticMap from "@/components/Maps/StaticMap" import Link from "@/components/TempDesignSystem/Link" import Subtitle from "@/components/TempDesignSystem/Text/Subtitle" import { getIntl } from "@/i18n" import { getFiltersFromHotels, type HotelResponse } from "./helpers" import styles from "./selectHotel.module.css" import type { Location } from "@/types/trpc/routers/hotel/locations" interface SelectHotelProps { isAlternative?: boolean bookingCode?: string city: Location hotels: HotelResponse[] mapHref: string title: string } export default async function SelectHotel({ bookingCode, city, hotels, isAlternative = false, mapHref, title, }: SelectHotelProps) { const intl = await getIntl() const isAllUnavailable = !hotels.length const isCityWithCountry = (city: any): city is { country: string } => "country" in city const isBookingCodeRateAvailable = bookingCode ? hotels.some( (hotel) => hotel.availability.bookingCode && hotel.availability.status === "Available" ) : false const isFullPriceHotelAvailable = bookingCode ? hotels?.some( (hotel) => !hotel.availability.bookingCode && hotel.availability.status === "Available" ) : false // Special rates (corporate cheque, voucher and reward nights) will not have regular rate hotels availability const isSpecialRate = hotels.some( (hotel) => hotel.availability.productType?.bonusCheque || hotel.availability.productType?.voucher || hotel.availability.productType?.redemptions ) const filterList = getFiltersFromHotels(hotels) const showBookingCodeFilter = isBookingCodeRateAvailable && isFullPriceHotelAvailable && !isSpecialRate return ( <>
{title}
{showBookingCodeFilter ? : null}
{hotels.length ? (
{intl.formatMessage({ defaultMessage: "See map", })}
) : (
)}
) }