diff --git a/framework/saleor/api/cart.ts b/framework/saleor/api/cart.ts new file mode 100644 index 000000000..ea9b101e1 --- /dev/null +++ b/framework/saleor/api/cart.ts @@ -0,0 +1 @@ +export default function () {} diff --git a/framework/saleor/api/catalog/products.ts b/framework/saleor/api/catalog/products.ts new file mode 100644 index 000000000..ea9b101e1 --- /dev/null +++ b/framework/saleor/api/catalog/products.ts @@ -0,0 +1 @@ +export default function () {} diff --git a/framework/saleor/api/checkout.ts b/framework/saleor/api/checkout.ts new file mode 100644 index 000000000..ea9b101e1 --- /dev/null +++ b/framework/saleor/api/checkout.ts @@ -0,0 +1 @@ +export default function () {} diff --git a/framework/saleor/api/customers/index.ts b/framework/saleor/api/customers/index.ts new file mode 100644 index 000000000..ea9b101e1 --- /dev/null +++ b/framework/saleor/api/customers/index.ts @@ -0,0 +1 @@ +export default function () {} diff --git a/framework/saleor/api/customers/login.ts b/framework/saleor/api/customers/login.ts new file mode 100644 index 000000000..ea9b101e1 --- /dev/null +++ b/framework/saleor/api/customers/login.ts @@ -0,0 +1 @@ +export default function () {} diff --git a/framework/saleor/api/customers/logout.ts b/framework/saleor/api/customers/logout.ts new file mode 100644 index 000000000..ea9b101e1 --- /dev/null +++ b/framework/saleor/api/customers/logout.ts @@ -0,0 +1 @@ +export default function () {} diff --git a/framework/saleor/api/customers/signup.ts b/framework/saleor/api/customers/signup.ts new file mode 100644 index 000000000..ea9b101e1 --- /dev/null +++ b/framework/saleor/api/customers/signup.ts @@ -0,0 +1 @@ +export default function () {} diff --git a/framework/saleor/api/wishlist.ts b/framework/saleor/api/wishlist.ts new file mode 100644 index 000000000..ea9b101e1 --- /dev/null +++ b/framework/saleor/api/wishlist.ts @@ -0,0 +1 @@ +export default function () {} diff --git a/framework/saleor/utils/normalize.ts b/framework/saleor/utils/normalize.ts index b142e8f04..494424d41 100644 --- a/framework/saleor/utils/normalize.ts +++ b/framework/saleor/utils/normalize.ts @@ -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!,