refactor(SW-96): use images from API & reduce data returned in getHotel
This commit is contained in:
30
server/routers/utils/hotels.ts
Normal file
30
server/routers/utils/hotels.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { ImageItem } from "@/types/components/lightbox/lightbox"
|
||||
import { Hotel } from "@/types/hotel"
|
||||
|
||||
export function extractHotelImages(hotelData: Hotel): ImageItem[] {
|
||||
const images: ImageItem[] = []
|
||||
|
||||
if (hotelData.hotelContent?.images) {
|
||||
images.push({
|
||||
url: hotelData.hotelContent.images.imageSizes.large,
|
||||
alt: hotelData.hotelContent.images.metaData.altText,
|
||||
title:
|
||||
hotelData.hotelContent.images.metaData.title ||
|
||||
hotelData.hotelContent.images.metaData.altText,
|
||||
})
|
||||
}
|
||||
|
||||
if (hotelData.healthFacilities) {
|
||||
hotelData.healthFacilities.forEach((facility: any) => {
|
||||
facility.content.images.forEach((image: any) => {
|
||||
images.push({
|
||||
url: image.imageSizes.large,
|
||||
alt: image.metaData.altText,
|
||||
title: image.metaData.title || image.metaData.altText,
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return images
|
||||
}
|
||||
Reference in New Issue
Block a user