Files
web/components/Blocks/HotelListing/HotelListingItem/utils.ts
Matilda Landström 577a4ca35e Merged in feat/SW-1333-hotel-endpoint (pull request #1206)
Feat(SW-133): Add additionalData endpoint

Approved-by: Erik Tiekstra
Approved-by: Fredrik Thorsson
2025-01-27 11:39:13 +00:00

37 lines
1.3 KiB
TypeScript

import type { Hotel } from "@/types/hotel"
import type { HotelListing } from "@/types/trpc/routers/contentstack/blocks"
export function getTypeSpecificInformation(
contentType: HotelListing["contentType"],
hotel: Hotel
) {
const { images } = hotel.hotelContent
const { descriptions, meetingDescription } = hotel.hotelContent.texts
const hotelData = {
description: descriptions.short,
imageSrc: images.imageSizes.small,
altText: images.metaData.altText,
}
switch (contentType) {
case "meeting":
const meetingImage = hotel.conferencesAndMeetings?.heroImages[0]
return {
description: meetingDescription?.short || hotelData.description,
imageSrc: meetingImage?.imageSizes.small || hotelData.imageSrc,
altText: meetingImage?.metaData.altText || hotelData.altText,
}
case "restaurant":
const restaurantImage = hotel.restaurantImages?.heroImages[0]
return {
description:
hotel.hotelContent.restaurantsOverviewPage
.restaurantsContentDescriptionShort || hotelData.description,
imageSrc: restaurantImage?.imageSizes.small || hotelData.imageSrc,
altText: restaurantImage?.metaData.altText || hotelData.altText,
}
case "hotel":
default:
return hotelData
}
}