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

@@ -11,9 +11,7 @@ import {
type TabNavigationProps,
} from "@/types/components/hotelPage/tabNavigation"
export default function TabNavigation({
restaurantRefData,
}: TabNavigationProps) {
export default function TabNavigation({ restaurantTitle }: TabNavigationProps) {
const hash = useHash()
const intl = useIntl()
@@ -24,8 +22,8 @@ export default function TabNavigation({
},
{ href: HotelHashValues.rooms, text: intl.formatMessage({ id: "Rooms" }) },
{
href: "#" + restaurantRefData.href.en,
text: intl.formatMessage({ id: restaurantRefData.title }),
href: HotelHashValues.restaurant,
text: intl.formatMessage({ id: restaurantTitle }),
},
{
href: HotelHashValues.meetings,

View File

@@ -6,9 +6,8 @@ import SidePeekProvider from "@/components/SidePeekProvider"
import SidePeek from "@/components/TempDesignSystem/SidePeek"
import { getIntl } from "@/i18n"
import { getLang } from "@/i18n/serverContext"
import {
getRestaurantDynamicTitles,
getRestaurantHeading,
setActivityCard,
setFacilityCards,
} from "@/utils/facilityCards"
@@ -70,7 +69,7 @@ export default async function HotelPage() {
<PreviewImages images={hotelImages} hotelName={hotelName} />
</div>
<TabNavigation
restaurantRefData={getRestaurantDynamicTitles(hotelDetailedFacilities)}
restaurantTitle={getRestaurantHeading(hotelDetailedFacilities)}
/>
<main className={styles.mainSection}>
<div className={styles.introContainer}>

View File

@@ -52,7 +52,7 @@ export const restaurantAndBar = {
de: "Restaurant-und-Bar",
}
export const restaurant = {
/*export const restaurant = {
en: "restaurant",
sv: "restaurant",
no: "restaurant",
@@ -78,7 +78,7 @@ export const breakfastRestaurant = {
fi: "aamiaisravintola",
de: "Frühstücksrestaurant",
}
*/
const params = {
about,
amenities,
@@ -86,9 +86,9 @@ const params = {
activities,
meetingsAndConferences,
restaurantAndBar,
bar,
/*bar,
restaurant,
breakfastRestaurant,
breakfastRestaurant,*/
}
export default params

View File

@@ -1,6 +1,7 @@
export enum HotelHashValues { // Should these be translated?
overview = "#overview",
rooms = "#rooms-section",
restaurant = "#restaurant-and-bar",
meetings = "#meetings-and-conferences",
wellness = "#wellness-and-exercise",
activities = "#activities",
@@ -8,5 +9,5 @@ export enum HotelHashValues { // Should these be translated?
}
export type TabNavigationProps = {
restaurantRefData: { href: any; title: string }
restaurantTitle: string
}

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
}