From ef1d3ee06521ab3cb9a677a5a2fdc0e7f4502102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matilda=20Landstr=C3=B6m?= Date: Mon, 17 Feb 2025 07:23:43 +0000 Subject: [PATCH] Merged in fix/hotel-pages-fix (pull request #1346) fix: HotelPage restaurant navigation + translation * fix: hotelPage restaurant navigation + translation Approved-by: Erik Tiekstra --- .../WellnessAndExercise/Facility/index.tsx | 25 +++---------------- .../HotelPage/TabNavigation/index.tsx | 3 +-- components/ContentType/HotelPage/index.tsx | 2 -- components/ContentType/HotelPage/utils.ts | 23 +++++++++++++++++ .../HotelSubpage/Sidebar/WellnessSidebar.tsx | 4 ++- types/components/hotelPage/tabNavigation.ts | 1 - utils/facilityCards.ts | 2 +- 7 files changed, 31 insertions(+), 29 deletions(-) diff --git a/components/ContentType/HotelPage/SidePeeks/WellnessAndExercise/Facility/index.tsx b/components/ContentType/HotelPage/SidePeeks/WellnessAndExercise/Facility/index.tsx index 67d04f002..f5476e6f8 100644 --- a/components/ContentType/HotelPage/SidePeeks/WellnessAndExercise/Facility/index.tsx +++ b/components/ContentType/HotelPage/SidePeeks/WellnessAndExercise/Facility/index.tsx @@ -4,9 +4,10 @@ import Subtitle from "@/components/TempDesignSystem/Text/Subtitle" import Title from "@/components/TempDesignSystem/Text/Title" import { getIntl } from "@/i18n" +import { translateWellnessType } from "../../../utils" + import styles from "./facility.module.css" -import { HealthFacilitiesEnum } from "@/types/components/hotelPage/facilities" import type { FacilityProps } from "@/types/components/hotelPage/sidepeek/facility" export default async function Facility({ data }: FacilityProps) { @@ -15,26 +16,6 @@ export default async function Facility({ data }: FacilityProps) { const ordinaryOpeningTimes = data.openingDetails.openingHours.ordinary const weekendOpeningTimes = data.openingDetails.openingHours.weekends - function translateWellnessType(type: string) { - switch (type) { - case HealthFacilitiesEnum.Gym: - return intl.formatMessage({ id: "Gym" }) - case HealthFacilitiesEnum.IndoorPool: - return intl.formatMessage({ id: "Indoor pool" }) - case HealthFacilitiesEnum.Jacuzzi: - return intl.formatMessage({ id: "Jacuzzi" }) - case HealthFacilitiesEnum.OutdoorPool: - return intl.formatMessage({ id: "Outdoor pool" }) - case HealthFacilitiesEnum.Relax: - return intl.formatMessage({ id: "Relax" }) - case HealthFacilitiesEnum.Sauna: - return intl.formatMessage({ id: "Sauna" }) - default: - console.warn(`Unsupported group given: ${type}`) - return intl.formatMessage({ id: "Wellness" }) - } - } - return (
{image?.imageSizes.medium && ( @@ -48,7 +29,7 @@ export default async function Facility({ data }: FacilityProps) { )}
- {translateWellnessType(data.type)} + {translateWellnessType(data.type, intl)}
diff --git a/components/ContentType/HotelPage/TabNavigation/index.tsx b/components/ContentType/HotelPage/TabNavigation/index.tsx index 083521c8c..4d9f76466 100644 --- a/components/ContentType/HotelPage/TabNavigation/index.tsx +++ b/components/ContentType/HotelPage/TabNavigation/index.tsx @@ -20,7 +20,6 @@ import { } from "@/types/components/hotelPage/tabNavigation" export default function TabNavigation({ - restaurantTitle, hasActivities, hasFAQ, tabValues, @@ -48,7 +47,7 @@ export default function TabNavigation({ hash: HotelHashValues.restaurant, text: tabValues?.restaurant_bar || - intl.formatMessage({ id: restaurantTitle }, { count: 1 }), + intl.formatMessage({ id: "Restaurant & Bar" }), }, { hash: HotelHashValues.meetings, diff --git a/components/ContentType/HotelPage/index.tsx b/components/ContentType/HotelPage/index.tsx index e4a37df6f..2440d9165 100644 --- a/components/ContentType/HotelPage/index.tsx +++ b/components/ContentType/HotelPage/index.tsx @@ -11,7 +11,6 @@ import Alert from "@/components/TempDesignSystem/Alert" import BreadcrumbsSkeleton from "@/components/TempDesignSystem/Breadcrumbs/BreadcrumbsSkeleton" import TrackingSDK from "@/components/TrackingSDK" import { getLang } from "@/i18n/serverContext" -import { getRestaurantHeading } from "@/utils/facilityCards" import { generateHotelSchema } from "@/utils/jsonSchemas" import DynamicMap from "./Map/DynamicMap" @@ -150,7 +149,6 @@ export default async function HotelPage({ hotelId }: HotelPageProps) { ) : null} 0} hasFAQ={!!faq?.accordions.length} tabValues={tabValues} diff --git a/components/ContentType/HotelPage/utils.ts b/components/ContentType/HotelPage/utils.ts index a725548f1..9288bd441 100644 --- a/components/ContentType/HotelPage/utils.ts +++ b/components/ContentType/HotelPage/utils.ts @@ -1,3 +1,6 @@ +import type { IntlShape } from "react-intl" + +import { HealthFacilitiesEnum } from "@/types/components/hotelPage/facilities" import { TrackingChannelEnum, type TrackingSDKHotelInfo, @@ -42,3 +45,23 @@ export function getTrackingHotelData(hotelData: HotelData["hotel"]) { return tracking } + +export function translateWellnessType(type: string, intl: IntlShape) { + switch (type) { + case HealthFacilitiesEnum.Gym: + return intl.formatMessage({ id: "Gym" }) + case HealthFacilitiesEnum.IndoorPool: + return intl.formatMessage({ id: "Indoor pool" }) + case HealthFacilitiesEnum.Jacuzzi: + return intl.formatMessage({ id: "Jacuzzi" }) + case HealthFacilitiesEnum.OutdoorPool: + return intl.formatMessage({ id: "Outdoor pool" }) + case HealthFacilitiesEnum.Relax: + return intl.formatMessage({ id: "Relax" }) + case HealthFacilitiesEnum.Sauna: + return intl.formatMessage({ id: "Sauna" }) + default: + console.warn(`Unsupported group given: ${type}`) + return intl.formatMessage({ id: "Wellness" }) + } +} diff --git a/components/ContentType/HotelSubpage/Sidebar/WellnessSidebar.tsx b/components/ContentType/HotelSubpage/Sidebar/WellnessSidebar.tsx index 8139967ff..6c7de4253 100644 --- a/components/ContentType/HotelSubpage/Sidebar/WellnessSidebar.tsx +++ b/components/ContentType/HotelSubpage/Sidebar/WellnessSidebar.tsx @@ -4,6 +4,8 @@ import Subtitle from "@/components/TempDesignSystem/Text/Subtitle" import Title from "@/components/TempDesignSystem/Text/Title" import { getIntl } from "@/i18n" +import { translateWellnessType } from "../../HotelPage/utils" + import styles from "./sidebar.module.css" import type { Hotel } from "@/types/hotel" @@ -23,7 +25,7 @@ export default async function WellnessSidebar({ hotel }: WellnessSidebarProps) { {hotel.healthFacilities.map((facility) => (
-

{intl.formatMessage({ id: facility.type })}

+

{translateWellnessType(facility.type, intl)}

{facility.openingDetails.openingHours.ordinary.alwaysOpen diff --git a/types/components/hotelPage/tabNavigation.ts b/types/components/hotelPage/tabNavigation.ts index 1e8a2458e..b07dd83f1 100644 --- a/types/components/hotelPage/tabNavigation.ts +++ b/types/components/hotelPage/tabNavigation.ts @@ -20,7 +20,6 @@ type Tabs = { } export type TabNavigationProps = { - restaurantTitle: string hasActivities: boolean hasFAQ: boolean tabValues?: Tabs | null diff --git a/utils/facilityCards.ts b/utils/facilityCards.ts index a9a8b6ff4..738ef9b09 100644 --- a/utils/facilityCards.ts +++ b/utils/facilityCards.ts @@ -124,7 +124,7 @@ export function setFacilityCardGrids( return cards } -export function getRestaurantHeading(amenities: Amenities): RestaurantHeadings { +function getRestaurantHeading(amenities: Amenities): RestaurantHeadings { const hasBar = amenities.some( (facility) => facility.id === FacilityEnum.Bar ||