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

View File

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

View File

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

View File

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

View File

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