Merge remote-tracking branch 'origin' into feature/tracking

This commit is contained in:
Linus Flood
2024-12-16 09:11:28 +01:00
42 changed files with 630 additions and 325 deletions

View File

@@ -161,10 +161,14 @@ export type CMSRewardWithRedeem = z.output<
export type Reward = CMSReward & {
id: string | undefined
rewardType: string | undefined
redeemLocation: string | undefined
}
export type RewardWithRedeem = CMSRewardWithRedeem & {
id: string | undefined
rewardType: string | undefined
redeemLocation: string | undefined
}
// New endpoint related types and schemas.
@@ -172,10 +176,11 @@ export type RewardWithRedeem = CMSRewardWithRedeem & {
const BenefitReward = z.object({
title: z.string().optional(),
id: z.string().optional(),
status: z.string().optional(),
redeemLocation: z.string().optional(),
rewardId: z.string().optional(),
rewardType: z.string().optional(),
rewardTierLevel: z.string().optional(),
status: z.string().optional(),
})
const CouponState = z.enum(["claimed", "redeemed", "viewed"])
@@ -191,6 +196,7 @@ const CouponReward = z.object({
id: z.string().optional(),
rewardId: z.string().optional(),
rewardType: z.string().optional(),
redeemLocation: z.string().optional(),
status: z.string().optional(),
coupon: z.array(CouponData).optional(),
})
@@ -224,3 +230,7 @@ export const validateApiAllTiersSchema = z.record(
}),
z.array(BenefitReward)
)
export type RedeemLocation = "Non-redeemable" | "On-site" | "Online"
export type RewardType = "Tier" | "Member-voucher" | "Surprise" | "Campaign"

View File

@@ -16,9 +16,10 @@ import {
rewardsUpdateInput,
} from "./input"
import {
type
Reward, validateApiRewardSchema,
validateCategorizedRewardsSchema} from "./output"
type Reward,
validateApiRewardSchema,
validateCategorizedRewardsSchema,
} from "./output"
import {
getAllCachedApiRewards,
getAllRewardCounter,
@@ -41,7 +42,6 @@ import {
getUnwrapSurpriseSuccessCounter,
} from "./utils"
const ONE_HOUR = 60 * 60
export const rewardQueryRouter = router({
@@ -245,13 +245,17 @@ export const rewardQueryRouter = router({
.map(({ rewardId }) => rewardId)
const rewards = cmsRewards
.filter((reward) => !wrappedSurprisesIds.includes(reward.reward_id))
.map((reward) => {
.filter((cmsReward) => !wrappedSurprisesIds.includes(cmsReward.reward_id))
.map((cmsReward) => {
const apiReward = validatedApiRewards.data.find(
({ rewardId }) => rewardId === cmsReward.reward_id
)
return {
...reward,
id: validatedApiRewards.data.find(
({ rewardId }) => rewardId === reward.reward_id
)?.id,
...cmsReward,
id: apiReward?.id,
rewardType: apiReward?.rewardType,
redeemLocation: apiReward?.redeemLocation,
}
})
@@ -364,6 +368,8 @@ export const rewardQueryRouter = router({
return {
...reward,
id: surprise.id,
rewardType: surprise.rewardType,
redeemLocation: surprise.redeemLocation,
coupons: "coupon" in surprise ? surprise.coupon || [] : [],
}
})

View File

@@ -105,8 +105,18 @@ const hotelContentSchema = z.object({
imageSizes: imageSizesSchema,
})
.default({
metaData: { title: "", altText: "", altText_En: "", copyRight: "" },
imageSizes: { tiny: "", small: "", medium: "", large: "" },
metaData: {
title: "default image",
altText: "default image",
altText_En: "default image",
copyRight: "default image",
},
imageSizes: {
tiny: "https://placehold.co/1280x720",
small: "https://placehold.co/1280x720",
medium: "https://placehold.co/1280x720",
large: "https://placehold.co/1280x720",
},
}),
texts: z.object({
facilityInformation: z.string().optional(),