From cc00aab7eed34ddf5afd29e6c24c30da5e74cb3c Mon Sep 17 00:00:00 2001 From: Fredrik Thorsson Date: Tue, 7 Jan 2025 15:22:50 +0100 Subject: [PATCH] feat(SW-495): update heading on facility cards --- .../HotelPage/Facilities/index.tsx | 8 ++- components/ContentType/HotelPage/index.tsx | 2 + types/components/hotelPage/facilities.ts | 12 +++- types/enums/healthFacilities.ts | 6 ++ types/hotel.ts | 2 + utils/facilityCards.ts | 56 ++++++++++++++++--- 6 files changed, 75 insertions(+), 11 deletions(-) create mode 100644 types/enums/healthFacilities.ts diff --git a/components/ContentType/HotelPage/Facilities/index.tsx b/components/ContentType/HotelPage/Facilities/index.tsx index 3f43cc328..52908b84d 100644 --- a/components/ContentType/HotelPage/Facilities/index.tsx +++ b/components/ContentType/HotelPage/Facilities/index.tsx @@ -17,10 +17,16 @@ import type { export default async function Facilities({ facilities, activitiesCard, + amenities, + healthFacilities, }: FacilitiesProps) { const intl = await getIntl() - const facilityCardGrids = setFacilityCardGrids(facilities) + const facilityCardGrids = setFacilityCardGrids( + facilities, + amenities, + healthFacilities + ) const translatedFacilityGrids: Facilities = facilityCardGrids.map( (cardGrid: FacilityGrid) => { diff --git a/components/ContentType/HotelPage/index.tsx b/components/ContentType/HotelPage/index.tsx index 180a5d16d..a603b5f55 100644 --- a/components/ContentType/HotelPage/index.tsx +++ b/components/ContentType/HotelPage/index.tsx @@ -169,6 +169,8 @@ export default async function HotelPage({ hotelId }: HotelPageProps) { {faq.accordions.length > 0 && ( diff --git a/types/components/hotelPage/facilities.ts b/types/components/hotelPage/facilities.ts index dcc58651f..1c00e1482 100644 --- a/types/components/hotelPage/facilities.ts +++ b/types/components/hotelPage/facilities.ts @@ -1,10 +1,12 @@ -import type { Facility } from "@/types/hotel" +import type { Amenities, Facility, HealthFacilities } from "@/types/hotel" import type { ActivityCard } from "@/types/trpc/routers/contentstack/hotelPage" import type { CardProps } from "@/components/TempDesignSystem/Card/card" export type FacilitiesProps = { facilities: Facility[] activitiesCard?: ActivityCard + amenities: Amenities + healthFacilities: HealthFacilities } export type FacilityImage = { @@ -47,3 +49,11 @@ export enum RestaurantHeadings { restaurant = "Restaurant", breakfastRestaurant = "Breakfast restaurant", } + +export enum WellnessHeadings { + GymPool = "Gym & Pool", + GymSauna = "Gym & Sauna", + GymPoolSaunaRelax = "Gym, Pool, Sauna & Relax", + GymJacuzziSaunaRelax = "Gym, Jacuzzi, Sauna & Relax", + FallbackHeading = "Wellness & Exercise", +} diff --git a/types/enums/healthFacilities.ts b/types/enums/healthFacilities.ts new file mode 100644 index 000000000..256ff0bd9 --- /dev/null +++ b/types/enums/healthFacilities.ts @@ -0,0 +1,6 @@ +export enum HealthFacilitiesEnum { + Jacuzzi = "Jacuzzi", + Gym = "Gym", + Sauna = "Sauna", + Relax = "Relax", +} diff --git a/types/hotel.ts b/types/hotel.ts index 0ccdaecf7..2435d8617 100644 --- a/types/hotel.ts +++ b/types/hotel.ts @@ -21,6 +21,8 @@ export type Hotel = HotelData["data"]["attributes"] export type HotelAddress = HotelData["data"]["attributes"]["address"] export type HotelLocation = HotelData["data"]["attributes"]["location"] export type Amenities = HotelData["data"]["attributes"]["detailedFacilities"] +export type HealthFacilities = + HotelData["data"]["attributes"]["healthFacilities"] type HotelRatings = HotelData["data"]["attributes"]["ratings"] export type HotelTripAdvisor = diff --git a/utils/facilityCards.ts b/utils/facilityCards.ts index f5e1ffc6a..bb6013580 100644 --- a/utils/facilityCards.ts +++ b/utils/facilityCards.ts @@ -14,9 +14,11 @@ import { type FacilityGrid, type FacilityImage, RestaurantHeadings, + WellnessHeadings, } from "@/types/components/hotelPage/facilities" import { FacilityEnum } from "@/types/enums/facilities" -import type { Amenities, Facility } from "@/types/hotel" +import { HealthFacilitiesEnum } from "@/types/enums/healthFacilities" +import type { Amenities, Facility, HealthFacilities } from "@/types/hotel" import type { CardProps } from "@/components/TempDesignSystem/Card/card" export function isFacilityCard(card: FacilityCardType): card is FacilityCard { @@ -48,7 +50,11 @@ function setCardProps( } } -export function setFacilityCardGrids(facilities: Facility[]): Facilities { +export function setFacilityCardGrids( + facilities: Facility[], + amenities: Amenities, + healthFacilities: HealthFacilities +): Facilities { const lang = getLang() const cards: Facilities = facilities.map((facility) => { @@ -74,12 +80,13 @@ export function setFacilityCardGrids(facilities: Facility[]): Facilities { switch (facility.id) { case FacilityCardTypeEnum.wellness: + const wellnessTitle = getWellnessHeading(healthFacilities) card = setCardProps( "one", - "Sauna and gym", + facility.headingText, "Read more about wellness & exercise", wellnessAndExercise[lang], - facility.headingText + wellnessTitle ) grid.unshift(card) break @@ -87,22 +94,22 @@ export function setFacilityCardGrids(facilities: Facility[]): Facilities { case FacilityCardTypeEnum.conference: card = setCardProps( "primaryDim", - "Events that make an impression", + facility.headingText, "About meetings & conferences", meetingsAndConferences[lang], - facility.headingText + "Events that make an impression" ) grid.push(card) break case FacilityCardTypeEnum.restaurant: - //const title = getRestaurantHeading(amenities) // TODO will be used later + const restaurantTitle = getRestaurantHeading(amenities) card = setCardProps( "primaryDark", - "Enjoy relaxed restaurant experiences", + facility.headingText, "Read more & book a table", restaurantAndBar[lang], - facility.headingText + restaurantTitle ) grid.unshift(card) break @@ -133,6 +140,37 @@ export function getRestaurantHeading(amenities: Amenities): RestaurantHeadings { return RestaurantHeadings.breakfastRestaurant } +export function getWellnessHeading( + healthFacilities: HealthFacilities +): WellnessHeadings { + const hasGym = healthFacilities.some( + (facility) => facility.type === HealthFacilitiesEnum.Gym + ) + const hasSauna = healthFacilities.some( + (faility) => faility.type === HealthFacilitiesEnum.Sauna + ) + const hasRelax = healthFacilities.some( + (facility) => facility.type === HealthFacilitiesEnum.Relax + ) + const hasJacuzzi = healthFacilities.some( + (facility) => facility.type === HealthFacilitiesEnum.Jacuzzi + ) + const hasPool = healthFacilities.some((facility) => + facility.type.includes("Pool") + ) + + if (hasGym && hasJacuzzi && hasSauna && hasRelax) { + return WellnessHeadings.GymJacuzziSaunaRelax + } else if (hasGym && hasPool && hasSauna && hasRelax) { + return WellnessHeadings.GymPoolSaunaRelax + } else if (hasGym && hasSauna) { + return WellnessHeadings.GymSauna + } else if (hasGym && hasPool) { + return WellnessHeadings.GymPool + } + return WellnessHeadings.FallbackHeading +} + export function filterFacilityCards(cards: FacilityGrid) { const card = cards.filter((card) => isFacilityCard(card)) const images = cards.filter((card) => isFacilityImage(card))