140 lines
3.8 KiB
TypeScript
140 lines
3.8 KiB
TypeScript
import {
|
|
meetingsAndConferences,
|
|
restaurantAndBar,
|
|
wellnessAndExercise,
|
|
} from "@/constants/routes/hotelPageParams"
|
|
|
|
import { getIntl } from "@/i18n"
|
|
import { getLang } from "@/i18n/serverContext"
|
|
|
|
import {
|
|
type Facilities,
|
|
type Facility as f,
|
|
facilityEnum,
|
|
} from "@/types/components/hotelPage/facilities"
|
|
import type { ImageVaultAsset } from "@/types/components/imageVault"
|
|
import type { CardProps } from "@/components/TempDesignSystem/Card/card"
|
|
import type { Facility } from "@/server/routers/hotels/output"
|
|
|
|
type ActivityCard = {
|
|
background_image?: ImageVaultAsset
|
|
scripted_title?: string
|
|
heading: string
|
|
body_text: string
|
|
cta_text: string
|
|
contentPage: Array<{ href: string }>
|
|
}
|
|
|
|
export function setActivityCard(activitiesCard: ActivityCard): f {
|
|
const hasImage = activitiesCard.background_image
|
|
return [
|
|
{
|
|
id: "activities",
|
|
theme: hasImage ? "image" : "primaryDark",
|
|
scriptedTopTitle: activitiesCard.scripted_title,
|
|
heading: activitiesCard.heading,
|
|
bodyText: activitiesCard.body_text,
|
|
backgroundImage: hasImage ? activitiesCard.background_image : undefined,
|
|
primaryButton: hasImage
|
|
? {
|
|
href: activitiesCard.contentPage[0].href,
|
|
title: activitiesCard.cta_text,
|
|
isExternal: false,
|
|
}
|
|
: undefined,
|
|
secondaryButton: hasImage
|
|
? undefined
|
|
: {
|
|
href: activitiesCard.contentPage[0].href,
|
|
title: activitiesCard.cta_text,
|
|
isExternal: false,
|
|
},
|
|
},
|
|
]
|
|
}
|
|
|
|
export async function setFacilityCards(facilities: Array<Facility>) {
|
|
const lang = getLang()
|
|
const intl = await getIntl()
|
|
|
|
let cards: Facilities = [],
|
|
card: CardProps,
|
|
img: CardProps,
|
|
grid: Array<CardProps>
|
|
|
|
facilities.map((facility) => {
|
|
card = {}
|
|
grid = []
|
|
|
|
card.scriptedTopTitle = facility.headingText ?? "Fallback title"
|
|
|
|
facility.heroImages.map((image) => {
|
|
img = {}
|
|
;(img.backgroundImage = {
|
|
url: image.imageSizes.large,
|
|
title: image.metaData.title,
|
|
meta: {
|
|
alt: image.metaData.altText,
|
|
caption: image.metaData.altText_En,
|
|
},
|
|
}),
|
|
(img.theme = "image")
|
|
grid.push(img)
|
|
})
|
|
|
|
switch (facility.id) {
|
|
case facilityEnum.wellness:
|
|
card.theme = "one"
|
|
card.id = "wellness-and-exercise"
|
|
;(card.heading = intl.formatMessage({ id: "Sauna and gym" })),
|
|
(card.secondaryButton = {
|
|
href: `?s=${wellnessAndExercise[lang]}`,
|
|
title: intl.formatMessage({
|
|
id: "Read more about wellness & exercise",
|
|
}),
|
|
isExternal: false,
|
|
})
|
|
grid.unshift(card)
|
|
break
|
|
|
|
case facilityEnum.conference:
|
|
card.theme = "primaryDim"
|
|
card.id = "meetings-and-conferences"
|
|
;(card.heading = intl.formatMessage({
|
|
id: "Events that make an impression",
|
|
})),
|
|
(card.secondaryButton = {
|
|
href: `?s=${meetingsAndConferences[lang]}`,
|
|
title: intl.formatMessage({ id: "About meetings & conferences" }),
|
|
isExternal: false,
|
|
})
|
|
grid.push(card)
|
|
break
|
|
|
|
case facilityEnum.restaurant:
|
|
card.theme = "primaryDark"
|
|
card.id = "restaurant-and-bar"
|
|
card.heading = intl.formatMessage({
|
|
id: "Enjoy relaxed restaurant experiences",
|
|
})
|
|
card.secondaryButton = {
|
|
href: `?s=${restaurantAndBar[lang]}`,
|
|
title: intl.formatMessage({ id: "Read more & book a table" }),
|
|
isExternal: false,
|
|
}
|
|
grid.unshift(card)
|
|
break
|
|
}
|
|
cards.push(grid)
|
|
})
|
|
return cards
|
|
}
|
|
|
|
/* lista över potentiella
|
|
Restaurant & Bar
|
|
Restaurants & bars
|
|
Restaurant
|
|
Bar
|
|
Breakfast restaurant (fallback om det inte finns restaurang eller bar)
|
|
*/
|