refactor(SW-302): cleanup

This commit is contained in:
Matilda Landström
2024-09-17 22:25:35 +02:00
parent 6c88d3431a
commit 2438d04f43
5 changed files with 24 additions and 29 deletions

View File

@@ -1,8 +1,5 @@
import {
bar,
breakfastRestaurant,
meetingsAndConferences,
restaurant,
restaurantAndBar,
wellnessAndExercise,
} from "@/constants/routes/hotelPageParams"
@@ -92,7 +89,7 @@ export async function setFacilityCards(
switch (facility.id) {
case FacilityEnum.wellness:
card.theme = "one"
card.id = "wellness-and-exercise"
card.id = wellnessAndExercise[lang]
;(card.heading = intl.formatMessage({ id: "Sauna and gym" })),
(card.secondaryButton = {
href: `?s=${wellnessAndExercise[lang]}`,
@@ -106,7 +103,7 @@ export async function setFacilityCards(
case FacilityEnum.conference:
card.theme = "primaryDim"
card.id = "meetings-and-conferences"
card.id = meetingsAndConferences[lang]
;(card.heading = intl.formatMessage({
id: "Events that make an impression",
})),
@@ -119,14 +116,14 @@ export async function setFacilityCards(
break
case FacilityEnum.restaurant:
const { href, title } = getRestaurantDynamicTitles(amenities)
const title = getRestaurantHeading(amenities)
card.theme = "primaryDark"
card.id = href[lang]
card.id = restaurantAndBar[lang]
card.heading = intl.formatMessage({
id: "Enjoy relaxed restaurant experiences",
})
card.secondaryButton = {
href: `?s=${href[lang]}`,
href: `?s=${restaurantAndBar[lang]}`,
title: intl.formatMessage({ id: "Read more & book a table" }),
isExternal: false,
}
@@ -138,7 +135,7 @@ export async function setFacilityCards(
return cards
}
export function getRestaurantDynamicTitles(
export function getRestaurantHeading(
amenities: HotelData["data"]["attributes"]["detailedFacilities"]
) {
const hasBar = amenities.some(
@@ -146,20 +143,20 @@ export function getRestaurantDynamicTitles(
)
const hasRestaurant = amenities.some((facility) => facility.id == 1383) // restaurant id
let href, title: string
//let href,
let title: string
if (hasBar && hasRestaurant) {
href = restaurantAndBar
//href = restaurantAndBar
title = "Restaurant & Bar"
} else if (hasBar) {
href = bar
//href = bar
title = "Bar"
} else if (hasRestaurant) {
href = restaurant
//href = restaurant
title = "Restaurant"
} else {
href = breakfastRestaurant
//href = breakfastRestaurant
title = "Breakfast restaurant"
}
return { href, title }
return title
}