Merge remote-tracking branch 'origin' into feat/tracking-payment
This commit is contained in:
@@ -13,10 +13,12 @@ import {
|
||||
FacilityCardTypeEnum,
|
||||
type FacilityGrid,
|
||||
type FacilityImage,
|
||||
HealthFacilitiesEnum,
|
||||
RestaurantHeadings,
|
||||
WellnessHeadings,
|
||||
} from "@/types/components/hotelPage/facilities"
|
||||
import { FacilityEnum } from "@/types/enums/facilities"
|
||||
import type { Amenities, Facility } from "@/types/hotel"
|
||||
import type { Amenities, Facility, HealthFacilities } from "@/types/hotel"
|
||||
import type { CardProps } from "@/components/TempDesignSystem/Card/card"
|
||||
|
||||
export function isFacilityCard(card: FacilityCardType): card is FacilityCard {
|
||||
@@ -32,7 +34,7 @@ function setCardProps(
|
||||
heading: string,
|
||||
buttonText: string,
|
||||
href: string,
|
||||
scriptedTopTitle: string
|
||||
scriptedTopTitle?: string
|
||||
): FacilityCard {
|
||||
return {
|
||||
theme,
|
||||
@@ -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,39 @@ export function getRestaurantHeading(amenities: Amenities): RestaurantHeadings {
|
||||
return RestaurantHeadings.breakfastRestaurant
|
||||
}
|
||||
|
||||
export function getWellnessHeading(
|
||||
healthFacilities: HealthFacilities
|
||||
): WellnessHeadings | undefined {
|
||||
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 === HealthFacilitiesEnum.IndoorPool ||
|
||||
facility.type === HealthFacilitiesEnum.OutdoorPool
|
||||
)
|
||||
|
||||
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 undefined
|
||||
}
|
||||
|
||||
export function filterFacilityCards(cards: FacilityGrid) {
|
||||
const card = cards.filter((card) => isFacilityCard(card))
|
||||
const images = cards.filter((card) => isFacilityImage(card))
|
||||
|
||||
@@ -4,7 +4,7 @@ import type {
|
||||
RestaurantRewardId,
|
||||
RewardId,
|
||||
} from "@/types/components/myPages/rewards"
|
||||
import type { Reward } from "@/server/routers/contentstack/reward/output"
|
||||
import type { RewardWithRedeem } from "@/server/routers/contentstack/reward/output"
|
||||
|
||||
export function isValidRewardId(id: string): id is RewardId {
|
||||
return Object.values<string>(REWARD_IDS).includes(id)
|
||||
@@ -17,22 +17,26 @@ export function isRestaurantReward(
|
||||
}
|
||||
|
||||
export function redeemLocationIsOnSite(
|
||||
location: Reward["redeemLocation"]
|
||||
location: RewardWithRedeem["redeemLocation"]
|
||||
): location is "On-site" {
|
||||
return location === "On-site"
|
||||
}
|
||||
|
||||
export function isTierType(type: Reward["rewardType"]): type is "Tier" {
|
||||
export function isTierType(
|
||||
type: RewardWithRedeem["rewardType"]
|
||||
): type is "Tier" {
|
||||
return type === "Tier"
|
||||
}
|
||||
|
||||
export function isOnSiteTierReward(reward: Reward): boolean {
|
||||
export function isOnSiteTierReward(reward: RewardWithRedeem): boolean {
|
||||
return (
|
||||
redeemLocationIsOnSite(reward.redeemLocation) &&
|
||||
isTierType(reward.rewardType)
|
||||
)
|
||||
}
|
||||
|
||||
export function isRestaurantOnSiteTierReward(reward: Reward): boolean {
|
||||
export function isRestaurantOnSiteTierReward(
|
||||
reward: RewardWithRedeem
|
||||
): boolean {
|
||||
return isOnSiteTierReward(reward) && isRestaurantReward(reward.reward_id)
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ export function trackPageViewStart() {
|
||||
}
|
||||
|
||||
export function trackLoginClick(position: TrackingPosition) {
|
||||
const loginEvent = {
|
||||
const event = {
|
||||
event: "loginStart",
|
||||
login: {
|
||||
position,
|
||||
@@ -28,7 +28,27 @@ export function trackLoginClick(position: TrackingPosition) {
|
||||
ctaName: "login",
|
||||
},
|
||||
}
|
||||
pushToDataLayer(loginEvent)
|
||||
pushToDataLayer(event)
|
||||
}
|
||||
|
||||
export function trackSocialMediaClick(socialMediaName: string) {
|
||||
const event = {
|
||||
event: "social media",
|
||||
social: {
|
||||
socialIconClicked: socialMediaName,
|
||||
},
|
||||
}
|
||||
pushToDataLayer(event)
|
||||
}
|
||||
|
||||
export function trackFooterClick(group: string, name: string) {
|
||||
const event = {
|
||||
event: "footer link",
|
||||
footer: {
|
||||
footerLinkClicked: `${group}:${name}`,
|
||||
},
|
||||
}
|
||||
pushToDataLayer(event)
|
||||
}
|
||||
|
||||
export function trackUpdatePaymentMethod(hotelId: string, method: string) {
|
||||
@@ -80,7 +100,7 @@ export function createSDKPageObject(
|
||||
|
||||
return {
|
||||
...trackingData,
|
||||
domain: window.location.host,
|
||||
domain: typeof window !== "undefined" ? window.location.host : "",
|
||||
pageName: pageName,
|
||||
siteSections: siteSections,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user