43 lines
1.4 KiB
TypeScript
43 lines
1.4 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 }) => {
|
|
const productType = availability.productType
|
|
return {
|
|
coordinates: {
|
|
lat: hotel.location.latitude,
|
|
lng: hotel.location.longitude,
|
|
},
|
|
name: hotel.name,
|
|
publicPrice: productType?.public?.localPrice.pricePerNight ?? null,
|
|
memberPrice: productType?.member?.localPrice.pricePerNight ?? null,
|
|
redemptionPrice: productType?.redemption?.localPrice.pointsPerNight ?? 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, ...(hotel.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),
|
|
}
|
|
})
|
|
}
|