Merged in feat/LOY-365-promo-campaign-eligible-levels (pull request #2864)

feat(LOY-365): Add support for eligible levels for promo campaign pages

* feat(LOY-365): Add support for eligible levels for promo campaign pages

* fix(LOY-365): update to most recent copy

* fix(LOY-365): cleanup css

* fix(LOY-365): Move ineligible message to the bottom

* fix(LOY-365): remove uneeded type


Approved-by: Erik Tiekstra
Approved-by: Matilda Landström
This commit is contained in:
Chuma Mcphoy (We Ahead)
2025-09-29 06:58:15 +00:00
parent 50bac104fc
commit daeb38832b
11 changed files with 174 additions and 42 deletions

View File

@@ -54,6 +54,7 @@
"./utils/isValidJson": "./utils/isValidJson.ts",
"./utils/languages": "./utils/languages.ts",
"./utils/maskValue": "./utils/maskValue.ts",
"./utils/membershipLevels": "./utils/membershipLevels.ts",
"./utils/numberFormatting": "./utils/numberFormatting.ts",
"./utils/rangeArray": "./utils/rangeArray.ts",
"./utils/safeTry": "./utils/safeTry.ts",

View File

@@ -0,0 +1,10 @@
import { MembershipLevelEnum } from "../constants/membershipLevels"
/**
* Type guard to check if a string value is a valid MembershipLevel
* @param value - The string value to check
* @returns true if the value is a valid MembershipLevel, false otherwise
*/
export function isMembershipLevel(value: string): value is MembershipLevelEnum {
return Object.values(MembershipLevelEnum).some((level) => level === value)
}

View File

@@ -25,6 +25,7 @@ query GetPromoCampaignPage($locale: String!, $uid: String!) {
promo_code
startdate
enddate
level_selection
system {
...System
created_at

View File

@@ -1,6 +1,7 @@
import { z } from "zod"
import { transformedImageVaultAssetSchema } from "@scandic-hotels/common/utils/imageVault"
import { isMembershipLevel } from "@scandic-hotels/common/utils/membershipLevels"
import { nullableStringValidator } from "@scandic-hotels/common/utils/zod/stringValidator"
import { systemSchema } from "../schemas/system"
@@ -35,6 +36,13 @@ export const promoCampaignPageSchema = z
promo_code: z.string(),
startdate: nullableStringValidator,
enddate: nullableStringValidator,
level_selection: z
.array(z.string())
.nullish()
.transform((data) => {
if (!data) return []
return data.filter(isMembershipLevel)
}),
system: systemSchema.merge(
z.object({
created_at: z.string(),
@@ -47,13 +55,15 @@ export const promoCampaignPageSchema = z
}),
})
.transform(({ promo_campaign_page, ...data }) => {
const { page_settings, ...promoCampaignPageData } = promo_campaign_page
const { page_settings, level_selection, ...promoCampaignPageData } =
promo_campaign_page
const bookingCode = page_settings?.booking_code || null
return {
...data,
promo_campaign_page: {
bookingCode,
eligibleLevels: level_selection,
...promoCampaignPageData,
},
}