fix(SW-438): fix sidebar refs

This commit is contained in:
Matilda Landström
2024-10-16 08:11:55 +02:00
parent 01db5aa192
commit e5eb6a5331
6 changed files with 41 additions and 5 deletions

View File

@@ -29,6 +29,7 @@ fragment ContentCardSidebar_ContentPageRefs on ContentPageSidebarContentCard {
content_cardConnection { content_cardConnection {
edges { edges {
node { node {
__typename
...TeaserCardBlockRef ...TeaserCardBlockRef
} }
} }

View File

@@ -17,6 +17,7 @@ fragment QuickLinksSidebar_ContentPage on ContentPageSidebarShortcuts {
fragment QuickLinksSidebar_ContentPageRefs on ContentPageSidebarShortcuts { fragment QuickLinksSidebar_ContentPageRefs on ContentPageSidebarShortcuts {
shortcuts { shortcuts {
__typename
...ShortcutsRefs ...ShortcutsRefs
} }
} }

View File

@@ -24,11 +24,12 @@ fragment ScriptedCardSidebar_ContentPage on ContentPageSidebarScriptedCard {
} }
} }
fragment ScriptedCardSidebar_ContentPageRefs on ContentPageSidebarContentCard { fragment ScriptedCardSidebar_ContentPageRefs on ContentPageSidebarScriptedCard {
scripted_card { scripted_card {
scripted_cardConnection { scripted_cardConnection {
edges { edges {
node { node {
__typename
...CardBlockRef ...CardBlockRef
} }
} }

View File

@@ -96,7 +96,10 @@ query GetContentPageRefs($locale: String!, $uid: String!) {
sidebar { sidebar {
__typename __typename
...ContentSidebar_ContentPageRefs ...ContentSidebar_ContentPageRefs
...ContentCardSidebar_ContentPageRefs
...JoinLoyaltyContactSidebar_ContentPageRefs ...JoinLoyaltyContactSidebar_ContentPageRefs
...ScriptedCardSidebar_ContentPageRefs
...QuickLinksSidebar_ContentPageRefs
} }
system { system {
...System ...System

View File

@@ -34,14 +34,23 @@ import {
contentRefsSchema as sidebarContentRefsSchema, contentRefsSchema as sidebarContentRefsSchema,
contentSchema as sidebarContentSchema, contentSchema as sidebarContentSchema,
} from "../schemas/sidebar/content" } from "../schemas/sidebar/content"
import { contentCardsSchema } from "../schemas/sidebar/contentCard" import {
contentCardRefschema,
contentCardsSchema,
} from "../schemas/sidebar/contentCard"
import { dynamicContentSchema as sidebarDynamicContentSchema } from "../schemas/sidebar/dynamicContent" import { dynamicContentSchema as sidebarDynamicContentSchema } from "../schemas/sidebar/dynamicContent"
import { import {
joinLoyaltyContactRefsSchema, joinLoyaltyContactRefsSchema,
joinLoyaltyContactSchema, joinLoyaltyContactSchema,
} from "../schemas/sidebar/joinLoyaltyContact" } from "../schemas/sidebar/joinLoyaltyContact"
import { quickLinksSchema } from "../schemas/sidebar/quickLinks" import {
import { scriptedCardsSchema } from "../schemas/sidebar/scriptedCard" quickLinksRefschema,
quickLinksSchema,
} from "../schemas/sidebar/quickLinks"
import {
scriptedCardRefschema,
scriptedCardsSchema,
} from "../schemas/sidebar/scriptedCard"
import { systemSchema } from "../schemas/system" import { systemSchema } from "../schemas/system"
import { ContentPageEnum } from "@/types/enums/contentPage" import { ContentPageEnum } from "@/types/enums/contentPage"
@@ -254,6 +263,12 @@ const contentPageSidebarContentRef = z
}) })
.merge(sidebarContentRefsSchema) .merge(sidebarContentRefsSchema)
const contentPageSidebarContentCardRef = z
.object({
__typename: z.literal(ContentPageEnum.ContentStack.sidebar.ContentCard),
})
.merge(contentCardRefschema)
const contentPageSidebarJoinLoyaltyContactRef = z const contentPageSidebarJoinLoyaltyContactRef = z
.object({ .object({
__typename: z.literal( __typename: z.literal(
@@ -262,9 +277,24 @@ const contentPageSidebarJoinLoyaltyContactRef = z
}) })
.merge(joinLoyaltyContactRefsSchema) .merge(joinLoyaltyContactRefsSchema)
const contentPageSidebarScriptedCardRef = z
.object({
__typename: z.literal(ContentPageEnum.ContentStack.sidebar.ScriptedCard),
})
.merge(scriptedCardRefschema)
const contentPageSidebarQuickLinksRef = z
.object({
__typename: z.literal(ContentPageEnum.ContentStack.sidebar.QuickLinks),
})
.merge(quickLinksRefschema)
const contentPageSidebarRefsItem = z.discriminatedUnion("__typename", [ const contentPageSidebarRefsItem = z.discriminatedUnion("__typename", [
contentPageSidebarContentRef, contentPageSidebarContentRef,
contentPageSidebarContentCardRef,
contentPageSidebarJoinLoyaltyContactRef, contentPageSidebarJoinLoyaltyContactRef,
contentPageSidebarScriptedCardRef,
contentPageSidebarQuickLinksRef,
]) ])
const contentPageHeaderRefs = z.object({ const contentPageHeaderRefs = z.object({

View File

@@ -43,7 +43,7 @@ export const scriptedCardsSchema = z.object({
}) })
export const scriptedCardRefschema = z.object({ export const scriptedCardRefschema = z.object({
cripted_card: z.object({ scripted_card: z.object({
scripted_cardConnection: z.object({ scripted_cardConnection: z.object({
edges: z.array( edges: z.array(
z.object({ z.object({