refactor(SW-302
This commit is contained in:
@@ -5,79 +5,67 @@ import {
|
||||
wellnessAndExercise,
|
||||
} from "@/constants/routes/hotelPageParams"
|
||||
|
||||
import { getIntl } from "@/i18n"
|
||||
import { getLang } from "@/i18n/serverContext"
|
||||
|
||||
import {
|
||||
type Facilities,
|
||||
type FacilityCards,
|
||||
FacilityEnum,
|
||||
FacilityIds,
|
||||
RestaurantHeadings,
|
||||
} from "@/types/components/hotelPage/facilities"
|
||||
import type { ImageVaultAsset } from "@/types/components/imageVault"
|
||||
import type { Amenities, Facility } from "@/types/hotel"
|
||||
import { ActivityCard } from "@/types/trpc/routers/contentstack/hotelPage"
|
||||
import type { CardProps } from "@/components/TempDesignSystem/Card/card"
|
||||
|
||||
type ActivityCard = {
|
||||
background_image?: ImageVaultAsset
|
||||
scripted_title?: string
|
||||
heading: string
|
||||
body_text: string
|
||||
cta_text: string
|
||||
contentPage: { href: string }
|
||||
}
|
||||
|
||||
export function setActivityCard(activitiesCard: ActivityCard): FacilityCards {
|
||||
export function setActivityCard(activitiesCard: ActivityCard): CardProps {
|
||||
const lang = getLang()
|
||||
const hasImage = activitiesCard.background_image
|
||||
return [
|
||||
{
|
||||
id: activities[lang],
|
||||
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.href,
|
||||
title: activitiesCard.cta_text,
|
||||
isExternal: false,
|
||||
}
|
||||
: undefined,
|
||||
secondaryButton: hasImage
|
||||
? undefined
|
||||
: {
|
||||
href: activitiesCard.contentPage.href,
|
||||
title: activitiesCard.cta_text,
|
||||
isExternal: false,
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
const updatedCard: CardProps = {
|
||||
id: activities[lang],
|
||||
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.href,
|
||||
title: activitiesCard.cta_text,
|
||||
isExternal: false,
|
||||
}
|
||||
: undefined,
|
||||
secondaryButton: hasImage
|
||||
? undefined
|
||||
: {
|
||||
href: activitiesCard.contentPage.href,
|
||||
title: activitiesCard.cta_text,
|
||||
isExternal: false,
|
||||
},
|
||||
}
|
||||
return updatedCard
|
||||
}
|
||||
|
||||
async function setCardProps(
|
||||
function setCardProps(
|
||||
theme: CardProps["theme"],
|
||||
heading: string,
|
||||
buttonText: string,
|
||||
href: string
|
||||
) {
|
||||
const intl = await getIntl()
|
||||
const card: CardProps = {}
|
||||
|
||||
card.theme = theme
|
||||
card.id = href
|
||||
card.heading = intl.formatMessage({ id: heading })
|
||||
card.heading = heading
|
||||
card.secondaryButton = {
|
||||
href: `?s=${href}`,
|
||||
title: intl.formatMessage({ id: buttonText }),
|
||||
title: buttonText,
|
||||
isExternal: false,
|
||||
}
|
||||
return card
|
||||
}
|
||||
|
||||
export function setFacilityCards(facilities: Facility[]) {
|
||||
export function setFacilityCardGrids(facilities: Facility[]): Facilities {
|
||||
const lang = getLang()
|
||||
const cards: Facilities = []
|
||||
|
||||
@@ -104,7 +92,7 @@ export function setFacilityCards(facilities: Facility[]) {
|
||||
|
||||
switch (facility.id) {
|
||||
case FacilityEnum.wellness:
|
||||
card = await setCardProps(
|
||||
card = setCardProps(
|
||||
"one",
|
||||
"Sauna and gym",
|
||||
"Read more about wellness & exercise",
|
||||
@@ -115,7 +103,7 @@ export function setFacilityCards(facilities: Facility[]) {
|
||||
break
|
||||
|
||||
case FacilityEnum.conference:
|
||||
card = await setCardProps(
|
||||
card = setCardProps(
|
||||
"primaryDim",
|
||||
"Events that make an impression",
|
||||
"About meetings & conferences",
|
||||
@@ -127,7 +115,7 @@ export function setFacilityCards(facilities: Facility[]) {
|
||||
|
||||
case FacilityEnum.restaurant:
|
||||
//const title = getRestaurantHeading(amenities) // TODO will be used later
|
||||
card = await setCardProps(
|
||||
card = setCardProps(
|
||||
"primaryDark",
|
||||
"Enjoy relaxed restaurant experiences",
|
||||
"Read more & book a table",
|
||||
|
||||
Reference in New Issue
Block a user