From 1a95b65653f05d7fa5b20a745d1e1956b82ada27 Mon Sep 17 00:00:00 2001 From: Christel Westerberg Date: Thu, 18 Apr 2024 10:28:35 +0200 Subject: [PATCH] fix: move url field on content page to root --- components/MyPages/Sidebar/helpers.ts | 14 +------------- lib/graphql/Fragments/PageLinks.graphql | 4 +--- tsconfig.json | 2 +- types/requests/myPages/navigation.ts | 4 +--- 4 files changed, 4 insertions(+), 20 deletions(-) diff --git a/components/MyPages/Sidebar/helpers.ts b/components/MyPages/Sidebar/helpers.ts index b9492db78..c4e898699 100644 --- a/components/MyPages/Sidebar/helpers.ts +++ b/components/MyPages/Sidebar/helpers.ts @@ -1,20 +1,8 @@ -import { PageLinkEnum } from "@/types/requests/myPages/navigation" import type { NavigationItem, MenuItem, - PageLink, } from "@/types/requests/myPages/navigation" -function getURL(node: PageLink) { - switch (node.__typename) { - case PageLinkEnum.ContentPage: - return node.web.url - case PageLinkEnum.AccountPage: - case PageLinkEnum.LoyaltyPage: - return node.url - } -} - export function mapMenuItems(navigationItems: NavigationItem[]) { return navigationItems.map(({ item }): MenuItem => { const { node } = item.pageConnection.edges[0] @@ -24,7 +12,7 @@ export function mapMenuItems(navigationItems: NavigationItem[]) { lang: node.system.locale, subItems: item.sub_items ? mapMenuItems(item.sub_items) : null, uid: node.system.uid, - url: `/${node.system.locale}/${getURL(node)}`.replaceAll(/\/\/+/g, "/"), + url: `/${node.system.locale}/${node.url}`.replaceAll(/\/\/+/g, "/"), } }) } diff --git a/lib/graphql/Fragments/PageLinks.graphql b/lib/graphql/Fragments/PageLinks.graphql index b0807d5e7..61f380efa 100644 --- a/lib/graphql/Fragments/PageLinks.graphql +++ b/lib/graphql/Fragments/PageLinks.graphql @@ -30,8 +30,6 @@ fragment ContentPageLink on ContentPage { locale uid } - web { - url - } + url title } diff --git a/tsconfig.json b/tsconfig.json index 83ababe71..6cd24b8da 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -25,5 +25,5 @@ } }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], - "exclude": ["node_modules"] + "exclude": ["node_modules", ".next"] } diff --git a/types/requests/myPages/navigation.ts b/types/requests/myPages/navigation.ts index e0c5ed35a..762f22a37 100644 --- a/types/requests/myPages/navigation.ts +++ b/types/requests/myPages/navigation.ts @@ -44,9 +44,7 @@ export interface LoyaltyPageLink export interface ContentPageLink extends NavigationLink, TypenameInterface { - web: { - url: string - } + url: string } export type PageLink = ContentPageLink | AccountPageLink | LoyaltyPageLink