refactor(SW-438): change name to teasercard
This commit is contained in:
@@ -29,16 +29,6 @@ export default function Sidebar({ blocks }: SidebarProps) {
|
|||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
case SidebarEnums.blocks.ContentCard:
|
|
||||||
return (
|
|
||||||
<TeaserCard
|
|
||||||
{...block.content_card}
|
|
||||||
title={block.content_card.heading}
|
|
||||||
description={block.content_card.body_text}
|
|
||||||
style={block.content_card.theme}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
|
|
||||||
case SidebarEnums.blocks.DynamicContent:
|
case SidebarEnums.blocks.DynamicContent:
|
||||||
switch (block.dynamic_content.component) {
|
switch (block.dynamic_content.component) {
|
||||||
case DynamicContentEnum.Sidebar.components.my_pages_navigation:
|
case DynamicContentEnum.Sidebar.components.my_pages_navigation:
|
||||||
@@ -62,7 +52,15 @@ export default function Sidebar({ blocks }: SidebarProps) {
|
|||||||
theme={block.scripted_card.theme ?? "image"}
|
theme={block.scripted_card.theme ?? "image"}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
case SidebarEnums.blocks.TeaserCard:
|
||||||
|
return (
|
||||||
|
<TeaserCard
|
||||||
|
{...block.teaser_card}
|
||||||
|
title={block.teaser_card.heading}
|
||||||
|
description={block.teaser_card.body_text}
|
||||||
|
style={block.teaser_card.theme}
|
||||||
|
/>
|
||||||
|
)
|
||||||
case SidebarEnums.blocks.QuickLinks:
|
case SidebarEnums.blocks.QuickLinks:
|
||||||
return <ShortcutsList {...block.shortcuts} />
|
return <ShortcutsList {...block.shortcuts} />
|
||||||
|
|
||||||
|
|||||||
@@ -9,11 +9,11 @@
|
|||||||
#import "../Blocks/TeaserCard.graphql"
|
#import "../Blocks/TeaserCard.graphql"
|
||||||
#import "../Blocks/Refs/TeaserCard.graphql"
|
#import "../Blocks/Refs/TeaserCard.graphql"
|
||||||
|
|
||||||
fragment ContentCardSidebar_ContentPage on ContentPageSidebarContentCard {
|
fragment TeaserCardSidebar_ContentPage on ContentPageSidebarTeaserCard {
|
||||||
__typename
|
__typename
|
||||||
content_card {
|
teaser_card {
|
||||||
theme
|
theme
|
||||||
content_cardConnection {
|
teaser_cardConnection {
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
__typename
|
__typename
|
||||||
@@ -24,9 +24,9 @@ fragment ContentCardSidebar_ContentPage on ContentPageSidebarContentCard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment ContentCardSidebar_ContentPageRefs on ContentPageSidebarContentCard {
|
fragment TeaserCardSidebar_ContentPageRefs on ContentPageSidebarTeaserCard {
|
||||||
content_card {
|
teaser_card {
|
||||||
content_cardConnection {
|
teaser_cardConnection {
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
__typename
|
__typename
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
#import "../../Fragments/Sidebar/Content.graphql"
|
#import "../../Fragments/Sidebar/Content.graphql"
|
||||||
#import "../../Fragments/Sidebar/DynamicContent.graphql"
|
#import "../../Fragments/Sidebar/DynamicContent.graphql"
|
||||||
#import "../../Fragments/Sidebar/JoinLoyaltyContact.graphql"
|
#import "../../Fragments/Sidebar/JoinLoyaltyContact.graphql"
|
||||||
#import "../../Fragments/Sidebar/ContentCard.graphql"
|
#import "../../Fragments/Sidebar/TeaserCard.graphql"
|
||||||
#import "../../Fragments/Sidebar/ScriptedCard.graphql"
|
#import "../../Fragments/Sidebar/ScriptedCard.graphql"
|
||||||
#import "../../Fragments/Sidebar/QuickLinks.graphql"
|
#import "../../Fragments/Sidebar/QuickLinks.graphql"
|
||||||
|
|
||||||
@@ -31,8 +31,8 @@ query GetContentPage($locale: String!, $uid: String!) {
|
|||||||
...ContentSidebar_ContentPage
|
...ContentSidebar_ContentPage
|
||||||
...DynamicContentSidebar_ContentPage
|
...DynamicContentSidebar_ContentPage
|
||||||
...JoinLoyaltyContactSidebar_ContentPage
|
...JoinLoyaltyContactSidebar_ContentPage
|
||||||
...ContentCardSidebar_ContentPage
|
|
||||||
...ScriptedCardSidebar_ContentPage
|
...ScriptedCardSidebar_ContentPage
|
||||||
|
...TeaserCardSidebar_ContentPage
|
||||||
...QuickLinksSidebar_ContentPage
|
...QuickLinksSidebar_ContentPage
|
||||||
}
|
}
|
||||||
system {
|
system {
|
||||||
@@ -96,9 +96,9 @@ query GetContentPageRefs($locale: String!, $uid: String!) {
|
|||||||
sidebar {
|
sidebar {
|
||||||
__typename
|
__typename
|
||||||
...ContentSidebar_ContentPageRefs
|
...ContentSidebar_ContentPageRefs
|
||||||
...ContentCardSidebar_ContentPageRefs
|
|
||||||
...JoinLoyaltyContactSidebar_ContentPageRefs
|
...JoinLoyaltyContactSidebar_ContentPageRefs
|
||||||
...ScriptedCardSidebar_ContentPageRefs
|
...ScriptedCardSidebar_ContentPageRefs
|
||||||
|
...TeaserCardSidebar_ContentPageRefs
|
||||||
...QuickLinksSidebar_ContentPageRefs
|
...QuickLinksSidebar_ContentPageRefs
|
||||||
}
|
}
|
||||||
system {
|
system {
|
||||||
|
|||||||
@@ -34,10 +34,6 @@ import {
|
|||||||
contentRefsSchema as sidebarContentRefsSchema,
|
contentRefsSchema as sidebarContentRefsSchema,
|
||||||
contentSchema as sidebarContentSchema,
|
contentSchema as sidebarContentSchema,
|
||||||
} from "../schemas/sidebar/content"
|
} from "../schemas/sidebar/content"
|
||||||
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,
|
||||||
@@ -51,6 +47,10 @@ import {
|
|||||||
scriptedCardRefschema,
|
scriptedCardRefschema,
|
||||||
scriptedCardsSchema,
|
scriptedCardsSchema,
|
||||||
} from "../schemas/sidebar/scriptedCard"
|
} from "../schemas/sidebar/scriptedCard"
|
||||||
|
import {
|
||||||
|
teaserCardRefschema,
|
||||||
|
teaserCardsSchema,
|
||||||
|
} from "../schemas/sidebar/teaserCard"
|
||||||
import { systemSchema } from "../schemas/system"
|
import { systemSchema } from "../schemas/system"
|
||||||
|
|
||||||
import { ContentPageEnum } from "@/types/enums/contentPage"
|
import { ContentPageEnum } from "@/types/enums/contentPage"
|
||||||
@@ -134,30 +134,30 @@ export const contentPageJoinLoyaltyContact = z
|
|||||||
})
|
})
|
||||||
.merge(joinLoyaltyContactSchema)
|
.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
|
export const contentPageSidebarScriptedCard = z
|
||||||
.object({
|
.object({
|
||||||
__typename: z.literal(ContentPageEnum.ContentStack.sidebar.ScriptedCard),
|
__typename: z.literal(ContentPageEnum.ContentStack.sidebar.ScriptedCard),
|
||||||
})
|
})
|
||||||
.merge(scriptedCardsSchema)
|
.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", [
|
export const sidebarSchema = z.discriminatedUnion("__typename", [
|
||||||
contentPageSidebarContent,
|
contentPageSidebarContent,
|
||||||
contentPageSidebarContentCard,
|
|
||||||
contentPageSidebarDynamicContent,
|
contentPageSidebarDynamicContent,
|
||||||
contentPageJoinLoyaltyContact,
|
contentPageJoinLoyaltyContact,
|
||||||
contentPageSidebarScriptedCard,
|
contentPageSidebarScriptedCard,
|
||||||
|
contentPageSidebarTeaserCard,
|
||||||
contentPageSidebarQuicklinks,
|
contentPageSidebarQuicklinks,
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -263,12 +263,6 @@ 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(
|
||||||
@@ -283,6 +277,12 @@ const contentPageSidebarScriptedCardRef = z
|
|||||||
})
|
})
|
||||||
.merge(scriptedCardRefschema)
|
.merge(scriptedCardRefschema)
|
||||||
|
|
||||||
|
const contentPageSidebarTeaserCardRef = z
|
||||||
|
.object({
|
||||||
|
__typename: z.literal(ContentPageEnum.ContentStack.sidebar.TeaserCard),
|
||||||
|
})
|
||||||
|
.merge(teaserCardRefschema)
|
||||||
|
|
||||||
const contentPageSidebarQuickLinksRef = z
|
const contentPageSidebarQuickLinksRef = z
|
||||||
.object({
|
.object({
|
||||||
__typename: z.literal(ContentPageEnum.ContentStack.sidebar.QuickLinks),
|
__typename: z.literal(ContentPageEnum.ContentStack.sidebar.QuickLinks),
|
||||||
@@ -291,9 +291,9 @@ const contentPageSidebarQuickLinksRef = z
|
|||||||
|
|
||||||
const contentPageSidebarRefsItem = z.discriminatedUnion("__typename", [
|
const contentPageSidebarRefsItem = z.discriminatedUnion("__typename", [
|
||||||
contentPageSidebarContentRef,
|
contentPageSidebarContentRef,
|
||||||
contentPageSidebarContentCardRef,
|
|
||||||
contentPageSidebarJoinLoyaltyContactRef,
|
contentPageSidebarJoinLoyaltyContactRef,
|
||||||
contentPageSidebarScriptedCardRef,
|
contentPageSidebarScriptedCardRef,
|
||||||
|
contentPageSidebarTeaserCardRef,
|
||||||
contentPageSidebarQuickLinksRef,
|
contentPageSidebarQuickLinksRef,
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|||||||
@@ -171,11 +171,6 @@ export function getConnections({ content_page }: ContentPageRefs) {
|
|||||||
connections.push(...block.content)
|
connections.push(...block.content)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case ContentPageEnum.ContentStack.sidebar.ContentCard:
|
|
||||||
if (block.content_card?.length) {
|
|
||||||
connections.push(...block.content_card)
|
|
||||||
}
|
|
||||||
break
|
|
||||||
case ContentPageEnum.ContentStack.sidebar.JoinLoyaltyContact:
|
case ContentPageEnum.ContentStack.sidebar.JoinLoyaltyContact:
|
||||||
if (block.join_loyalty_contact?.button) {
|
if (block.join_loyalty_contact?.button) {
|
||||||
connections.push(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)
|
connections.push(...block.scripted_card)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
case ContentPageEnum.ContentStack.sidebar.TeaserCard:
|
||||||
|
if (block.teaser_card?.length) {
|
||||||
|
connections.push(...block.teaser_card)
|
||||||
|
}
|
||||||
|
break
|
||||||
case ContentPageEnum.ContentStack.sidebar.QuickLinks:
|
case ContentPageEnum.ContentStack.sidebar.QuickLinks:
|
||||||
if (block.shortcuts.shortcuts.length) {
|
if (block.shortcuts.shortcuts.length) {
|
||||||
connections.push(...block.shortcuts.shortcuts)
|
connections.push(...block.shortcuts.shortcuts)
|
||||||
|
|||||||
@@ -9,15 +9,15 @@ import {
|
|||||||
|
|
||||||
import { SidebarEnums } from "@/types/enums/sidebar"
|
import { SidebarEnums } from "@/types/enums/sidebar"
|
||||||
|
|
||||||
export const contentCardsSchema = z.object({
|
export const teaserCardsSchema = z.object({
|
||||||
typename: z
|
typename: z
|
||||||
.literal(SidebarEnums.blocks.ContentCard)
|
.literal(SidebarEnums.blocks.TeaserCard)
|
||||||
.optional()
|
.optional()
|
||||||
.default(SidebarEnums.blocks.ContentCard),
|
.default(SidebarEnums.blocks.TeaserCard),
|
||||||
content_card: z
|
teaser_card: z
|
||||||
.object({
|
.object({
|
||||||
theme: z.enum(["featured", "default"]).nullable().default("default"),
|
theme: z.enum(["featured", "default"]).nullable().default("default"),
|
||||||
content_cardConnection: z.object({
|
teaser_cardConnection: z.object({
|
||||||
edges: z.array(
|
edges: z.array(
|
||||||
z.object({
|
z.object({
|
||||||
node: teaserCardBlockSchema,
|
node: teaserCardBlockSchema,
|
||||||
@@ -27,16 +27,16 @@ export const contentCardsSchema = z.object({
|
|||||||
})
|
})
|
||||||
.transform((data) => {
|
.transform((data) => {
|
||||||
return {
|
return {
|
||||||
...transformTeaserCardBlock(data.content_cardConnection.edges[0].node),
|
...transformTeaserCardBlock(data.teaser_cardConnection.edges[0].node),
|
||||||
theme: data.theme,
|
theme: data.theme,
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
export const contentCardRefschema = z.object({
|
export const teaserCardRefschema = z.object({
|
||||||
content_card: z
|
teaser_card: z
|
||||||
.object({
|
.object({
|
||||||
content_cardConnection: z.object({
|
teaser_cardConnection: z.object({
|
||||||
edges: z.array(
|
edges: z.array(
|
||||||
z.object({
|
z.object({
|
||||||
node: teaserCardBlockRefsSchema,
|
node: teaserCardBlockRefsSchema,
|
||||||
@@ -46,8 +46,8 @@ export const contentCardRefschema = z.object({
|
|||||||
})
|
})
|
||||||
.transform((data) => {
|
.transform((data) => {
|
||||||
let card = null
|
let card = null
|
||||||
if (data.content_cardConnection.edges.length) {
|
if (data.teaser_cardConnection.edges.length) {
|
||||||
card = transformCardBlockRefs(data.content_cardConnection.edges[0].node)
|
card = transformCardBlockRefs(data.teaser_cardConnection.edges[0].node)
|
||||||
}
|
}
|
||||||
return card
|
return card
|
||||||
}),
|
}),
|
||||||
@@ -13,10 +13,10 @@ export namespace ContentPageEnum {
|
|||||||
|
|
||||||
export const enum sidebar {
|
export const enum sidebar {
|
||||||
Content = "ContentPageSidebarContent",
|
Content = "ContentPageSidebarContent",
|
||||||
ContentCard = "ContentPageSidebarContentCard",
|
|
||||||
DynamicContent = "ContentPageSidebarDynamicContent",
|
DynamicContent = "ContentPageSidebarDynamicContent",
|
||||||
JoinLoyaltyContact = "ContentPageSidebarJoinLoyaltyContact",
|
JoinLoyaltyContact = "ContentPageSidebarJoinLoyaltyContact",
|
||||||
ScriptedCard = "ContentPageSidebarScriptedCard",
|
ScriptedCard = "ContentPageSidebarScriptedCard",
|
||||||
|
TeaserCard = "ContentPageSidebarTeaserCard",
|
||||||
QuickLinks = "ContentPageSidebarShortcuts",
|
QuickLinks = "ContentPageSidebarShortcuts",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
export namespace SidebarEnums {
|
export namespace SidebarEnums {
|
||||||
export const enum blocks {
|
export const enum blocks {
|
||||||
Content = "Content",
|
Content = "Content",
|
||||||
ContentCard = "ContentCard",
|
|
||||||
DynamicContent = "DynamicContent",
|
DynamicContent = "DynamicContent",
|
||||||
JoinLoyaltyContact = "JoinLoyaltyContact",
|
JoinLoyaltyContact = "JoinLoyaltyContact",
|
||||||
ScriptedCard = "ScriptedCard",
|
ScriptedCard = "ScriptedCard",
|
||||||
|
TeaserCard = "TeaserCard",
|
||||||
QuickLinks = "QuickLinks",
|
QuickLinks = "QuickLinks",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user