Merged in feat/rework-contentstack (pull request #3493)
Feat(SW-3708): refactor contentstack fetching (removing all refs) and cache invalidation * Remove all REFS * Revalidate correct language * PR fixes * PR fixes * Throw when errors from contentstack api Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -5,20 +5,11 @@ import { removeMultipleSlashes } from "@scandic-hotels/common/utils/url"
|
||||
|
||||
import { CampaignPageEnum } from "../../../types/campaignPage"
|
||||
import { discriminatedUnionArray } from "../../../utils/discriminatedUnion"
|
||||
import {
|
||||
accordionRefsSchema,
|
||||
accordionSchema,
|
||||
} from "../schemas/blocks/accordion"
|
||||
import {
|
||||
carouselCardsRefsSchema,
|
||||
carouselCardsSchema,
|
||||
} from "../schemas/blocks/carouselCards"
|
||||
import { accordionSchema } from "../schemas/blocks/accordion"
|
||||
import { carouselCardsSchema } from "../schemas/blocks/carouselCards"
|
||||
import { essentialsBlockSchema } from "../schemas/blocks/essentials"
|
||||
import { campaignPageHotelListingSchema } from "../schemas/blocks/hotelListing"
|
||||
import {
|
||||
linkConnectionRefs,
|
||||
linkConnectionSchema,
|
||||
} from "../schemas/linkConnection"
|
||||
import { linkConnectionSchema } from "../schemas/linkConnection"
|
||||
import { systemSchema } from "../schemas/system"
|
||||
import { getCarouselCardsBlockWithBookingCodeLinks } from "./utils"
|
||||
|
||||
@@ -258,46 +249,3 @@ export const campaignPagesByHotelUidSchema = z
|
||||
}),
|
||||
})
|
||||
.transform((data) => data.all_campaign_page.items)
|
||||
|
||||
/** REFS */
|
||||
const campaignPageCarouselCardsRef = z
|
||||
.object({
|
||||
__typename: z.literal(CampaignPageEnum.ContentStack.blocks.CarouselCards),
|
||||
})
|
||||
.merge(carouselCardsRefsSchema)
|
||||
|
||||
const campaignPageAccordionRefs = z
|
||||
.object({
|
||||
__typename: z.literal(CampaignPageEnum.ContentStack.blocks.Accordion),
|
||||
})
|
||||
.merge(accordionRefsSchema)
|
||||
|
||||
const campaignPageBlockRefsItem = z.discriminatedUnion("__typename", [
|
||||
campaignPageCarouselCardsRef,
|
||||
campaignPageAccordionRefs,
|
||||
])
|
||||
const heroRefsSchema = z.object({
|
||||
button: linkConnectionRefs,
|
||||
})
|
||||
|
||||
export const campaignPageRefsSchema = z.object({
|
||||
campaign_page: z.object({
|
||||
hero: heroRefsSchema,
|
||||
blocks: discriminatedUnionArray(
|
||||
campaignPageBlockRefsItem.options
|
||||
).nullable(),
|
||||
system: systemSchema,
|
||||
}),
|
||||
})
|
||||
|
||||
export const campaignPagesByHotelUidRefsSchema = z
|
||||
.object({
|
||||
all_campaign_page: z.object({
|
||||
items: z.array(
|
||||
z.object({
|
||||
system: systemSchema,
|
||||
})
|
||||
),
|
||||
}),
|
||||
})
|
||||
.transform((data) => data.all_campaign_page.items.map((item) => item.system))
|
||||
|
||||
Reference in New Issue
Block a user