feat(SW-1464): Added meeting url instead of hotel url for hotellisting with meeting information

Approved-by: Matilda Landström
This commit is contained in:
Erik Tiekstra
2025-03-18 07:01:56 +00:00
parent d5b47be2f2
commit da3a7c1865
11 changed files with 85 additions and 33 deletions

View File

@@ -1,36 +1,67 @@
import type { Hotel } from "@/types/hotel"
import type { IntlShape } from "react-intl"
import type { AdditionalData, Hotel } from "@/types/hotel"
import type { HotelListing } from "@/types/trpc/routers/contentstack/blocks"
export function getTypeSpecificInformation(
intl: IntlShape,
contentType: HotelListing["contentType"],
hotel: Hotel
hotelContent: Hotel["hotelContent"],
additionalData: AdditionalData,
url: string | null
) {
const { images } = hotel.hotelContent
const { descriptions, meetingDescription } = hotel.hotelContent.texts
const hotelData = {
const { images, texts } = hotelContent
const { descriptions, meetingDescription } = texts
const { conferencesAndMeetings, restaurantsOverviewPage, restaurantImages } =
additionalData
const data = {
description: descriptions?.short,
imageSrc: images.imageSizes.small,
altText: images.metaData.altText,
image: {
src: images.imageSizes.small,
alt: images.metaData.altText,
},
cta: {
text: intl.formatMessage({ id: "See hotel details" }),
url,
openInNewTab: false,
},
}
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,
const meetingImage = conferencesAndMeetings?.heroImages[0]
const meetingUrl = additionalData.meetingRooms.meetingOnlineLink
if (meetingDescription?.short) {
data.description = meetingDescription.short
}
if (meetingImage) {
data.image = {
src: meetingImage.imageSizes.small,
alt: meetingImage.metaData.altText,
}
}
if (meetingUrl) {
data.cta = {
text: intl.formatMessage({ id: "Book a meeting" }),
url: meetingUrl,
openInNewTab: true,
}
}
return data
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,
const restaurantImage = restaurantImages?.heroImages[0]
if (restaurantsOverviewPage.restaurantsContentDescriptionShort) {
data.description =
restaurantsOverviewPage.restaurantsContentDescriptionShort
}
if (restaurantImage) {
data.image = {
src: restaurantImage.imageSizes.small,
alt: restaurantImage.metaData.altText,
}
}
return data
case "hotel":
default:
return hotelData
return data
}
}