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,12 +5,9 @@ import { nullableStringValidator } from "@scandic-hotels/common/utils/zod/string
|
||||
|
||||
import { HotelPageEnum } from "../../../types/hotelPageEnum"
|
||||
import { discriminatedUnionArray } from "../../../utils/discriminatedUnion"
|
||||
import {
|
||||
activitiesCardRefSchema,
|
||||
activitiesCardSchema,
|
||||
} from "../schemas/blocks/activitiesCard"
|
||||
import { hotelFaqRefsSchema, hotelFaqSchema } from "../schemas/blocks/hotelFaq"
|
||||
import { spaPageRefSchema, spaPageSchema } from "../schemas/blocks/spaPage"
|
||||
import { activitiesCardSchema } from "../schemas/blocks/activitiesCard"
|
||||
import { hotelFaqSchema } from "../schemas/blocks/hotelFaq"
|
||||
import { spaPageSchema } from "../schemas/blocks/spaPage"
|
||||
import { systemSchema } from "../schemas/system"
|
||||
|
||||
import type { ActivitiesCard, SpaPage } from "../../../types/hotelPage"
|
||||
@@ -112,35 +109,6 @@ export const hotelPageSchema = z.object({
|
||||
})),
|
||||
})
|
||||
|
||||
/** REFS */
|
||||
const hotelPageActivitiesCardRefs = z
|
||||
.object({
|
||||
__typename: z.literal(HotelPageEnum.ContentStack.blocks.ActivitiesCard),
|
||||
})
|
||||
.merge(activitiesCardRefSchema)
|
||||
|
||||
const hotelPageSpaPageRefs = z
|
||||
.object({
|
||||
__typename: z.literal(HotelPageEnum.ContentStack.blocks.SpaPage),
|
||||
})
|
||||
.merge(spaPageRefSchema)
|
||||
|
||||
const hotelPageBlockRefsItem = z.discriminatedUnion("__typename", [
|
||||
hotelPageActivitiesCardRefs,
|
||||
hotelPageSpaPageRefs,
|
||||
])
|
||||
|
||||
export const hotelPageRefsSchema = z.object({
|
||||
hotel_page: z.object({
|
||||
content: discriminatedUnionArray(hotelPageBlockRefsItem.options).nullable(),
|
||||
faq: hotelFaqRefsSchema.nullable(),
|
||||
system: systemSchema,
|
||||
}),
|
||||
trackingProps: z.object({
|
||||
url: z.string(),
|
||||
}),
|
||||
})
|
||||
|
||||
export const hotelPageUrlsSchema = z
|
||||
.object({
|
||||
all_hotel_page: z.object({
|
||||
|
||||
Reference in New Issue
Block a user