"use client" import { useState } from "react" import { useIntl } from "react-intl" import { selectRate } from "@scandic-hotels/common/constants/routes/hotelReservation" import { formatPrice } from "@scandic-hotels/common/utils/numberFormatting" import ButtonLink from "@scandic-hotels/design-system/ButtonLink" 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 { 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, pointsType, chequePrice, voucherPrice, hasEnoughPoints, } = data const imageSrc = images[0]?.src const altText = images[0]?.altText || images[0]?.altText_En const notEnoughPointsLabel = intl.formatMessage({ id: "booking.notEnoughPoints", defaultMessage: "Not enough points", }) const shouldShowNotEnoughPoints = redemptionPrice && !hasEnoughPoints const label = redemptionPrice ? intl.formatMessage({ id: "hotelCard.availableRates", defaultMessage: "Available rates", }) : chequePrice || voucherPrice ? intl.formatMessage({ id: "common.from", defaultMessage: "From", }) : intl.formatMessage({ id: "listingHotelCardDialog.perNightFrom", defaultMessage: "Per night from", }) return (

{name}

{amenities.map((facility) => (
))}
{publicPrice || memberPrice || redemptionPrice || voucherPrice || chequePrice ? (

{label}

{publicPrice && !isUserLoggedIn ? ( <>

{publicPrice} {currency}

{memberPrice && ( {/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}

/

)} ) : ( bookingCode && publicPrice && (

{publicPrice} {currency}

) )} {memberPrice && (

{intl.formatMessage( { id: "common.priceCurrency", defaultMessage: "{price} {currency}", }, { price: memberPrice, currency, } )}

)} {redemptionPrice && ( )} {chequePrice && ( <> {intl.formatMessage( { id: "common.priceCurrency", defaultMessage: "{price} {currency}", }, { price: chequePrice.numberOfCheques, currency: "CC", } )} {chequePrice.additionalPricePerStay > 0 ? // eslint-disable-next-line formatjs/no-literal-string-in-jsx " + " + intl.formatMessage( { id: "common.priceCurrency", defaultMessage: "{price} {currency}", }, { price: chequePrice.additionalPricePerStay, currency: chequePrice.currency, } ) : null} )} {voucherPrice && ( <>

{formatPrice(intl, voucherPrice, currency)}

)}
{shouldShowNotEnoughPoints ? (
{notEnoughPointsLabel}
) : ( {intl.formatMessage({ id: "common.seeRooms", defaultMessage: "See rooms", })} )}
) : ( )}
) }