Files
web/apps/scandic-web/components/HotelReservation/HotelCardDialogListing/utils.ts
Bianca Widstam 9e3d82b62c Merged in fix/SW-2739-map-reward-night-not-enough-points (pull request #2435)
fix(SW-2739): remove tooltip and add correct CTA on map for reward nights

* fix(SW-2739): remove tooltip and add correct CTA on map for reward nights

* fix(SW-2739): fix pr comment


Approved-by: Arvid Norlin
2025-06-25 13:30:43 +00:00

60 lines
2.0 KiB
TypeScript

import type { HotelPin } from "@/types/components/hotelReservation/selectHotel/map"
import type { HotelResponse } from "@/components/HotelReservation/SelectHotel/helpers"
export function getHotelPins(
hotels: HotelResponse[],
currencyValue?: string
): HotelPin[] {
if (!hotels.length) {
return []
}
return hotels.map(({ availability, hotel, additionalData }) => {
const productType = availability.productType
const redemptionRate = productType?.redemptions?.find(
(r) => r?.localPrice.pointsPerStay
)
const chequePrice = productType?.bonusCheque?.localPrice
const voucherPrice = productType?.voucher?.numberOfVouchers
if (chequePrice || voucherPrice) {
currencyValue = chequePrice ? "CC" : "Voucher"
}
return {
bookingCode: availability.bookingCode,
coordinates: {
lat: hotel.location.latitude,
lng: hotel.location.longitude,
},
name: hotel.name,
chequePrice: chequePrice ?? null,
publicPrice: productType?.public?.localPrice.pricePerNight ?? null,
memberPrice: productType?.member?.localPrice.pricePerNight ?? null,
redemptionPrice: redemptionRate?.localPrice.pointsPerStay ?? null,
voucherPrice: voucherPrice ?? null,
rateType:
productType?.public?.rateType ?? productType?.member?.rateType ?? null,
currency:
productType?.public?.localPrice.currency ||
productType?.member?.localPrice.currency ||
currencyValue ||
"N/A",
images: [
hotel.hotelContent.images,
...(additionalData.gallery?.heroImages ?? []),
],
amenities: hotel.detailedFacilities
.map((facility) => ({
...facility,
icon: facility.icon ?? "None",
}))
.slice(0, 5),
ratings: hotel.ratings?.tripAdvisor.rating ?? null,
operaId: hotel.operaId,
facilityIds: hotel.detailedFacilities.map((facility) => facility.id),
hasEnoughPoints: !!availability.productType?.redemptions?.some(
(r) => r.hasEnoughPoints
),
}
})
}