feat(SW-495): update heading on facility cards
This commit is contained in:
@@ -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) => {
|
||||
|
||||
@@ -169,6 +169,8 @@ export default async function HotelPage({ hotelId }: HotelPageProps) {
|
||||
<Facilities
|
||||
facilities={facilities}
|
||||
activitiesCard={activitiesCard?.upcoming_activities_card}
|
||||
amenities={detailedFacilities}
|
||||
healthFacilities={healthFacilities}
|
||||
/>
|
||||
{faq.accordions.length > 0 && (
|
||||
<AccordionSection accordion={faq.accordions} title={faq.title} />
|
||||
|
||||
@@ -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",
|
||||
}
|
||||
|
||||
6
types/enums/healthFacilities.ts
Normal file
6
types/enums/healthFacilities.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export enum HealthFacilitiesEnum {
|
||||
Jacuzzi = "Jacuzzi",
|
||||
Gym = "Gym",
|
||||
Sauna = "Sauna",
|
||||
Relax = "Relax",
|
||||
}
|
||||
@@ -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 =
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user