4
0
forked from crowetic/commerce

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 <dom@vercel.com>
This commit is contained in:
Bel 2022-03-24 12:42:33 +01:00 committed by GitHub
parent fee16e795c
commit 52b25b85d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 30 deletions

View File

@ -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

View File

@ -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,

View File

@ -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<typeof getStaticProps>) {
}: {page: Page}) {
const router = useRouter()
return router.isFallback ? (