From 84a11d731a881ac0eab0c8f9c053e42cf4bf932d Mon Sep 17 00:00:00 2001 From: Fredrik Thorsson Date: Tue, 8 Oct 2024 13:32:10 +0200 Subject: [PATCH] feat(SW-322): change output variable name --- components/Blocks/Shortcuts/index.tsx | 8 +- components/Blocks/index.tsx | 2 +- components/Webviews/AccountPage/Blocks.tsx | 2 +- components/Webviews/LoyaltyPage/Blocks.tsx | 2 +- .../Fragments/Blocks/Shortcuts.graphql | 2 +- .../contentstack/schemas/blocks/shortcuts.ts | 93 ++++++++++--------- 6 files changed, 58 insertions(+), 51 deletions(-) diff --git a/components/Blocks/Shortcuts/index.tsx b/components/Blocks/Shortcuts/index.tsx index f0a88e37b..d0a332511 100644 --- a/components/Blocks/Shortcuts/index.tsx +++ b/components/Blocks/Shortcuts/index.tsx @@ -12,7 +12,7 @@ export default function Shortcuts({ shortcuts, subtitle, title, - columns, + twoColumnList, }: ShortcutsProps) { const middleIndex = Math.ceil(shortcuts.length / 2) const leftColumn = shortcuts.slice(0, middleIndex) @@ -37,11 +37,11 @@ export default function Shortcuts({ return ( -
-
+
+
-
+
diff --git a/components/Blocks/index.tsx b/components/Blocks/index.tsx index f48014044..bc78bb619 100644 --- a/components/Blocks/index.tsx +++ b/components/Blocks/index.tsx @@ -47,7 +47,7 @@ export default function Blocks({ blocks }: BlocksProps) { shortcuts={block.shortcuts.shortcuts} subtitle={block.shortcuts.subtitle} title={block.shortcuts.title} - columns={block.shortcuts.columns} + twoColumnList={block.shortcuts.twoColumnList} /> ) case BlocksEnums.block.Table: diff --git a/components/Webviews/AccountPage/Blocks.tsx b/components/Webviews/AccountPage/Blocks.tsx index 534dd1a83..7701e47f4 100644 --- a/components/Webviews/AccountPage/Blocks.tsx +++ b/components/Webviews/AccountPage/Blocks.tsx @@ -70,7 +70,7 @@ export default function Content({ content }: ContentProps) { shortcuts={shortcuts} subtitle={item.shortcuts.subtitle} title={item.shortcuts.title} - columns={item.shortcuts.columns} + twoColumnList={item.shortcuts.twoColumnList} /> ) case BlocksEnums.block.TextContent: diff --git a/components/Webviews/LoyaltyPage/Blocks.tsx b/components/Webviews/LoyaltyPage/Blocks.tsx index 98b1f1b5d..77c826900 100644 --- a/components/Webviews/LoyaltyPage/Blocks.tsx +++ b/components/Webviews/LoyaltyPage/Blocks.tsx @@ -61,7 +61,7 @@ export default function Blocks({ blocks }: BlocksProps) { shortcuts={shortcuts} subtitle={block.shortcuts.subtitle} title={block.shortcuts.title} - columns={block.shortcuts.columns} + twoColumnList={block.shortcuts.twoColumnList} /> ) default: diff --git a/lib/graphql/Fragments/Blocks/Shortcuts.graphql b/lib/graphql/Fragments/Blocks/Shortcuts.graphql index 993f1891b..4ba566634 100644 --- a/lib/graphql/Fragments/Blocks/Shortcuts.graphql +++ b/lib/graphql/Fragments/Blocks/Shortcuts.graphql @@ -9,7 +9,7 @@ fragment Shortcuts on Shortcuts { subtitle: preamble title - columns + two_column_list shortcuts { open_in_new_tab text diff --git a/server/routers/contentstack/schemas/blocks/shortcuts.ts b/server/routers/contentstack/schemas/blocks/shortcuts.ts index 85bb5d684..13e99d7b3 100644 --- a/server/routers/contentstack/schemas/blocks/shortcuts.ts +++ b/server/routers/contentstack/schemas/blocks/shortcuts.ts @@ -9,50 +9,57 @@ export const shortcutsSchema = z.object({ .literal(BlocksEnums.block.Shortcuts) .optional() .default(BlocksEnums.block.Shortcuts), - shortcuts: z.object({ - subtitle: z.string().nullable(), - title: z.string().nullable(), - columns: z.boolean().default(false), - shortcuts: z - .array( - z.object({ - open_in_new_tab: z.boolean(), - text: z.string().optional().default(""), - linkConnection: z.object({ - edges: z.array( - z.object({ - node: z - .discriminatedUnion("__typename", [ - pageLinks.accountPageSchema, - pageLinks.contentPageSchema, - pageLinks.loyaltyPageSchema, - ]) - .transform((data) => { - const link = pageLinks.transform(data) - if (link) { - return link - } - return data - }), - }) - ), - }), - }) - ) - .transform((data) => { - return data - .filter((node) => node.linkConnection.edges.length) - .map((node) => { - const link = node.linkConnection.edges[0].node - return { - openInNewTab: node.open_in_new_tab, - text: node.text, - title: link.title, - url: link.url, - } + shortcuts: z + .object({ + subtitle: z.string().nullable(), + title: z.string().nullable(), + two_column_list: z.boolean().default(false), + shortcuts: z + .array( + z.object({ + open_in_new_tab: z.boolean(), + text: z.string().optional().default(""), + linkConnection: z.object({ + edges: z.array( + z.object({ + node: z + .discriminatedUnion("__typename", [ + pageLinks.accountPageSchema, + pageLinks.contentPageSchema, + pageLinks.loyaltyPageSchema, + ]) + .transform((data) => { + const link = pageLinks.transform(data) + if (link) { + return link + } + return data + }), + }) + ), + }), }) - }), - }), + ) + .transform((data) => { + return data + .filter((node) => node.linkConnection.edges.length) + .map((node) => { + const link = node.linkConnection.edges[0].node + return { + openInNewTab: node.open_in_new_tab, + text: node.text, + title: link.title, + url: link.url, + } + }) + }), + }) + .transform(({ two_column_list, ...rest }) => { + return { + ...rest, + twoColumnList: two_column_list, + } + }), }) export const shortcutsRefsSchema = z.object({