chore(SW-302): add dynamic restaurant title
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import {
|
||||
bar,
|
||||
breakfastRestaurant,
|
||||
meetingsAndConferences,
|
||||
restaurant,
|
||||
restaurantAndBar,
|
||||
wellnessAndExercise,
|
||||
} from "@/constants/routes/hotelPageParams"
|
||||
@@ -13,6 +16,7 @@ import {
|
||||
FacilityEnum,
|
||||
} from "@/types/components/hotelPage/facilities"
|
||||
import type { ImageVaultAsset } from "@/types/components/imageVault"
|
||||
import type { HotelData } from "@/types/hotel"
|
||||
import type { CardProps } from "@/components/TempDesignSystem/Card/card"
|
||||
import type { Facility } from "@/server/routers/hotels/output"
|
||||
|
||||
@@ -53,7 +57,10 @@ export function setActivityCard(activitiesCard: ActivityCard): FacilityCards {
|
||||
]
|
||||
}
|
||||
|
||||
export async function setFacilityCards(facilities: Array<Facility>) {
|
||||
export async function setFacilityCards(
|
||||
facilities: Array<Facility>,
|
||||
amenities: HotelData["data"]["attributes"]["detailedFacilities"]
|
||||
) {
|
||||
const lang = getLang()
|
||||
const intl = await getIntl()
|
||||
|
||||
@@ -112,13 +119,14 @@ export async function setFacilityCards(facilities: Array<Facility>) {
|
||||
break
|
||||
|
||||
case FacilityEnum.restaurant:
|
||||
const { href, title } = getRestaurantDynamicTitles(amenities)
|
||||
card.theme = "primaryDark"
|
||||
card.id = "restaurant-and-bar"
|
||||
card.id = href[lang]
|
||||
card.heading = intl.formatMessage({
|
||||
id: "Enjoy relaxed restaurant experiences",
|
||||
})
|
||||
card.secondaryButton = {
|
||||
href: `?s=${restaurantAndBar[lang]}`,
|
||||
href: `?s=${href[lang]}`,
|
||||
title: intl.formatMessage({ id: "Read more & book a table" }),
|
||||
isExternal: false,
|
||||
}
|
||||
@@ -130,10 +138,28 @@ export async function setFacilityCards(facilities: Array<Facility>) {
|
||||
return cards
|
||||
}
|
||||
|
||||
/* lista över potentiella
|
||||
Restaurant & Bar
|
||||
Restaurants & bars
|
||||
Restaurant
|
||||
Bar
|
||||
Breakfast restaurant (fallback om det inte finns restaurang eller bar)
|
||||
*/
|
||||
export function getRestaurantDynamicTitles(
|
||||
amenities: HotelData["data"]["attributes"]["detailedFacilities"]
|
||||
) {
|
||||
const hasBar = amenities.some(
|
||||
(facility) => facility.id == 1606 || facility.id == 1014 // bar & rooftop bar id
|
||||
)
|
||||
const hasRestaurant = amenities.some((facility) => facility.id == 1383) // restaurant id
|
||||
|
||||
let href, title: string
|
||||
if (hasBar && hasRestaurant) {
|
||||
href = restaurantAndBar
|
||||
title = "Restaurant & Bar"
|
||||
} else if (hasBar) {
|
||||
href = bar
|
||||
title = "Bar"
|
||||
} else if (hasRestaurant) {
|
||||
href = restaurant
|
||||
title = "Restaurant"
|
||||
} else {
|
||||
href = breakfastRestaurant
|
||||
title = "Breakfast restaurant"
|
||||
}
|
||||
|
||||
return { href, title }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user