diff --git a/packages/booking-flow/lib/components/HotelCardDialogListing/index.tsx b/packages/booking-flow/lib/components/HotelCardDialogListing/index.tsx index 752d10d11..0d248f25a 100644 --- a/packages/booking-flow/lib/components/HotelCardDialogListing/index.tsx +++ b/packages/booking-flow/lib/components/HotelCardDialogListing/index.tsx @@ -28,7 +28,7 @@ export default function HotelCardDialogListing({ defaultMessage: "Points", }) : undefined - const hotelsPinData = getHotelPins(hotels, currencyValue) + const hotelsPinData = getHotelPins(hotels, intl, currencyValue) const activeCardRef = useRef(null) const observerRef = useRef(null) const dialogRef = useRef(null) diff --git a/packages/booking-flow/lib/components/HotelCardDialogListing/utils.ts b/packages/booking-flow/lib/components/HotelCardDialogListing/utils.ts index 63fb3ceae..5a1d501a4 100644 --- a/packages/booking-flow/lib/components/HotelCardDialogListing/utils.ts +++ b/packages/booking-flow/lib/components/HotelCardDialogListing/utils.ts @@ -1,7 +1,9 @@ -import type { PointType } from "@scandic-hotels/common/constants/pointType" +import { PointType } from "@scandic-hotels/common/constants/pointType" + import type { imageSchema } from "@scandic-hotels/trpc/routers/hotels/schemas/image" import type { ProductTypeCheque } from "@scandic-hotels/trpc/types/availability" import type { Amenities } from "@scandic-hotels/trpc/types/hotel" +import type { IntlShape } from "react-intl" import type { z } from "zod" import type { HotelResponse } from "../SelectHotel/helpers" @@ -34,6 +36,7 @@ export type HotelPin = { export function getHotelPins( hotels: HotelResponse[], + intl: IntlShape, currencyValue?: string ): HotelPin[] { if (!hotels.length) { @@ -50,6 +53,14 @@ export function getHotelPins( if (chequePrice || voucherPrice) { currencyValue = chequePrice ? "CC" : "Voucher" } + + const redemptionPrice = redemptionRate?.localPrice.pointsPerStay ?? null + const redemptionCurrency = getRedemptionCurrencyText( + redemptionPrice, + redemptionRate?.localPrice.pointsType ?? null, + intl + ) + return { bookingCode: availability.bookingCode, coordinates: { @@ -60,7 +71,7 @@ export function getHotelPins( chequePrice: chequePrice ?? null, publicPrice: productType?.public?.localPrice.pricePerNight ?? null, memberPrice: productType?.member?.localPrice.pricePerNight ?? null, - redemptionPrice: redemptionRate?.localPrice.pointsPerStay ?? null, + redemptionPrice, pointsType: redemptionRate?.localPrice.pointsType ?? null, voucherPrice: voucherPrice ?? null, rateType: @@ -68,6 +79,7 @@ export function getHotelPins( currency: productType?.public?.localPrice.currency || productType?.member?.localPrice.currency || + redemptionCurrency || currencyValue || "N/A", images: [ @@ -89,3 +101,42 @@ export function getHotelPins( } }) } + +function getRedemptionCurrencyText( + points: number | null, + pointsType: PointType | null, + intl: IntlShape +) { + if (points === null || pointsType === null) return null + + switch (pointsType) { + case PointType.SCANDIC: { + return intl.formatMessage( + { + id: "price.numberOfScandicPoints", + defaultMessage: + "{numberOfScandicPoints, plural, one {Point} other {Points}}", + }, + { + numberOfScandicPoints: points, + } + ) + } + case PointType.EUROBONUS: { + return intl.formatMessage( + { + id: "price.numberOfEuroBonusPoints", + defaultMessage: + "{numberOfEuroBonusPoints, plural, one {EB Point} other {EB Points}}", + }, + { + numberOfEuroBonusPoints: points, + } + ) + } + default: { + const _exhaustiveCheck: never = pointsType + return null + } + } +} diff --git a/packages/booking-flow/lib/components/SelectHotel/SelectHotelMap/SelectHotelMapContent/index.tsx b/packages/booking-flow/lib/components/SelectHotel/SelectHotelMap/SelectHotelMapContent/index.tsx index b6abd010c..0e0603eda 100644 --- a/packages/booking-flow/lib/components/SelectHotel/SelectHotelMap/SelectHotelMapContent/index.tsx +++ b/packages/booking-flow/lib/components/SelectHotel/SelectHotelMap/SelectHotelMapContent/index.tsx @@ -91,7 +91,7 @@ export function SelectHotelMapContent({ (state) => state.activeCodeFilter ) - const hotelPins = getHotelPins(hotels) + const hotelPins = getHotelPins(hotels, intl) const coordinates = useMemo(() => { if (hotelMapStore.activeHotel) {