mirror of
https://github.com/vercel/commerce.git
synced 2025-06-20 06:01:21 +00:00
Check nextjs-commerce bug if no images are added for a product
This commit is contained in:
parent
740192affe
commit
bbbe270842
21
framework/saleor/schema.d.ts
vendored
21
framework/saleor/schema.d.ts
vendored
@ -680,7 +680,7 @@ export enum WebhookEventTypeEnum {
|
|||||||
AnyEvents = 'ANY_EVENTS',
|
AnyEvents = 'ANY_EVENTS',
|
||||||
/** A new order is placed. */
|
/** A new order is placed. */
|
||||||
OrderCreated = 'ORDER_CREATED',
|
OrderCreated = 'ORDER_CREATED',
|
||||||
/** An order is confirmed (status change unconfirmed -> unfulfilled) by staff user using OrderConfirm mutation. Also triggers when user finish checkout and shop setting `automatically_confirm_all_new_orders` is enabled. */
|
/** An order is confirmed (status change unconfirmed -> unfulfilled) by a staff user using the OrderConfirm mutation. It also triggers when the user completes the checkout and the shop setting `automatically_confirm_all_new_orders` is enabled. */
|
||||||
OrderConfirmed = 'ORDER_CONFIRMED',
|
OrderConfirmed = 'ORDER_CONFIRMED',
|
||||||
/** Payment is made and an order is fully paid. */
|
/** Payment is made and an order is fully paid. */
|
||||||
OrderFullyPaid = 'ORDER_FULLY_PAID',
|
OrderFullyPaid = 'ORDER_FULLY_PAID',
|
||||||
@ -714,7 +714,7 @@ export enum WebhookEventTypeEnum {
|
|||||||
ProductVariantDeleted = 'PRODUCT_VARIANT_DELETED',
|
ProductVariantDeleted = 'PRODUCT_VARIANT_DELETED',
|
||||||
/** A new checkout is created. */
|
/** A new checkout is created. */
|
||||||
CheckoutCreated = 'CHECKOUT_CREATED',
|
CheckoutCreated = 'CHECKOUT_CREATED',
|
||||||
/** A checkout is updated. Also triggers for all updates related to a checkout. */
|
/** A checkout is updated. It also triggers all updates related to the checkout. */
|
||||||
CheckoutUpdated = 'CHECKOUT_UPDATED',
|
CheckoutUpdated = 'CHECKOUT_UPDATED',
|
||||||
/** A new fulfillment is created. */
|
/** A new fulfillment is created. */
|
||||||
FulfillmentCreated = 'FULFILLMENT_CREATED',
|
FulfillmentCreated = 'FULFILLMENT_CREATED',
|
||||||
@ -1035,6 +1035,7 @@ export type ShippingMethod = Node &
|
|||||||
/** The ID of the object. */
|
/** The ID of the object. */
|
||||||
id: Scalars['ID']
|
id: Scalars['ID']
|
||||||
name: Scalars['String']
|
name: Scalars['String']
|
||||||
|
description?: Maybe<Scalars['JSONString']>
|
||||||
minimumOrderWeight?: Maybe<Weight>
|
minimumOrderWeight?: Maybe<Weight>
|
||||||
maximumOrderWeight?: Maybe<Weight>
|
maximumOrderWeight?: Maybe<Weight>
|
||||||
maximumDeliveryDays?: Maybe<Scalars['Int']>
|
maximumDeliveryDays?: Maybe<Scalars['Int']>
|
||||||
@ -1102,6 +1103,7 @@ export type ShippingMethodTranslation = Node & {
|
|||||||
/** The ID of the object. */
|
/** The ID of the object. */
|
||||||
id: Scalars['ID']
|
id: Scalars['ID']
|
||||||
name?: Maybe<Scalars['String']>
|
name?: Maybe<Scalars['String']>
|
||||||
|
description?: Maybe<Scalars['JSONString']>
|
||||||
/** Translation language. */
|
/** Translation language. */
|
||||||
language: LanguageDisplay
|
language: LanguageDisplay
|
||||||
}
|
}
|
||||||
@ -2779,6 +2781,7 @@ export type ShippingMethodTranslatableContent = Node & {
|
|||||||
/** The ID of the object. */
|
/** The ID of the object. */
|
||||||
id: Scalars['ID']
|
id: Scalars['ID']
|
||||||
name: Scalars['String']
|
name: Scalars['String']
|
||||||
|
description?: Maybe<Scalars['JSONString']>
|
||||||
/** Returns translated shipping method fields for the given language code. */
|
/** Returns translated shipping method fields for the given language code. */
|
||||||
translation?: Maybe<ShippingMethodTranslation>
|
translation?: Maybe<ShippingMethodTranslation>
|
||||||
/** Shipping method are the methods you'll use to get customer's orders to them. They are directly exposed to the customers. */
|
/** Shipping method are the methods you'll use to get customer's orders to them. They are directly exposed to the customers. */
|
||||||
@ -5614,7 +5617,7 @@ export type MutationShippingPriceUpdateArgs = {
|
|||||||
|
|
||||||
export type MutationShippingPriceTranslateArgs = {
|
export type MutationShippingPriceTranslateArgs = {
|
||||||
id: Scalars['ID']
|
id: Scalars['ID']
|
||||||
input: NameTranslationInput
|
input: ShippingPriceTranslationInput
|
||||||
languageCode: LanguageCodeEnum
|
languageCode: LanguageCodeEnum
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7211,6 +7214,8 @@ export type ShippingPriceCreate = {
|
|||||||
export type ShippingPriceInput = {
|
export type ShippingPriceInput = {
|
||||||
/** Name of the shipping method. */
|
/** Name of the shipping method. */
|
||||||
name?: Maybe<Scalars['String']>
|
name?: Maybe<Scalars['String']>
|
||||||
|
/** Shipping method description (JSON). */
|
||||||
|
description?: Maybe<Scalars['JSONString']>
|
||||||
/** Minimum order weight to use this shipping method. */
|
/** Minimum order weight to use this shipping method. */
|
||||||
minimumOrderWeight?: Maybe<Scalars['WeightScalar']>
|
minimumOrderWeight?: Maybe<Scalars['WeightScalar']>
|
||||||
/** Maximum order weight to use this shipping method. */
|
/** Maximum order weight to use this shipping method. */
|
||||||
@ -7292,8 +7297,10 @@ export type ShippingPriceTranslate = {
|
|||||||
shippingMethod?: Maybe<ShippingMethod>
|
shippingMethod?: Maybe<ShippingMethod>
|
||||||
}
|
}
|
||||||
|
|
||||||
export type NameTranslationInput = {
|
export type ShippingPriceTranslationInput = {
|
||||||
name?: Maybe<Scalars['String']>
|
name?: Maybe<Scalars['String']>
|
||||||
|
/** Translated shipping method description (JSON). */
|
||||||
|
description?: Maybe<Scalars['JSONString']>
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Exclude products from shipping price. */
|
/** Exclude products from shipping price. */
|
||||||
@ -8495,6 +8502,10 @@ export type ProductVariantTranslate = {
|
|||||||
productVariant?: Maybe<ProductVariant>
|
productVariant?: Maybe<ProductVariant>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type NameTranslationInput = {
|
||||||
|
name?: Maybe<Scalars['String']>
|
||||||
|
}
|
||||||
|
|
||||||
/** Manage product variant prices in channels. */
|
/** Manage product variant prices in channels. */
|
||||||
export type ProductVariantChannelListingUpdate = {
|
export type ProductVariantChannelListingUpdate = {
|
||||||
__typename?: 'ProductVariantChannelListingUpdate'
|
__typename?: 'ProductVariantChannelListingUpdate'
|
||||||
@ -11678,6 +11689,8 @@ export type AccountRegisterInput = {
|
|||||||
redirectUrl?: Maybe<Scalars['String']>
|
redirectUrl?: Maybe<Scalars['String']>
|
||||||
/** User language code. */
|
/** User language code. */
|
||||||
languageCode?: Maybe<LanguageCodeEnum>
|
languageCode?: Maybe<LanguageCodeEnum>
|
||||||
|
/** User public metadata. */
|
||||||
|
metadata?: Maybe<Array<MetadataInput>>
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Updates the account of the logged-in user. */
|
/** Updates the account of the logged-in user. */
|
||||||
|
@ -1634,7 +1634,7 @@ enum WebhookEventTypeEnum {
|
|||||||
ORDER_CREATED
|
ORDER_CREATED
|
||||||
|
|
||||||
"""
|
"""
|
||||||
An order is confirmed (status change unconfirmed -> unfulfilled) by staff user using OrderConfirm mutation. Also triggers when user finish checkout and shop setting `automatically_confirm_all_new_orders` is enabled.
|
An order is confirmed (status change unconfirmed -> unfulfilled) by a staff user using the OrderConfirm mutation. It also triggers when the user completes the checkout and the shop setting `automatically_confirm_all_new_orders` is enabled.
|
||||||
"""
|
"""
|
||||||
ORDER_CONFIRMED
|
ORDER_CONFIRMED
|
||||||
|
|
||||||
@ -1719,7 +1719,7 @@ enum WebhookEventTypeEnum {
|
|||||||
CHECKOUT_CREATED
|
CHECKOUT_CREATED
|
||||||
|
|
||||||
"""
|
"""
|
||||||
A checkout is updated. Also triggers for all updates related to a checkout.
|
A checkout is updated. It also triggers all updates related to the checkout.
|
||||||
"""
|
"""
|
||||||
CHECKOUT_UPDATED
|
CHECKOUT_UPDATED
|
||||||
|
|
||||||
@ -2254,6 +2254,7 @@ type ShippingMethod implements Node & ObjectWithMetadata {
|
|||||||
"""
|
"""
|
||||||
id: ID!
|
id: ID!
|
||||||
name: String!
|
name: String!
|
||||||
|
description: JSONString
|
||||||
minimumOrderWeight: Weight
|
minimumOrderWeight: Weight
|
||||||
maximumOrderWeight: Weight
|
maximumOrderWeight: Weight
|
||||||
maximumDeliveryDays: Int
|
maximumDeliveryDays: Int
|
||||||
@ -2374,6 +2375,7 @@ type ShippingMethodTranslation implements Node {
|
|||||||
"""
|
"""
|
||||||
id: ID!
|
id: ID!
|
||||||
name: String
|
name: String
|
||||||
|
description: JSONString
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Translation language.
|
Translation language.
|
||||||
@ -4929,6 +4931,7 @@ type ShippingMethodTranslatableContent implements Node {
|
|||||||
"""
|
"""
|
||||||
id: ID!
|
id: ID!
|
||||||
name: String!
|
name: String!
|
||||||
|
description: JSONString
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Returns translated shipping method fields for the given language code.
|
Returns translated shipping method fields for the given language code.
|
||||||
@ -8927,7 +8930,7 @@ type Mutation {
|
|||||||
Shipping method ID.
|
Shipping method ID.
|
||||||
"""
|
"""
|
||||||
id: ID!
|
id: ID!
|
||||||
input: NameTranslationInput!
|
input: ShippingPriceTranslationInput!
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Translation language code.
|
Translation language code.
|
||||||
@ -12791,6 +12794,11 @@ input ShippingPriceInput {
|
|||||||
"""
|
"""
|
||||||
name: String
|
name: String
|
||||||
|
|
||||||
|
"""
|
||||||
|
Shipping method description (JSON).
|
||||||
|
"""
|
||||||
|
description: JSONString
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Minimum order weight to use this shipping method.
|
Minimum order weight to use this shipping method.
|
||||||
"""
|
"""
|
||||||
@ -12929,8 +12937,13 @@ type ShippingPriceTranslate {
|
|||||||
shippingMethod: ShippingMethod
|
shippingMethod: ShippingMethod
|
||||||
}
|
}
|
||||||
|
|
||||||
input NameTranslationInput {
|
input ShippingPriceTranslationInput {
|
||||||
name: String
|
name: String
|
||||||
|
|
||||||
|
"""
|
||||||
|
Translated shipping method description (JSON).
|
||||||
|
"""
|
||||||
|
description: JSONString
|
||||||
}
|
}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -14859,6 +14872,10 @@ type ProductVariantTranslate {
|
|||||||
productVariant: ProductVariant
|
productVariant: ProductVariant
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input NameTranslationInput {
|
||||||
|
name: String
|
||||||
|
}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Manage product variant prices in channels.
|
Manage product variant prices in channels.
|
||||||
"""
|
"""
|
||||||
@ -19721,6 +19738,11 @@ input AccountRegisterInput {
|
|||||||
User language code.
|
User language code.
|
||||||
"""
|
"""
|
||||||
languageCode: LanguageCodeEnum
|
languageCode: LanguageCodeEnum
|
||||||
|
|
||||||
|
"""
|
||||||
|
User public metadata.
|
||||||
|
"""
|
||||||
|
metadata: [MetadataInput!]
|
||||||
}
|
}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -14,6 +14,9 @@ import {
|
|||||||
|
|
||||||
import type { Cart, LineItem } from '../types'
|
import type { Cart, LineItem } from '../types'
|
||||||
|
|
||||||
|
// TODO: Check nextjs-commerce bug if no images are added for a product
|
||||||
|
const placeholderImg = '/product-img-placeholder.svg'
|
||||||
|
|
||||||
const money = ({ amount, currency }: Money) => {
|
const money = ({ amount, currency }: Money) => {
|
||||||
return {
|
return {
|
||||||
value: +amount,
|
value: +amount,
|
||||||
@ -97,7 +100,8 @@ export function normalizeProduct(productNode: SaleorProduct): Product {
|
|||||||
path: `/${slug}`,
|
path: `/${slug}`,
|
||||||
slug: slug?.replace(/^\/+|\/+$/g, ''),
|
slug: slug?.replace(/^\/+|\/+$/g, ''),
|
||||||
price: money(pricing?.priceRange?.start?.net) || 0,
|
price: money(pricing?.priceRange?.start?.net) || 0,
|
||||||
images: media,
|
// TODO: Check nextjs-commerce bug if no images are added for a product
|
||||||
|
images: media?.length ? media : [{ url: placeholderImg }],
|
||||||
variants: variants ? normalizeProductVariants(variants) : [],
|
variants: variants ? normalizeProductVariants(variants) : [],
|
||||||
options: variants ? normalizeProductOptions(variants) : [],
|
options: variants ? normalizeProductOptions(variants) : [],
|
||||||
...rest,
|
...rest,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user