feat(SW-495): update heading on facility cards
This commit is contained in:
@@ -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