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

This commit is contained in:
Linus Flood
2024-12-05 15:12:09 +01:00
114 changed files with 1388 additions and 653 deletions

View File

@@ -238,15 +238,18 @@ export const rewardQueryRouter = router({
const nextCursor =
limit + cursor < rewardIds.length ? limit + cursor : undefined
const surprisesIds = validatedApiRewards.data
const wrappedSurprisesIds = validatedApiRewards.data
.filter(
({ type, rewardType }) =>
type === "coupon" && rewardType === "Surprise"
(reward) =>
reward.type === "coupon" &&
reward.rewardType === "Surprise" &&
"coupon" in reward &&
reward.coupon?.some(({ unwrapped }) => !unwrapped)
)
.map(({ rewardId }) => rewardId)
const rewards = cmsRewards.filter(
(reward) => !surprisesIds.includes(reward.reward_id)
(reward) => !wrappedSurprisesIds.includes(reward.reward_id)
)
getCurrentRewardSuccessCounter.add(1)

View File

@@ -19,31 +19,33 @@ export const activitiesCardSchema = z.object({
body_text: z.string(),
cta_text: z.string(),
heading: z.string(),
open_in_new_tab: z.boolean(),
scripted_title: z.string().optional(),
hotel_page_activities_content_pageConnection: z.object({
edges: z.array(
z.object({
node: z.discriminatedUnion("__typename", [
pageLinks.contentPageSchema,
pageLinks.contentPageSchema.extend({
header: z.object({
preamble: z.string(),
}),
}),
]),
})
),
}),
})
.transform((data) => {
let contentPage = { href: "" }
let contentPage = { href: "", preamble: "" }
if (data.hotel_page_activities_content_pageConnection.edges.length) {
const page =
data.hotel_page_activities_content_pageConnection.edges[0].node
contentPage.preamble = page.header.preamble
if (page.web.original_url) {
contentPage = {
href: page.web.original_url,
}
contentPage.href = page.web.original_url
} else {
contentPage = {
href: removeMultipleSlashes(`/${page.system.locale}/${page.url}`),
}
contentPage.href = removeMultipleSlashes(
`/${page.system.locale}/${page.url}`
)
}
}
return {
@@ -52,7 +54,6 @@ export const activitiesCardSchema = z.object({
contentPage,
ctaText: data.cta_text,
heading: data.heading,
openInNewTab: !!data.open_in_new_tab,
scriptedTopTitle: data.scripted_title,
}
}),