Merge branch 'develop' into feature/tracking

This commit is contained in:
Linus Flood
2024-10-30 14:12:24 +01:00
261 changed files with 3397 additions and 2854 deletions

View File

@@ -26,7 +26,7 @@ export const bookingwidgetQueryRouter = router({
const failedResponse = { hideBookingWidget: false }
const { contentType, uid, lang } = ctx
// This condition is to handle 404 page case
// This condition is to handle 404 page case and booking flow
if (!contentType || !uid) {
console.log("No proper params defined: ", contentType, uid)
return failedResponse

View File

@@ -19,7 +19,11 @@ import {
TrackingChannelEnum,
type TrackingSDKPageData,
} from "@/types/components/tracking"
import type { GetContentPageSchema } from "@/types/trpc/routers/contentstack/contentPage"
import { ContentPageEnum } from "@/types/enums/contentPage"
import type {
GetBlock,
GetContentPageSchema,
} from "@/types/trpc/routers/contentstack/contentPage"
export const contentPageQueryRouter = router({
get: contentstackExtendedProcedureUID.query(async ({ ctx }) => {
@@ -79,21 +83,36 @@ export const contentPageQueryRouter = router({
),
])
const blocksOrder = mainResponse.data.content_page.blocks?.map(
(block) => block.__typename
)
let sortedBlocks
if (blocksOrder) {
const blocks = [
blocksResponse1.data.content_page.blocks,
blocksResponse2.data.content_page.blocks,
]
.flat(2)
.filter((obj) => !(obj && Object.keys(obj).length < 2))
// Remove empty objects and objects with only typename
sortedBlocks = blocksOrder
.map((typename: ContentPageEnum.ContentStack.blocks) =>
blocks.find((block) => block?.__typename === typename)
)
.filter((block): block is GetBlock => !!block)
}
const responseData = {
...mainResponse.data,
content_page: {
...mainResponse.data.content_page,
blocks: [
blocksResponse1.data.content_page.blocks,
blocksResponse2.data.content_page.blocks,
]
.flat(2)
.filter((obj) => !(obj && Object.keys(obj).length < 2)), // Remove empty objects and objects with only typename
blocks: sortedBlocks,
},
}
const contentPage = contentPageSchema.safeParse(responseData)
if (!contentPage.success) {
console.error(
`Failed to validate Contentpage Data - (lang: ${lang}, uid: ${uid})`

View File

@@ -75,7 +75,7 @@ function getUniqueRewardIds(rewardIds: string[]) {
const getAllCachedApiRewards = unstable_cache(
async function (token) {
const apiResponse = await api.get(api.endpoints.v1.tierRewards, {
const apiResponse = await api.get(api.endpoints.v1.Profile.tierRewards, {
headers: {
Authorization: `Bearer ${token}`,
},
@@ -194,7 +194,7 @@ export const rewardQueryRouter = router({
const { limit, cursor } = input
const apiResponse = await api.get(api.endpoints.v1.rewards, {
const apiResponse = await api.get(api.endpoints.v1.Profile.reward, {
cache: undefined, // override defaultOptions
headers: {
Authorization: `Bearer ${ctx.session.token.access_token}`,
@@ -393,7 +393,7 @@ export const rewardQueryRouter = router({
surprises: contentStackBaseWithProtectedProcedure.query(async ({ ctx }) => {
getCurrentRewardCounter.add(1)
const apiResponse = await api.get(api.endpoints.v1.rewards, {
const apiResponse = await api.get(api.endpoints.v1.Profile.reward, {
cache: undefined, // override defaultOptions
headers: {
Authorization: `Bearer ${ctx.session.token.access_token}`,