From 52b25b85d6ba36b617c8aec1e67bdeff7148d031 Mon Sep 17 00:00:00 2001 From: Bel Date: Thu, 24 Mar 2022 12:42:33 +0100 Subject: [PATCH] Bug Fix Round and Updates (#719) * Kibo missing dependency * return 404 for invalid page * fix and simplify types for pages Co-authored-by: Dominik Sipowicz --- packages/kibocommerce/src/lib/immutability.ts | 13 ------------- packages/kibocommerce/src/lib/normalize.ts | 14 -------------- site/pages/[...pages].tsx | 7 ++++--- 3 files changed, 4 insertions(+), 30 deletions(-) delete mode 100644 packages/kibocommerce/src/lib/immutability.ts diff --git a/packages/kibocommerce/src/lib/immutability.ts b/packages/kibocommerce/src/lib/immutability.ts deleted file mode 100644 index 488d3570f..000000000 --- a/packages/kibocommerce/src/lib/immutability.ts +++ /dev/null @@ -1,13 +0,0 @@ -import update, { Context } from 'immutability-helper' - -const c = new Context() - -c.extend('$auto', function (value, object) { - return object ? c.update(object, value) : c.update({}, value) -}) - -c.extend('$autoArray', function (value, object) { - return object ? c.update(object, value) : c.update([], value) -}) - -export default c.update diff --git a/packages/kibocommerce/src/lib/normalize.ts b/packages/kibocommerce/src/lib/normalize.ts index 00d0a44c7..363589f0f 100644 --- a/packages/kibocommerce/src/lib/normalize.ts +++ b/packages/kibocommerce/src/lib/normalize.ts @@ -1,21 +1,7 @@ -import update from './immutability' -import getSlug from './get-slug' import type { PrCategory, CustomerAccountInput, Document } from '../../schema' import { Page } from '../types/page'; import { Customer } from '../types/customer' -function normalizeProductOption(productOption: any) { - const { - node: { entityId, values: { edges = [] } = {}, ...rest }, - } = productOption - - return { - id: entityId, - values: edges?.map(({ node }: any) => node), - ...rest, - } -} - export function normalizeProduct(productNode: any, config: any): any { const product = { id: productNode.productCode, diff --git a/site/pages/[...pages].tsx b/site/pages/[...pages].tsx index a8a24b3aa..f0f7e5991 100644 --- a/site/pages/[...pages].tsx +++ b/site/pages/[...pages].tsx @@ -38,8 +38,9 @@ export async function getStaticProps({ const page = data?.page if (!page) { - // We throw to make sure this fails at build time as this is never expected to happen - throw new Error(`Page with slug '${slug}' not found`) + return { + notFound: true, + } } return { @@ -71,7 +72,7 @@ export async function getStaticPaths({ locales }: GetStaticPathsContext) { export default function Pages({ page, -}: InferGetStaticPropsType) { +}: {page: Page}) { const router = useRouter() return router.isFallback ? (