chore(SW-302): add dynamic restaurant title
This commit is contained in:
@@ -6,21 +6,40 @@ import useHash from "@/hooks/useHash"
|
|||||||
|
|
||||||
import styles from "./tabNavigation.module.css"
|
import styles from "./tabNavigation.module.css"
|
||||||
|
|
||||||
import { HotelHashValues } from "@/types/components/hotelPage/tabNavigation"
|
import {
|
||||||
|
HotelHashValues,
|
||||||
|
type TabNavigationProps,
|
||||||
|
} from "@/types/components/hotelPage/tabNavigation"
|
||||||
|
|
||||||
export default function TabNavigation() {
|
export default function TabNavigation({
|
||||||
|
restaurantRefData,
|
||||||
|
}: TabNavigationProps) {
|
||||||
const hash = useHash()
|
const hash = useHash()
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
|
|
||||||
const hotelTabLinks: { href: HotelHashValues; text: string }[] = [
|
const hotelTabLinks: { href: HotelHashValues | string; text: string }[] = [
|
||||||
// TODO these titles will need to reflect the facility card titles, which will vary between hotels
|
{
|
||||||
{ href: HotelHashValues.overview, text: "Overview" },
|
href: HotelHashValues.overview,
|
||||||
{ href: HotelHashValues.rooms, text: "Rooms" },
|
text: intl.formatMessage({ id: "Overview" }),
|
||||||
{ href: HotelHashValues.restaurant, text: "Restaurant & Bar" },
|
},
|
||||||
{ href: HotelHashValues.meetings, text: "Meetings & Conferences" },
|
{ href: HotelHashValues.rooms, text: intl.formatMessage({ id: "Rooms" }) },
|
||||||
{ href: HotelHashValues.wellness, text: "Wellness & Exercise" },
|
{
|
||||||
{ href: HotelHashValues.activities, text: "Activities" },
|
href: "#" + restaurantRefData.href.en,
|
||||||
{ href: HotelHashValues.faq, text: "FAQ" },
|
text: intl.formatMessage({ id: restaurantRefData.title }),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: HotelHashValues.meetings,
|
||||||
|
text: intl.formatMessage({ id: "Meetings & Conferences" }),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: HotelHashValues.wellness,
|
||||||
|
text: intl.formatMessage({ id: "Wellness & Exercise" }),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: HotelHashValues.activities,
|
||||||
|
text: intl.formatMessage({ id: "Activities" }),
|
||||||
|
},
|
||||||
|
{ href: HotelHashValues.faq, text: intl.formatMessage({ id: "FAQ" }) },
|
||||||
]
|
]
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -7,7 +7,12 @@ 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 { setActivityCard, setFacilityCards } from "@/utils/facilityCards"
|
import {
|
||||||
|
getRestaurantDynamicTitles,
|
||||||
|
setActivityCard,
|
||||||
|
setFacilityCards,
|
||||||
|
} from "@/utils/facilityCards"
|
||||||
|
|
||||||
import DynamicMap from "./Map/DynamicMap"
|
import DynamicMap from "./Map/DynamicMap"
|
||||||
import MapCard from "./Map/MapCard"
|
import MapCard from "./Map/MapCard"
|
||||||
import MobileMapToggle from "./Map/MobileMapToggle"
|
import MobileMapToggle from "./Map/MobileMapToggle"
|
||||||
@@ -47,7 +52,10 @@ export default async function HotelPage() {
|
|||||||
facilityCards,
|
facilityCards,
|
||||||
} = hotelData
|
} = hotelData
|
||||||
|
|
||||||
const facilities = await setFacilityCards(facilityCards)
|
const facilities = await setFacilityCards(
|
||||||
|
facilityCards,
|
||||||
|
hotelDetailedFacilities
|
||||||
|
)
|
||||||
activitiesCard && facilities.push(setActivityCard(activitiesCard))
|
activitiesCard && facilities.push(setActivityCard(activitiesCard))
|
||||||
const topThreePois = pointsOfInterest.slice(0, 3)
|
const topThreePois = pointsOfInterest.slice(0, 3)
|
||||||
|
|
||||||
@@ -61,7 +69,9 @@ export default async function HotelPage() {
|
|||||||
<div className={styles.hotelImages}>
|
<div className={styles.hotelImages}>
|
||||||
<PreviewImages images={hotelImages} hotelName={hotelName} />
|
<PreviewImages images={hotelImages} hotelName={hotelName} />
|
||||||
</div>
|
</div>
|
||||||
<TabNavigation />
|
<TabNavigation
|
||||||
|
restaurantRefData={getRestaurantDynamicTitles(hotelDetailedFacilities)}
|
||||||
|
/>
|
||||||
<main className={styles.mainSection}>
|
<main className={styles.mainSection}>
|
||||||
<div className={styles.introContainer}>
|
<div className={styles.introContainer}>
|
||||||
<IntroSection
|
<IntroSection
|
||||||
|
|||||||
@@ -45,13 +45,40 @@ export const meetingsAndConferences = {
|
|||||||
|
|
||||||
export const restaurantAndBar = {
|
export const restaurantAndBar = {
|
||||||
en: "restaurant-and-bar",
|
en: "restaurant-and-bar",
|
||||||
sv: "restaurant-och-bar",
|
sv: "restaurang-och-bar",
|
||||||
no: "restaurant-og-bar",
|
no: "restaurant-og-bar",
|
||||||
da: "restaurant-og-bar",
|
da: "restaurant-og-bar",
|
||||||
fi: "ravintola-ja-baari",
|
fi: "ravintola-ja-baari",
|
||||||
de: "Restaurant-und-Bar",
|
de: "Restaurant-und-Bar",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const restaurant = {
|
||||||
|
en: "restaurant",
|
||||||
|
sv: "restaurant",
|
||||||
|
no: "restaurant",
|
||||||
|
da: "restaurant",
|
||||||
|
fi: "ravintola",
|
||||||
|
de: "Restaurant",
|
||||||
|
}
|
||||||
|
|
||||||
|
export const bar = {
|
||||||
|
en: "bar",
|
||||||
|
sv: "bar",
|
||||||
|
no: "bar",
|
||||||
|
da: "bar",
|
||||||
|
fi: "baari",
|
||||||
|
de: "Bar",
|
||||||
|
}
|
||||||
|
|
||||||
|
export const breakfastRestaurant = {
|
||||||
|
en: "breakfast-restaurant",
|
||||||
|
sv: "frukostrestaurang",
|
||||||
|
no: "frokostrestaurant",
|
||||||
|
da: "morgenmadsrestaurant",
|
||||||
|
fi: "aamiaisravintola",
|
||||||
|
de: "Frühstücksrestaurant",
|
||||||
|
}
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
about,
|
about,
|
||||||
amenities,
|
amenities,
|
||||||
@@ -59,6 +86,9 @@ const params = {
|
|||||||
activities,
|
activities,
|
||||||
meetingsAndConferences,
|
meetingsAndConferences,
|
||||||
restaurantAndBar,
|
restaurantAndBar,
|
||||||
|
bar,
|
||||||
|
restaurant,
|
||||||
|
breakfastRestaurant,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default params
|
export default params
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
export enum HotelHashValues {
|
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",
|
||||||
faq = "#faq",
|
faq = "#faq",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type TabNavigationProps = {
|
||||||
|
restaurantRefData: { href: any; title: string }
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import {
|
import {
|
||||||
|
bar,
|
||||||
|
breakfastRestaurant,
|
||||||
meetingsAndConferences,
|
meetingsAndConferences,
|
||||||
|
restaurant,
|
||||||
restaurantAndBar,
|
restaurantAndBar,
|
||||||
wellnessAndExercise,
|
wellnessAndExercise,
|
||||||
} from "@/constants/routes/hotelPageParams"
|
} from "@/constants/routes/hotelPageParams"
|
||||||
@@ -13,6 +16,7 @@ import {
|
|||||||
FacilityEnum,
|
FacilityEnum,
|
||||||
} from "@/types/components/hotelPage/facilities"
|
} from "@/types/components/hotelPage/facilities"
|
||||||
import type { ImageVaultAsset } from "@/types/components/imageVault"
|
import type { ImageVaultAsset } from "@/types/components/imageVault"
|
||||||
|
import type { HotelData } from "@/types/hotel"
|
||||||
import type { CardProps } from "@/components/TempDesignSystem/Card/card"
|
import type { CardProps } from "@/components/TempDesignSystem/Card/card"
|
||||||
import type { Facility } from "@/server/routers/hotels/output"
|
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 lang = getLang()
|
||||||
const intl = await getIntl()
|
const intl = await getIntl()
|
||||||
|
|
||||||
@@ -112,13 +119,14 @@ export async function setFacilityCards(facilities: Array<Facility>) {
|
|||||||
break
|
break
|
||||||
|
|
||||||
case FacilityEnum.restaurant:
|
case FacilityEnum.restaurant:
|
||||||
|
const { href, title } = getRestaurantDynamicTitles(amenities)
|
||||||
card.theme = "primaryDark"
|
card.theme = "primaryDark"
|
||||||
card.id = "restaurant-and-bar"
|
card.id = href[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=${restaurantAndBar[lang]}`,
|
href: `?s=${href[lang]}`,
|
||||||
title: intl.formatMessage({ id: "Read more & book a table" }),
|
title: intl.formatMessage({ id: "Read more & book a table" }),
|
||||||
isExternal: false,
|
isExternal: false,
|
||||||
}
|
}
|
||||||
@@ -130,10 +138,28 @@ export async function setFacilityCards(facilities: Array<Facility>) {
|
|||||||
return cards
|
return cards
|
||||||
}
|
}
|
||||||
|
|
||||||
/* lista över potentiella
|
export function getRestaurantDynamicTitles(
|
||||||
Restaurant & Bar
|
amenities: HotelData["data"]["attributes"]["detailedFacilities"]
|
||||||
Restaurants & bars
|
) {
|
||||||
Restaurant
|
const hasBar = amenities.some(
|
||||||
Bar
|
(facility) => facility.id == 1606 || facility.id == 1014 // bar & rooftop bar id
|
||||||
Breakfast restaurant (fallback om det inte finns restaurang eller bar)
|
)
|
||||||
*/
|
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