refactor(SW-438): change name to teasercard

This commit is contained in:
Matilda Landström
2024-10-16 10:21:34 +02:00
parent 8eb822da16
commit df17798662
8 changed files with 60 additions and 62 deletions

View File

@@ -34,10 +34,6 @@ import {
contentRefsSchema as sidebarContentRefsSchema,
contentSchema as sidebarContentSchema,
} from "../schemas/sidebar/content"
import {
contentCardRefschema,
contentCardsSchema,
} from "../schemas/sidebar/contentCard"
import { dynamicContentSchema as sidebarDynamicContentSchema } from "../schemas/sidebar/dynamicContent"
import {
joinLoyaltyContactRefsSchema,
@@ -51,6 +47,10 @@ import {
scriptedCardRefschema,
scriptedCardsSchema,
} from "../schemas/sidebar/scriptedCard"
import {
teaserCardRefschema,
teaserCardsSchema,
} from "../schemas/sidebar/teaserCard"
import { systemSchema } from "../schemas/system"
import { ContentPageEnum } from "@/types/enums/contentPage"
@@ -134,30 +134,30 @@ export const contentPageJoinLoyaltyContact = z
})
.merge(joinLoyaltyContactSchema)
export const contentPageSidebarQuicklinks = z
.object({
__typename: z.literal(ContentPageEnum.ContentStack.sidebar.QuickLinks),
})
.merge(quickLinksSchema)
export const contentPageSidebarContentCard = z
.object({
__typename: z.literal(ContentPageEnum.ContentStack.sidebar.ContentCard),
})
.merge(contentCardsSchema)
export const contentPageSidebarScriptedCard = z
.object({
__typename: z.literal(ContentPageEnum.ContentStack.sidebar.ScriptedCard),
})
.merge(scriptedCardsSchema)
export const contentPageSidebarTeaserCard = z
.object({
__typename: z.literal(ContentPageEnum.ContentStack.sidebar.TeaserCard),
})
.merge(teaserCardsSchema)
export const contentPageSidebarQuicklinks = z
.object({
__typename: z.literal(ContentPageEnum.ContentStack.sidebar.QuickLinks),
})
.merge(quickLinksSchema)
export const sidebarSchema = z.discriminatedUnion("__typename", [
contentPageSidebarContent,
contentPageSidebarContentCard,
contentPageSidebarDynamicContent,
contentPageJoinLoyaltyContact,
contentPageSidebarScriptedCard,
contentPageSidebarTeaserCard,
contentPageSidebarQuicklinks,
])
@@ -263,12 +263,6 @@ const contentPageSidebarContentRef = z
})
.merge(sidebarContentRefsSchema)
const contentPageSidebarContentCardRef = z
.object({
__typename: z.literal(ContentPageEnum.ContentStack.sidebar.ContentCard),
})
.merge(contentCardRefschema)
const contentPageSidebarJoinLoyaltyContactRef = z
.object({
__typename: z.literal(
@@ -283,6 +277,12 @@ const contentPageSidebarScriptedCardRef = z
})
.merge(scriptedCardRefschema)
const contentPageSidebarTeaserCardRef = z
.object({
__typename: z.literal(ContentPageEnum.ContentStack.sidebar.TeaserCard),
})
.merge(teaserCardRefschema)
const contentPageSidebarQuickLinksRef = z
.object({
__typename: z.literal(ContentPageEnum.ContentStack.sidebar.QuickLinks),
@@ -291,9 +291,9 @@ const contentPageSidebarQuickLinksRef = z
const contentPageSidebarRefsItem = z.discriminatedUnion("__typename", [
contentPageSidebarContentRef,
contentPageSidebarContentCardRef,
contentPageSidebarJoinLoyaltyContactRef,
contentPageSidebarScriptedCardRef,
contentPageSidebarTeaserCardRef,
contentPageSidebarQuickLinksRef,
])

View File

@@ -171,11 +171,6 @@ export function getConnections({ content_page }: ContentPageRefs) {
connections.push(...block.content)
}
break
case ContentPageEnum.ContentStack.sidebar.ContentCard:
if (block.content_card?.length) {
connections.push(...block.content_card)
}
break
case ContentPageEnum.ContentStack.sidebar.JoinLoyaltyContact:
if (block.join_loyalty_contact?.button) {
connections.push(block.join_loyalty_contact.button)
@@ -186,6 +181,11 @@ export function getConnections({ content_page }: ContentPageRefs) {
connections.push(...block.scripted_card)
}
break
case ContentPageEnum.ContentStack.sidebar.TeaserCard:
if (block.teaser_card?.length) {
connections.push(...block.teaser_card)
}
break
case ContentPageEnum.ContentStack.sidebar.QuickLinks:
if (block.shortcuts.shortcuts.length) {
connections.push(...block.shortcuts.shortcuts)