37 lines
1.3 KiB
TypeScript
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 { restaurantsOverviewPage, 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:
|
|
restaurantsOverviewPage.restaurantsContentDescriptionShort ||
|
|
hotelData.description,
|
|
imageSrc: restaurantImage?.imageSizes.small || hotelData.imageSrc,
|
|
altText: restaurantImage?.metaData.altText || hotelData.altText,
|
|
}
|
|
case "hotel":
|
|
default:
|
|
return hotelData
|
|
}
|
|
}
|