feat(LOY-135): change redeem description to be RTE

This commit is contained in:
Christian Andolf
2025-02-14 16:37:56 +01:00
parent 9b61417264
commit a192d32f7e
5 changed files with 236 additions and 31 deletions
+47 -4
View File
@@ -2,6 +2,13 @@ import { z } from "zod"
import { MembershipLevelEnum } from "@/constants/membershipLevels"
import {
linkRefsUnionSchema,
linkUnionSchema,
transformPageLink,
} from "../schemas/pageLinks"
import { systemSchema } from "../schemas/system"
const Coupon = z.object({
code: z.string().optional(),
status: z.string().optional(),
@@ -133,10 +140,22 @@ export const validateCmsRewardsWithRedeemSchema = z
reward_id: z.string(),
grouped_label: z.string().optional(),
description: z.string().optional(),
redeem_description: z
.string()
.nullable()
.transform((val) => val || ""),
redeem_description: z.object({
json: z.any(), // JSON
embedded_itemsConnection: z.object({
edges: z.array(
z.object({
node: linkUnionSchema.transform((data) => {
const link = transformPageLink(data)
if (link) {
return link
}
return data
}),
})
),
}),
}),
grouped_description: z.string().optional(),
value: z.string().optional(),
})
@@ -156,6 +175,30 @@ export type CmsRewardsWithRedeemResponse = z.input<
typeof validateCmsRewardsWithRedeemSchema
>
export const rewardWithRedeemRefsSchema = z.object({
data: z.object({
all_reward: z.object({
items: z.array(
z.object({
redeem_description: z.object({
embedded_itemsConnection: z.object({
edges: z.array(
z.object({
node: linkRefsUnionSchema,
})
),
}),
}),
system: systemSchema,
})
),
}),
}),
})
export interface GetRewardWithRedeemRefsSchema
extends z.input<typeof rewardWithRedeemRefsSchema> {}
export type CMSReward = z.output<typeof validateCmsRewardsSchema>[0]
export type CMSRewardWithRedeem = z.output<