From 76063e17573b1d64d83b21f368d1eaec1c3348f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matilda=20Landstr=C3=B6m?= Date: Wed, 16 Oct 2024 08:50:26 +0200 Subject: [PATCH] fix(SW-438): fix problem with type for quick links --- components/Sidebar/index.tsx | 5 ++--- .../contentstack/schemas/blocks/shortcuts.ts | 15 ++++++++++----- .../contentstack/schemas/sidebar/quickLinks.ts | 4 ++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/components/Sidebar/index.tsx b/components/Sidebar/index.tsx index 36774a205..6154e7185 100644 --- a/components/Sidebar/index.tsx +++ b/components/Sidebar/index.tsx @@ -63,9 +63,8 @@ export default function Sidebar({ blocks }: SidebarProps) { /> ) - /*case SidebarEnums.blocks.Shortcuts: - console.log("SSS", block) - return */ + case SidebarEnums.blocks.Shortcuts: + return default: return null diff --git a/server/routers/contentstack/schemas/blocks/shortcuts.ts b/server/routers/contentstack/schemas/blocks/shortcuts.ts index 5ceadf45a..3f08ff665 100644 --- a/server/routers/contentstack/schemas/blocks/shortcuts.ts +++ b/server/routers/contentstack/schemas/blocks/shortcuts.ts @@ -4,11 +4,7 @@ import * as pageLinks from "@/server/routers/contentstack/schemas/pageLinks" import { BlocksEnums } from "@/types/enums/blocks" -export const shortcutsSchema = z.object({ - typename: z - .literal(BlocksEnums.block.Shortcuts) - .optional() - .default(BlocksEnums.block.Shortcuts), +export const shortcutsBlockSchema = z.object({ shortcuts: z .object({ subtitle: z.string().nullable(), @@ -62,6 +58,15 @@ export const shortcutsSchema = z.object({ }), }) +export const shortcutsSchema = z + .object({ + typename: z + .literal(BlocksEnums.block.Shortcuts) + .optional() + .default(BlocksEnums.block.Shortcuts), + }) + .merge(shortcutsBlockSchema) + export const shortcutsRefsSchema = z.object({ shortcuts: z.object({ shortcuts: z diff --git a/server/routers/contentstack/schemas/sidebar/quickLinks.ts b/server/routers/contentstack/schemas/sidebar/quickLinks.ts index c8bc61b78..c706239dd 100644 --- a/server/routers/contentstack/schemas/sidebar/quickLinks.ts +++ b/server/routers/contentstack/schemas/sidebar/quickLinks.ts @@ -1,6 +1,6 @@ import { z } from "zod" -import { shortcutsRefsSchema, shortcutsSchema } from "../blocks/shortcuts" +import { shortcutsBlockSchema, shortcutsRefsSchema } from "../blocks/shortcuts" import { SidebarEnums } from "@/types/enums/sidebar" @@ -11,6 +11,6 @@ export const quickLinksSchema = z .optional() .default(SidebarEnums.blocks.Shortcuts), }) - .merge(shortcutsSchema) + .merge(shortcutsBlockSchema) export const quickLinksRefschema = shortcutsRefsSchema