From 8b68b045eb20b643bd8fc5b68e67863b8644d7bb Mon Sep 17 00:00:00 2001 From: Christel Westerberg Date: Thu, 22 Aug 2024 13:18:15 +0200 Subject: [PATCH] fix: check if its a cs link before checking node --- server/routers/contentstack/loyaltyPage/utils.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server/routers/contentstack/loyaltyPage/utils.ts b/server/routers/contentstack/loyaltyPage/utils.ts index 54da06669..80e1f4208 100644 --- a/server/routers/contentstack/loyaltyPage/utils.ts +++ b/server/routers/contentstack/loyaltyPage/utils.ts @@ -84,16 +84,18 @@ export function makeButtonObject(button: any) { const isContenstackLink = button?.is_contentstack_link || button.linkConnection?.edges?.length - const linkConnnectionNode = button.linkConnection.edges[0].node + const linkConnnectionNode = isContenstackLink + ? button.linkConnection.edges[0]?.node + : null return { openInNewTab: button?.open_in_new_tab, title: button.cta_text || - (isContenstackLink + (linkConnnectionNode ? linkConnnectionNode.title : button.external_link.title), - href: isContenstackLink + href: linkConnnectionNode ? linkConnnectionNode.web?.original_url || removeMultipleSlashes( `/${linkConnnectionNode.system.locale}/${linkConnnectionNode.url}`