feat(SW-2863): Move contentstack router to trpc package * Add exports to packages and lint rule to prevent relative imports * Add env to trpc package * Add eslint to trpc package * Apply lint rules * Use direct imports from trpc package * Add lint-staged config to trpc * Move lang enum to common * Restructure trpc package folder structure * WIP first step * update internal imports in trpc * Fix most errors in scandic-web Just 100 left... * Move Props type out of trpc * Fix CategorizedFilters types * Move more schemas in hotel router * Fix deps * fix getNonContentstackUrls * Fix import error * Fix entry error handling * Fix generateMetadata metrics * Fix alertType enum * Fix duplicated types * lint:fix * Merge branch 'master' into feat/sw-2863-move-contentstack-router-to-trpc-package * Fix broken imports * Merge branch 'master' into feat/sw-2863-move-contentstack-router-to-trpc-package Approved-by: Linus Flood
72 lines
2.0 KiB
TypeScript
72 lines
2.0 KiB
TypeScript
import type { AdditionalData, Hotel } from "@scandic-hotels/trpc/types/hotel"
|
|
import type { IntlShape } from "react-intl"
|
|
|
|
import type { HotelListing } from "@/types/trpc/routers/contentstack/blocks"
|
|
|
|
export function getTypeSpecificInformation(
|
|
intl: IntlShape,
|
|
contentType: HotelListing["contentType"],
|
|
hotelContent: Hotel["hotelContent"],
|
|
additionalData: AdditionalData,
|
|
url: string | null
|
|
) {
|
|
const { images, texts } = hotelContent
|
|
const { descriptions, meetingDescription } = texts
|
|
const { conferencesAndMeetings, restaurantsOverviewPage, restaurantImages } =
|
|
additionalData
|
|
const data = {
|
|
description: descriptions?.short,
|
|
image: {
|
|
src: images.imageSizes.small,
|
|
alt: images.metaData.altText,
|
|
},
|
|
cta: {
|
|
text: intl.formatMessage({
|
|
defaultMessage: "See hotel details",
|
|
}),
|
|
url,
|
|
openInNewTab: false,
|
|
},
|
|
}
|
|
switch (contentType) {
|
|
case "meeting":
|
|
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({
|
|
defaultMessage: "Book a meeting",
|
|
}),
|
|
url: meetingUrl,
|
|
openInNewTab: true,
|
|
}
|
|
}
|
|
return data
|
|
case "restaurant":
|
|
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 data
|
|
}
|
|
}
|