Merged in fix/sw-3702-interactive-map-points-currency (pull request #3480)

fix(SW-3702): Show correct point currencies in interactive map

* Show correct point currencies in interactive map


Approved-by: Matilda Haneling
This commit is contained in:
Anton Gunnarsson
2026-01-26 13:38:55 +00:00
parent e215aec8bb
commit e086cd8146
3 changed files with 55 additions and 4 deletions

View File

@@ -28,7 +28,7 @@ export default function HotelCardDialogListing({
defaultMessage: "Points", defaultMessage: "Points",
}) })
: undefined : undefined
const hotelsPinData = getHotelPins(hotels, currencyValue) const hotelsPinData = getHotelPins(hotels, intl, currencyValue)
const activeCardRef = useRef<HTMLDivElement | null>(null) const activeCardRef = useRef<HTMLDivElement | null>(null)
const observerRef = useRef<IntersectionObserver | null>(null) const observerRef = useRef<IntersectionObserver | null>(null)
const dialogRef = useRef<HTMLDivElement>(null) const dialogRef = useRef<HTMLDivElement>(null)

View File

@@ -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 { imageSchema } from "@scandic-hotels/trpc/routers/hotels/schemas/image"
import type { ProductTypeCheque } from "@scandic-hotels/trpc/types/availability" import type { ProductTypeCheque } from "@scandic-hotels/trpc/types/availability"
import type { Amenities } from "@scandic-hotels/trpc/types/hotel" import type { Amenities } from "@scandic-hotels/trpc/types/hotel"
import type { IntlShape } from "react-intl"
import type { z } from "zod" import type { z } from "zod"
import type { HotelResponse } from "../SelectHotel/helpers" import type { HotelResponse } from "../SelectHotel/helpers"
@@ -34,6 +36,7 @@ export type HotelPin = {
export function getHotelPins( export function getHotelPins(
hotels: HotelResponse[], hotels: HotelResponse[],
intl: IntlShape,
currencyValue?: string currencyValue?: string
): HotelPin[] { ): HotelPin[] {
if (!hotels.length) { if (!hotels.length) {
@@ -50,6 +53,14 @@ export function getHotelPins(
if (chequePrice || voucherPrice) { if (chequePrice || voucherPrice) {
currencyValue = chequePrice ? "CC" : "Voucher" currencyValue = chequePrice ? "CC" : "Voucher"
} }
const redemptionPrice = redemptionRate?.localPrice.pointsPerStay ?? null
const redemptionCurrency = getRedemptionCurrencyText(
redemptionPrice,
redemptionRate?.localPrice.pointsType ?? null,
intl
)
return { return {
bookingCode: availability.bookingCode, bookingCode: availability.bookingCode,
coordinates: { coordinates: {
@@ -60,7 +71,7 @@ export function getHotelPins(
chequePrice: chequePrice ?? null, chequePrice: chequePrice ?? null,
publicPrice: productType?.public?.localPrice.pricePerNight ?? null, publicPrice: productType?.public?.localPrice.pricePerNight ?? null,
memberPrice: productType?.member?.localPrice.pricePerNight ?? null, memberPrice: productType?.member?.localPrice.pricePerNight ?? null,
redemptionPrice: redemptionRate?.localPrice.pointsPerStay ?? null, redemptionPrice,
pointsType: redemptionRate?.localPrice.pointsType ?? null, pointsType: redemptionRate?.localPrice.pointsType ?? null,
voucherPrice: voucherPrice ?? null, voucherPrice: voucherPrice ?? null,
rateType: rateType:
@@ -68,6 +79,7 @@ export function getHotelPins(
currency: currency:
productType?.public?.localPrice.currency || productType?.public?.localPrice.currency ||
productType?.member?.localPrice.currency || productType?.member?.localPrice.currency ||
redemptionCurrency ||
currencyValue || currencyValue ||
"N/A", "N/A",
images: [ 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
}
}
}

View File

@@ -91,7 +91,7 @@ export function SelectHotelMapContent({
(state) => state.activeCodeFilter (state) => state.activeCodeFilter
) )
const hotelPins = getHotelPins(hotels) const hotelPins = getHotelPins(hotels, intl)
const coordinates = useMemo(() => { const coordinates = useMemo(() => {
if (hotelMapStore.activeHotel) { if (hotelMapStore.activeHotel) {