Merged in feat/SW-286-collectionPage (pull request #765)

Feat(SW-286): CollectionPage

Approved-by: Erik Tiekstra
Approved-by: Fredrik Thorsson
This commit is contained in:
Matilda Landström
2024-11-04 12:10:51 +00:00
parent dabdd597e2
commit d5efaa686c
45 changed files with 918 additions and 35 deletions

View File

@@ -11,6 +11,7 @@ import { imageContainerSchema } from "./imageContainer"
import { BlocksEnums } from "@/types/enums/blocks"
import { CardsGridEnum, CardsGridLayoutEnum } from "@/types/enums/cardsGrid"
import { scriptedCardThemeEnum } from "@/types/enums/scriptedCard"
export const cardBlockSchema = z.object({
__typename: z.literal(CardsGridEnum.cards.Card),
@@ -161,7 +162,7 @@ export const cardsGridSchema = z.object({
}),
layout: z.nativeEnum(CardsGridLayoutEnum),
preamble: z.string().optional().default(""),
theme: z.enum(["one", "two", "three"]).nullable(),
theme: z.nativeEnum(scriptedCardThemeEnum).nullable(),
title: z.string().optional().default(""),
})
.transform((data) => {

View File

@@ -5,6 +5,7 @@ import * as pageLinks from "@/server/routers/contentstack/schemas/pageLinks"
const linkUnionSchema = z.discriminatedUnion("__typename", [
pageLinks.contentPageSchema,
pageLinks.collectionPageSchema,
pageLinks.hotelPageSchema,
pageLinks.loyaltyPageSchema,
])

View File

@@ -30,6 +30,16 @@ export const extendedPageLinkSchema = pageLinkSchema.merge(
}),
})
)
export const collectionPageSchema = z
.object({
__typename: z.literal(ContentEnum.blocks.CollectionPage),
})
.merge(extendedPageLinkSchema)
export const collectionPageRefSchema = z.object({
__typename: z.literal(ContentEnum.blocks.CollectionPage),
system: systemSchema,
})
export const contentPageSchema = z
.object({
@@ -67,6 +77,7 @@ export const loyaltyPageRefSchema = z.object({
type Data =
| z.output<typeof accountPageSchema>
| z.output<typeof contentPageSchema>
| z.output<typeof collectionPageSchema>
| z.output<typeof hotelPageSchema>
| z.output<typeof loyaltyPageSchema>
| Object
@@ -83,6 +94,7 @@ export function transform(data: Data) {
url: removeMultipleSlashes(`/${data.system.locale}/${data.url}`),
}
case ContentEnum.blocks.ContentPage:
case ContentEnum.blocks.CollectionPage:
case ContentEnum.blocks.LoyaltyPage:
// TODO: Once all links use this transform
// `web` can be removed and not to be worried
@@ -102,6 +114,7 @@ export function transform(data: Data) {
type RefData =
| z.output<typeof accountPageRefSchema>
| z.output<typeof collectionPageRefSchema>
| z.output<typeof contentPageRefSchema>
| z.output<typeof hotelPageRefSchema>
| z.output<typeof loyaltyPageRefSchema>
@@ -112,6 +125,7 @@ export function transformRef(data: RefData) {
switch (data.__typename) {
case ContentEnum.blocks.AccountPage:
case ContentEnum.blocks.ContentPage:
case ContentEnum.blocks.CollectionPage:
case ContentEnum.blocks.HotelPage:
case ContentEnum.blocks.LoyaltyPage:
return data.system

View File

@@ -7,6 +7,7 @@ import {
transformCardBlockRefs,
} from "../blocks/cardsGrid"
import { scriptedCardThemeEnum } from "@/types/enums/scriptedCard"
import { SidebarEnums } from "@/types/enums/sidebar"
export const scriptedCardsSchema = z.object({
@@ -16,17 +17,7 @@ export const scriptedCardsSchema = z.object({
.default(SidebarEnums.blocks.ScriptedCard),
scripted_card: z
.object({
theme: z
.enum([
"one",
"two",
"three",
"primaryDim",
"primaryDark",
"primaryInverted",
"primaryStrong",
])
.nullable(),
theme: z.nativeEnum(scriptedCardThemeEnum).nullable(),
scripted_cardConnection: z.object({
edges: z.array(
z.object({