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:
@@ -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<HTMLDivElement | null>(null)
|
||||
const observerRef = useRef<IntersectionObserver | null>(null)
|
||||
const dialogRef = useRef<HTMLDivElement>(null)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user