mirror of
https://github.com/vercel/commerce.git
synced 2025-06-20 06:01:21 +00:00
saleor: stub API for build/typescript compilation
thanks @cond0r
This commit is contained in:
parent
4a652a9b6a
commit
02cf125282
1
framework/saleor/api/cart.ts
Normal file
1
framework/saleor/api/cart.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export default function () {}
|
1
framework/saleor/api/catalog/products.ts
Normal file
1
framework/saleor/api/catalog/products.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export default function () {}
|
1
framework/saleor/api/checkout.ts
Normal file
1
framework/saleor/api/checkout.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export default function () {}
|
1
framework/saleor/api/customers/index.ts
Normal file
1
framework/saleor/api/customers/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export default function () {}
|
1
framework/saleor/api/customers/login.ts
Normal file
1
framework/saleor/api/customers/login.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export default function () {}
|
1
framework/saleor/api/customers/logout.ts
Normal file
1
framework/saleor/api/customers/logout.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export default function () {}
|
1
framework/saleor/api/customers/signup.ts
Normal file
1
framework/saleor/api/customers/signup.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export default function () {}
|
1
framework/saleor/api/wishlist.ts
Normal file
1
framework/saleor/api/wishlist.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export default function () {}
|
@ -64,7 +64,7 @@ const normalizeProductVariants = (variants: ProductVariant[]) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function normalizeProduct(productNode: SaleorProduct): Product {
|
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 = {
|
const product = {
|
||||||
id,
|
id,
|
||||||
@ -73,15 +73,15 @@ export function normalizeProduct(productNode: SaleorProduct): Product {
|
|||||||
description: description ? JSON.parse(description)?.blocks[0]?.data.text : '',
|
description: description ? JSON.parse(description)?.blocks[0]?.data.text : '',
|
||||||
path: `/${slug}`,
|
path: `/${slug}`,
|
||||||
slug: slug?.replace(/^\/+|\/+$/g, ''),
|
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
|
// TODO: Check nextjs-commerce bug if no images are added for a product
|
||||||
images: media?.length ? media : [{ url: placeholderImg }],
|
images: media?.length ? media : [{ url: placeholderImg }],
|
||||||
variants: variants && variants.length > 0 ? normalizeProductVariants(variants) : [],
|
variants: variants && variants.length > 0 ? normalizeProductVariants(variants as ProductVariant[]) : [],
|
||||||
options: variants && variants.length > 0 ? normalizeProductOptions(variants) : [],
|
options: variants && variants.length > 0 ? normalizeProductOptions(variants as ProductVariant[]) : [],
|
||||||
...rest,
|
...rest,
|
||||||
}
|
}
|
||||||
|
|
||||||
return product
|
return product as Product
|
||||||
}
|
}
|
||||||
|
|
||||||
export function normalizeCart(checkout: Checkout): Cart {
|
export function normalizeCart(checkout: Checkout): Cart {
|
||||||
@ -117,7 +117,7 @@ function normalizeLineItem({ id, variant, quantity }: CheckoutLine): LineItem {
|
|||||||
sku: variant?.sku ?? '',
|
sku: variant?.sku ?? '',
|
||||||
name: variant?.name!,
|
name: variant?.name!,
|
||||||
image: {
|
image: {
|
||||||
url: variant?.media![0].url ?? '/product-img-placeholder.svg',
|
url: variant?.media![0].url ?? placeholderImg,
|
||||||
},
|
},
|
||||||
requiresShipping: false,
|
requiresShipping: false,
|
||||||
price: variant?.pricing?.price?.gross.amount!,
|
price: variant?.pricing?.price?.gross.amount!,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user