saleor: stub API for build/typescript compilation

thanks @cond0r
This commit is contained in:
Zaiste 2021-05-18 15:40:36 +02:00
parent 4a652a9b6a
commit 02cf125282
No known key found for this signature in database
GPG Key ID: 15DF7EBC7F2FFE35
9 changed files with 14 additions and 6 deletions

View File

@ -0,0 +1 @@
export default function () {}

View File

@ -0,0 +1 @@
export default function () {}

View File

@ -0,0 +1 @@
export default function () {}

View File

@ -0,0 +1 @@
export default function () {}

View File

@ -0,0 +1 @@
export default function () {}

View File

@ -0,0 +1 @@
export default function () {}

View File

@ -0,0 +1 @@
export default function () {}

View File

@ -0,0 +1 @@
export default function () {}

View File

@ -64,7 +64,7 @@ const normalizeProductVariants = (variants: ProductVariant[]) => {
}
export function normalizeProduct(productNode: SaleorProduct): Product {
const { id, name, media, variants, description, slug, pricing, ...rest } = productNode
const { id, name, media = [], variants, description, slug, pricing, ...rest } = productNode
const product = {
id,
@ -73,15 +73,15 @@ export function normalizeProduct(productNode: SaleorProduct): Product {
description: description ? JSON.parse(description)?.blocks[0]?.data.text : '',
path: `/${slug}`,
slug: slug?.replace(/^\/+|\/+$/g, ''),
price: (pricing?.priceRange?.start?.net && money(pricing.priceRange.start.net)) || 0,
price: (pricing?.priceRange?.start?.net && money(pricing.priceRange.start.net)) || { value: 0, currencyCode: 'USD' },
// TODO: Check nextjs-commerce bug if no images are added for a product
images: media?.length ? media : [{ url: placeholderImg }],
variants: variants && variants.length > 0 ? normalizeProductVariants(variants) : [],
options: variants && variants.length > 0 ? normalizeProductOptions(variants) : [],
variants: variants && variants.length > 0 ? normalizeProductVariants(variants as ProductVariant[]) : [],
options: variants && variants.length > 0 ? normalizeProductOptions(variants as ProductVariant[]) : [],
...rest,
}
return product
return product as Product
}
export function normalizeCart(checkout: Checkout): Cart {
@ -117,7 +117,7 @@ function normalizeLineItem({ id, variant, quantity }: CheckoutLine): LineItem {
sku: variant?.sku ?? '',
name: variant?.name!,
image: {
url: variant?.media![0].url ?? '/product-img-placeholder.svg',
url: variant?.media![0].url ?? placeholderImg,
},
requiresShipping: false,
price: variant?.pricing?.price?.gross.amount!,