Feat(LOY-363): Promo Campaign Hero * feat(LOY-361): Add Promo Campaign Hero * feat(LOY-361): auth cta's wip * fix(LOY-361): improve hero card css * fix(LOY-361): correct size for button * fix(LOY-361): Make Promo Hero Required * fix(LOY-361): semantic css classes Approved-by: Matilda Landström
68 lines
1.7 KiB
TypeScript
68 lines
1.7 KiB
TypeScript
import { z } from "zod"
|
|
|
|
import { transformedImageVaultAssetSchema } from "@scandic-hotels/common/utils/imageVault"
|
|
import { nullableStringValidator } from "@scandic-hotels/common/utils/zod/stringValidator"
|
|
|
|
import { systemSchema } from "../schemas/system"
|
|
|
|
export const CAMPAIGN_TYPES = {
|
|
TIER: "TIER",
|
|
POINT: "POINT",
|
|
} as const
|
|
|
|
export const promoHeroSchema = z.object({
|
|
image: transformedImageVaultAssetSchema,
|
|
heading: z.string(),
|
|
benefits: z
|
|
.array(z.string())
|
|
.nullish()
|
|
.transform((data) => data || []),
|
|
})
|
|
|
|
export const promoCampaignPageSchema = z
|
|
.object({
|
|
promo_campaign_page: z.object({
|
|
title: z.string(),
|
|
heading: z.string(),
|
|
subheading: z.string().nullish(),
|
|
promo_hero: promoHeroSchema,
|
|
page_settings: z
|
|
.object({
|
|
booking_code: z.string().nullish(),
|
|
})
|
|
.nullish(),
|
|
campaign_type: z.nativeEnum(CAMPAIGN_TYPES),
|
|
promo_code: z.string(),
|
|
startdate: nullableStringValidator,
|
|
enddate: nullableStringValidator,
|
|
system: systemSchema.merge(
|
|
z.object({
|
|
created_at: z.string(),
|
|
updated_at: z.string(),
|
|
})
|
|
),
|
|
}),
|
|
trackingProps: z.object({
|
|
url: z.string(),
|
|
}),
|
|
})
|
|
.transform(({ promo_campaign_page, ...data }) => {
|
|
const { page_settings, ...promoCampaignPageData } = promo_campaign_page
|
|
const bookingCode = page_settings?.booking_code || null
|
|
|
|
return {
|
|
...data,
|
|
promo_campaign_page: {
|
|
bookingCode,
|
|
...promoCampaignPageData,
|
|
},
|
|
}
|
|
})
|
|
|
|
/** REFS */
|
|
export const promoCampaignPageRefsSchema = z.object({
|
|
promo_campaign_page: z.object({
|
|
system: systemSchema,
|
|
}),
|
|
})
|