"use client" import { useState } from "react" import { useIntl } from "react-intl" import { selectRate } from "@scandic-hotels/common/constants/routes/hotelReservation" import Caption from "@scandic-hotels/design-system/Caption" import { FacilityToIcon } from "@scandic-hotels/design-system/FacilityToIcon" import { HotelCardDialogImage } from "@scandic-hotels/design-system/HotelCard/HotelCardDialogImage" import { HotelPointsRow } from "@scandic-hotels/design-system/HotelCard/HotelPointsRow" import { NoPriceAvailableCard } from "@scandic-hotels/design-system/HotelCard/NoPriceAvailableCard" import { IconButton } from "@scandic-hotels/design-system/IconButton" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import Link from "@scandic-hotels/design-system/Link" import { OldDSButton as Button } from "@scandic-hotels/design-system/OldDSButton" import Subtitle from "@scandic-hotels/design-system/Subtitle" import { Typography } from "@scandic-hotels/design-system/Typography" import { useIsLoggedIn } from "../../hooks/useIsLoggedIn" import useLang from "../../hooks/useLang" import styles from "./listingHotelCardDialog.module.css" import type { HotelPin } from "../HotelCardDialogListing/utils" interface ListingHotelCardProps { data: HotelPin handleClose: () => void } export default function ListingHotelCardDialog({ data, handleClose, }: ListingHotelCardProps) { const intl = useIntl() const lang = useLang() const [imageError, setImageError] = useState(false) const isUserLoggedIn = useIsLoggedIn() const { bookingCode, name, publicPrice, memberPrice, currency, amenities, images, ratings, operaId, redemptionPrice, chequePrice, voucherPrice, hasEnoughPoints, } = data const imageSrc = images[0]?.src const altText = images[0]?.altText || images[0]?.altText_En const notEnoughPointsLabel = intl.formatMessage({ defaultMessage: "Not enough points", }) const shouldShowNotEnoughPoints = redemptionPrice && !hasEnoughPoints return (
{name}
{amenities.map((facility) => (
))}
{publicPrice || memberPrice || redemptionPrice || voucherPrice || chequePrice ? (
{redemptionPrice ? ( {intl.formatMessage({ defaultMessage: "Available rates", })} ) : ( {intl.formatMessage({ defaultMessage: "Per night from", })} )}
{publicPrice && !isUserLoggedIn && memberPrice ? ( <> {publicPrice} {currency} {/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */} {memberPrice && /} ) : ( bookingCode && publicPrice && ( {publicPrice} {currency} ) )} {memberPrice && ( {intl.formatMessage( { defaultMessage: "{price} {currency}", }, { price: memberPrice, currency, } )} )} {redemptionPrice && ( )} {chequePrice && ( {intl.formatMessage( { defaultMessage: "{price} {currency}", }, { price: chequePrice.numberOfCheques, currency: "CC", } )} {chequePrice.additionalPricePerStay > 0 ? // eslint-disable-next-line formatjs/no-literal-string-in-jsx " + " + intl.formatMessage( { defaultMessage: "{price} {currency}", }, { price: chequePrice.additionalPricePerStay, currency: chequePrice.currency, } ) : null} {/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */} / {intl.formatMessage({ defaultMessage: "night", })} )} {voucherPrice && ( {intl.formatMessage( { defaultMessage: "{price} {currency}", }, { price: voucherPrice, currency, } )} {/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */} / {intl.formatMessage({ defaultMessage: "night", })} )}
{shouldShowNotEnoughPoints ? (
{notEnoughPointsLabel}
) : ( )}
) : ( )}
) }