= props
order.shippingMethodName !== undefined ? (
order.shippingMethod === null ? (
order.availableShippingMethods &&
- order.availableShippingMethods.length > 0 ? (
+ order.availableShippingMethods.length > 0 &&
+ !disabled ? (
= props => {
>
- onSort(OrderDraftListUrlSortField.total)}
- className={classes.colTotal}
- >
+
,
TabPageProps {
orders: OrderDraftList_draftOrders_edges_node[];
+ onSettingsOpen?: () => void;
}
+const useStyles = makeStyles(
+ theme => ({
+ settings: {
+ marginRight: theme.spacing(2)
+ }
+ }),
+ { name: "OrderDraftListPage" }
+);
+
const OrderDraftListPage: React.FC = ({
- currencySymbol,
currentTab,
disabled,
filterOpts,
@@ -42,6 +53,7 @@ const OrderDraftListPage: React.FC = ({
onAll,
onFilterChange,
onSearchChange,
+ onSettingsOpen,
onTabChange,
onTabDelete,
onTabSave,
@@ -49,12 +61,26 @@ const OrderDraftListPage: React.FC = ({
...listProps
}) => {
const intl = useIntl();
-
+ const classes = useStyles({});
const structure = createFilterStructure(intl, filterOpts);
return (
+ {!!onSettingsOpen && (
+
+ )}
- onSort(OrderListUrlSortField.total)}
- className={classes.colTotal}
- >
+
,
SortPage {
orders: OrderList_orders_edges_node[];
+ onSettingsOpen?: () => void;
}
+const useStyles = makeStyles(
+ theme => ({
+ settings: {
+ marginRight: theme.spacing(2)
+ }
+ }),
+ { name: "OrderListPage" }
+);
+
const OrderListPage: React.FC = ({
- currencySymbol,
currentTab,
initialSearch,
filterOpts,
@@ -33,6 +44,7 @@ const OrderListPage: React.FC = ({
onAdd,
onAll,
onSearchChange,
+ onSettingsOpen,
onFilterChange,
onTabChange,
onTabDelete,
@@ -40,12 +52,26 @@ const OrderListPage: React.FC = ({
...listProps
}) => {
const intl = useIntl();
-
+ const classes = useStyles({});
const filterStructure = createFilterStructure(intl, filterOpts);
return (
+ {!!onSettingsOpen && (
+
+ )}
void;
onFetch: (query: string) => void;
onSubmit: (data: SearchOrderVariant_search_edges_node_variants[]) => void;
@@ -168,6 +169,7 @@ const OrderProductAddDialog: React.FC = props => {
loading,
hasMore,
products,
+ selectedChannel,
onFetch,
onFetchMore,
onClose,
@@ -252,84 +254,94 @@ const OrderProductAddDialog: React.FC = props => {
{renderCollection(
productChoices,
- (product, productIndex) => (
-
-
-
-
- onProductAdd(
- product,
- productIndex,
- productsWithAllVariantsSelected,
- variants,
- setVariants
- )
- }
+ (product, productIndex) =>
+ product.variants.some(variant =>
+ variant.channelListings.some(
+ listing => listing.channel.id === selectedChannel
+ )
+ ) ? (
+
+
+
+
+ onProductAdd(
+ product,
+ productIndex,
+ productsWithAllVariantsSelected,
+ variants,
+ setVariants
+ )
+ }
+ />
+
+ product.thumbnail.url)}
/>
-
- product.thumbnail.url)}
- />
-
- {maybe(() => product.name)}
-
-
- {maybe(() => product.variants, []).map(
- (variant, variantIndex) => (
-
-
-
-
- onVariantAdd(
- variant,
- variantIndex,
- productIndex,
- variants,
- selectedVariantsToProductsMap,
- setVariants
- )
- }
- />
-
-
- {variant.name}
-
-
-
-
-
-
-
-
- )
- )}
-
- ),
+
+ {maybe(() => product.name)}
+
+
+ {maybe(() => product.variants, []).map(
+ (variant, variantIndex) =>
+ variant.channelListings.some(
+ listing => listing.channel.id === selectedChannel
+ ) ? (
+
+
+
+
+ onVariantAdd(
+ variant,
+ variantIndex,
+ productIndex,
+ variants,
+ selectedVariantsToProductsMap,
+ setVariants
+ )
+ }
+ />
+
+
+ {variant.name}
+
+
+
+
+
+ {variant?.channelListings[0]?.price && (
+
+ )}
+
+
+ ) : null
+ )}
+
+ ) : null,
() => (
diff --git a/src/orders/fixtures.ts b/src/orders/fixtures.ts
index d6e40b66e..6a0e15d2d 100644
--- a/src/orders/fixtures.ts
+++ b/src/orders/fixtures.ts
@@ -811,6 +811,13 @@ export const order = (placeholder: string): OrderDetails_order => ({
streetAddress2: ""
},
canFinalize: true,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123454",
+ isActive: true,
+ name: "Default Channel"
+ },
created: "2018-09-11T09:37:28.185874+00:00",
customerNote: "Lorem ipsum dolor sit amet",
discount: null,
@@ -948,12 +955,6 @@ export const order = (placeholder: string): OrderDetails_order => ({
variant: {
__typename: "ProductVariant",
id: "dsfsfuhb",
- product: {
- __typename: "Product",
- id: "345678393",
- isAvailableForPurchase: true,
- isPublished: true
- },
quantityAvailable: 10
}
},
@@ -1000,12 +1001,6 @@ export const order = (placeholder: string): OrderDetails_order => ({
variant: {
__typename: "ProductVariant",
id: "dsfsfuhb",
- product: {
- __typename: "Product",
- id: "345678393",
- isAvailableForPurchase: true,
- isPublished: true
- },
quantityAvailable: 10
}
},
@@ -1057,12 +1052,6 @@ export const order = (placeholder: string): OrderDetails_order => ({
variant: {
__typename: "ProductVariant",
id: "dsfsfuhb",
- product: {
- __typename: "Product",
- id: "345678393",
- isAvailableForPurchase: true,
- isPublished: true
- },
quantityAvailable: 10
}
},
@@ -1094,12 +1083,6 @@ export const order = (placeholder: string): OrderDetails_order => ({
variant: {
__typename: "ProductVariant",
id: "dsfsfuhb",
- product: {
- __typename: "Product",
- id: "345678393",
- isAvailableForPurchase: true,
- isPublished: true
- },
quantityAvailable: 10
}
}
@@ -1184,6 +1167,13 @@ export const draftOrder = (placeholder: string): OrderDetails_order => ({
availableShippingMethods: null,
billingAddress: null,
canFinalize: true,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123454",
+ isActive: true,
+ name: "Default Channel"
+ },
created: "2018-09-20T23:23:39.811428+00:00",
customerNote: "Lorem ipsum dolor sit",
discount: null,
@@ -1229,12 +1219,6 @@ export const draftOrder = (placeholder: string): OrderDetails_order => ({
variant: {
__typename: "ProductVariant",
id: "dsfsfuhb",
- product: {
- __typename: "Product",
- id: "345678393",
- isAvailableForPurchase: true,
- isPublished: true
- },
quantityAvailable: 10
}
},
@@ -1266,12 +1250,6 @@ export const draftOrder = (placeholder: string): OrderDetails_order => ({
variant: {
__typename: "ProductVariant",
id: "dsfsfuhb",
- product: {
- __typename: "Product",
- id: "345678393",
- isAvailableForPurchase: true,
- isPublished: true
- },
quantityAvailable: 10
}
}
@@ -1362,53 +1340,116 @@ export const orderLineSearch = (
variants: [
{
__typename: "ProductVariant" as "ProductVariant",
- id: "UHJvZHVjdFZhcmlhbnQ6MjAy",
- name: "500ml",
- pricing: {
- __typename: "VariantPricingInfo",
- priceUndiscounted: {
- __typename: "TaxedMoney",
- net: {
- __typename: "Money" as "Money",
- amount: 3.0,
+ channelListings: [
+ {
+ __typename: "ProductVariantChannelListing",
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123",
+ isActive: true,
+ name: "Channel1"
+ },
+ price: {
+ __typename: "Money",
+ amount: 1,
+ currency: "USD"
+ }
+ },
+ {
+ __typename: "ProductVariantChannelListing",
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "124",
+ isActive: true,
+ name: "Channel2"
+ },
+ price: {
+ __typename: "Money",
+ amount: 1,
currency: "USD"
}
}
- },
+ ],
+ id: "UHJvZHVjdFZhcmlhbnQ6MjAy",
+ name: "500ml",
sku: "93855755"
},
{
__typename: "ProductVariant" as "ProductVariant",
- id: "UHJvZHVjdFZhcmlhbnQ6MjAz",
- name: "1l",
- pricing: {
- __typename: "VariantPricingInfo",
- priceUndiscounted: {
- __typename: "TaxedMoney",
- net: {
- __typename: "Money" as "Money",
- amount: 5.0,
+ channelListings: [
+ {
+ __typename: "ProductVariantChannelListing",
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123",
+ isActive: true,
+ name: "Channel1"
+ },
+ price: {
+ __typename: "Money",
+ amount: 1,
+ currency: "USD"
+ }
+ },
+ {
+ __typename: "ProductVariantChannelListing",
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "124",
+ isActive: true,
+ name: "Channel2"
+ },
+ price: {
+ __typename: "Money",
+ amount: 1,
currency: "USD"
}
}
- },
+ ],
+ id: "UHJvZHVjdFZhcmlhbnQ6MjAz",
+ name: "1l",
sku: "43226647"
},
{
__typename: "ProductVariant" as "ProductVariant",
- id: "UHJvZHVjdFZhcmlhbnQ6MjA0",
- name: "2l",
- pricing: {
- __typename: "VariantPricingInfo",
- priceUndiscounted: {
- __typename: "TaxedMoney",
- net: {
- __typename: "Money" as "Money",
- amount: 7.0,
+ channelListings: [
+ {
+ __typename: "ProductVariantChannelListing",
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123",
+ isActive: true,
+ name: "Channel1"
+ },
+ price: {
+ __typename: "Money",
+ amount: 1,
+ currency: "USD"
+ }
+ },
+ {
+ __typename: "ProductVariantChannelListing",
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "124",
+ isActive: true,
+ name: "Channel2"
+ },
+ price: {
+ __typename: "Money",
+ amount: 1,
currency: "USD"
}
}
- },
+ ],
+ id: "UHJvZHVjdFZhcmlhbnQ6MjA0",
+ name: "2l",
sku: "80884671"
}
]
@@ -1424,53 +1465,116 @@ export const orderLineSearch = (
variants: [
{
__typename: "ProductVariant" as "ProductVariant",
- id: "UHJvZHVjdFZhcmlhbnQ6MjEx",
- name: "500ml",
- pricing: {
- __typename: "VariantPricingInfo",
- priceUndiscounted: {
- __typename: "TaxedMoney",
- net: {
- __typename: "Money" as "Money",
- amount: 3.0,
+ channelListings: [
+ {
+ __typename: "ProductVariantChannelListing",
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123",
+ isActive: true,
+ name: "Channel1"
+ },
+ price: {
+ __typename: "Money",
+ amount: 1,
+ currency: "USD"
+ }
+ },
+ {
+ __typename: "ProductVariantChannelListing",
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "124",
+ isActive: true,
+ name: "Channel2"
+ },
+ price: {
+ __typename: "Money",
+ amount: 1,
currency: "USD"
}
}
- },
+ ],
+ id: "UHJvZHVjdFZhcmlhbnQ6MjEx",
+ name: "500ml",
sku: "43200242"
},
{
__typename: "ProductVariant" as "ProductVariant",
- id: "UHJvZHVjdFZhcmlhbnQ6MjEy",
- name: "1l",
- pricing: {
- __typename: "VariantPricingInfo",
- priceUndiscounted: {
- __typename: "TaxedMoney",
- net: {
- __typename: "Money" as "Money",
- amount: 5.0,
+ channelListings: [
+ {
+ __typename: "ProductVariantChannelListing",
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123",
+ isActive: true,
+ name: "Channel1"
+ },
+ price: {
+ __typename: "Money",
+ amount: 1,
+ currency: "USD"
+ }
+ },
+ {
+ __typename: "ProductVariantChannelListing",
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "124",
+ isActive: true,
+ name: "Channel2"
+ },
+ price: {
+ __typename: "Money",
+ amount: 1,
currency: "USD"
}
}
- },
+ ],
+ id: "UHJvZHVjdFZhcmlhbnQ6MjEy",
+ name: "1l",
sku: "79129513"
},
{
__typename: "ProductVariant" as "ProductVariant",
- id: "UHJvZHVjdFZhcmlhbnQ6MjEz",
- name: "2l",
- pricing: {
- __typename: "VariantPricingInfo",
- priceUndiscounted: {
- __typename: "TaxedMoney",
- net: {
- __typename: "Money" as "Money",
- amount: 7.0,
+ channelListings: [
+ {
+ __typename: "ProductVariantChannelListing",
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123",
+ isActive: true,
+ name: "Channel1"
+ },
+ price: {
+ __typename: "Money",
+ amount: 1,
+ currency: "USD"
+ }
+ },
+ {
+ __typename: "ProductVariantChannelListing",
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "124",
+ isActive: true,
+ name: "Channel2"
+ },
+ price: {
+ __typename: "Money",
+ amount: 1,
currency: "USD"
}
}
- },
+ ],
+ id: "UHJvZHVjdFZhcmlhbnQ6MjEz",
+ name: "2l",
sku: "75799450"
}
]
diff --git a/src/orders/mutations.ts b/src/orders/mutations.ts
index 0169ae2f5..1db7240c7 100644
--- a/src/orders/mutations.ts
+++ b/src/orders/mutations.ts
@@ -360,8 +360,8 @@ export const TypedOrderShippingMethodUpdateMutation = TypedMutation<
const orderDraftCreateMutation = gql`
${orderErrorFragment}
- mutation OrderDraftCreate {
- draftOrderCreate(input: {}) {
+ mutation OrderDraftCreate($input: DraftOrderCreateInput!) {
+ draftOrderCreate(input: $input) {
errors: orderErrors {
...OrderErrorFragment
}
diff --git a/src/orders/queries.ts b/src/orders/queries.ts
index 45747bd88..4808d6315 100644
--- a/src/orders/queries.ts
+++ b/src/orders/queries.ts
@@ -161,12 +161,16 @@ export const searchOrderVariant = gql`
id
name
sku
- pricing {
- priceUndiscounted {
- net {
- amount
- currency
- }
+ channelListings {
+ channel {
+ id
+ isActive
+ name
+ currencyCode
+ }
+ price {
+ amount
+ currency
}
}
}
diff --git a/src/orders/types/FulfillOrder.ts b/src/orders/types/FulfillOrder.ts
index 715c9a509..dcc4c359d 100644
--- a/src/orders/types/FulfillOrder.ts
+++ b/src/orders/types/FulfillOrder.ts
@@ -70,17 +70,9 @@ export interface FulfillOrder_orderFulfill_order_events {
user: FulfillOrder_orderFulfill_order_events_user | null;
}
-export interface FulfillOrder_orderFulfill_order_fulfillments_lines_orderLine_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface FulfillOrder_orderFulfill_order_fulfillments_lines_orderLine_variant {
__typename: "ProductVariant";
id: string;
- product: FulfillOrder_orderFulfill_order_fulfillments_lines_orderLine_variant_product;
quantityAvailable: number;
}
@@ -143,17 +135,9 @@ export interface FulfillOrder_orderFulfill_order_fulfillments {
warehouse: FulfillOrder_orderFulfill_order_fulfillments_warehouse | null;
}
-export interface FulfillOrder_orderFulfill_order_lines_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface FulfillOrder_orderFulfill_order_lines_variant {
__typename: "ProductVariant";
id: string;
- product: FulfillOrder_orderFulfill_order_lines_variant_product;
quantityAvailable: number;
}
@@ -306,6 +290,14 @@ export interface FulfillOrder_orderFulfill_order_invoices {
status: JobStatusEnum;
}
+export interface FulfillOrder_orderFulfill_order_channel {
+ __typename: "Channel";
+ isActive: boolean;
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
export interface FulfillOrder_orderFulfill_order {
__typename: "Order";
id: string;
@@ -335,6 +327,7 @@ export interface FulfillOrder_orderFulfill_order {
availableShippingMethods: (FulfillOrder_orderFulfill_order_availableShippingMethods | null)[] | null;
discount: FulfillOrder_orderFulfill_order_discount | null;
invoices: (FulfillOrder_orderFulfill_order_invoices | null)[] | null;
+ channel: FulfillOrder_orderFulfill_order_channel;
}
export interface FulfillOrder_orderFulfill {
diff --git a/src/orders/types/OrderCancel.ts b/src/orders/types/OrderCancel.ts
index a188bbaf8..434ca5214 100644
--- a/src/orders/types/OrderCancel.ts
+++ b/src/orders/types/OrderCancel.ts
@@ -68,17 +68,9 @@ export interface OrderCancel_orderCancel_order_events {
user: OrderCancel_orderCancel_order_events_user | null;
}
-export interface OrderCancel_orderCancel_order_fulfillments_lines_orderLine_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderCancel_orderCancel_order_fulfillments_lines_orderLine_variant {
__typename: "ProductVariant";
id: string;
- product: OrderCancel_orderCancel_order_fulfillments_lines_orderLine_variant_product;
quantityAvailable: number;
}
@@ -141,17 +133,9 @@ export interface OrderCancel_orderCancel_order_fulfillments {
warehouse: OrderCancel_orderCancel_order_fulfillments_warehouse | null;
}
-export interface OrderCancel_orderCancel_order_lines_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderCancel_orderCancel_order_lines_variant {
__typename: "ProductVariant";
id: string;
- product: OrderCancel_orderCancel_order_lines_variant_product;
quantityAvailable: number;
}
@@ -304,6 +288,14 @@ export interface OrderCancel_orderCancel_order_invoices {
status: JobStatusEnum;
}
+export interface OrderCancel_orderCancel_order_channel {
+ __typename: "Channel";
+ isActive: boolean;
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
export interface OrderCancel_orderCancel_order {
__typename: "Order";
id: string;
@@ -333,6 +325,7 @@ export interface OrderCancel_orderCancel_order {
availableShippingMethods: (OrderCancel_orderCancel_order_availableShippingMethods | null)[] | null;
discount: OrderCancel_orderCancel_order_discount | null;
invoices: (OrderCancel_orderCancel_order_invoices | null)[] | null;
+ channel: OrderCancel_orderCancel_order_channel;
}
export interface OrderCancel_orderCancel {
diff --git a/src/orders/types/OrderCapture.ts b/src/orders/types/OrderCapture.ts
index f81eabdd0..536aabda6 100644
--- a/src/orders/types/OrderCapture.ts
+++ b/src/orders/types/OrderCapture.ts
@@ -68,17 +68,9 @@ export interface OrderCapture_orderCapture_order_events {
user: OrderCapture_orderCapture_order_events_user | null;
}
-export interface OrderCapture_orderCapture_order_fulfillments_lines_orderLine_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderCapture_orderCapture_order_fulfillments_lines_orderLine_variant {
__typename: "ProductVariant";
id: string;
- product: OrderCapture_orderCapture_order_fulfillments_lines_orderLine_variant_product;
quantityAvailable: number;
}
@@ -141,17 +133,9 @@ export interface OrderCapture_orderCapture_order_fulfillments {
warehouse: OrderCapture_orderCapture_order_fulfillments_warehouse | null;
}
-export interface OrderCapture_orderCapture_order_lines_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderCapture_orderCapture_order_lines_variant {
__typename: "ProductVariant";
id: string;
- product: OrderCapture_orderCapture_order_lines_variant_product;
quantityAvailable: number;
}
@@ -304,6 +288,14 @@ export interface OrderCapture_orderCapture_order_invoices {
status: JobStatusEnum;
}
+export interface OrderCapture_orderCapture_order_channel {
+ __typename: "Channel";
+ isActive: boolean;
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
export interface OrderCapture_orderCapture_order {
__typename: "Order";
id: string;
@@ -333,6 +325,7 @@ export interface OrderCapture_orderCapture_order {
availableShippingMethods: (OrderCapture_orderCapture_order_availableShippingMethods | null)[] | null;
discount: OrderCapture_orderCapture_order_discount | null;
invoices: (OrderCapture_orderCapture_order_invoices | null)[] | null;
+ channel: OrderCapture_orderCapture_order_channel;
}
export interface OrderCapture_orderCapture {
diff --git a/src/orders/types/OrderDetails.ts b/src/orders/types/OrderDetails.ts
index f9bca7b9a..1ed9adac7 100644
--- a/src/orders/types/OrderDetails.ts
+++ b/src/orders/types/OrderDetails.ts
@@ -62,17 +62,9 @@ export interface OrderDetails_order_events {
user: OrderDetails_order_events_user | null;
}
-export interface OrderDetails_order_fulfillments_lines_orderLine_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderDetails_order_fulfillments_lines_orderLine_variant {
__typename: "ProductVariant";
id: string;
- product: OrderDetails_order_fulfillments_lines_orderLine_variant_product;
quantityAvailable: number;
}
@@ -135,17 +127,9 @@ export interface OrderDetails_order_fulfillments {
warehouse: OrderDetails_order_fulfillments_warehouse | null;
}
-export interface OrderDetails_order_lines_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderDetails_order_lines_variant {
__typename: "ProductVariant";
id: string;
- product: OrderDetails_order_lines_variant_product;
quantityAvailable: number;
}
@@ -298,6 +282,14 @@ export interface OrderDetails_order_invoices {
status: JobStatusEnum;
}
+export interface OrderDetails_order_channel {
+ __typename: "Channel";
+ isActive: boolean;
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
export interface OrderDetails_order {
__typename: "Order";
id: string;
@@ -327,6 +319,7 @@ export interface OrderDetails_order {
availableShippingMethods: (OrderDetails_order_availableShippingMethods | null)[] | null;
discount: OrderDetails_order_discount | null;
invoices: (OrderDetails_order_invoices | null)[] | null;
+ channel: OrderDetails_order_channel;
}
export interface OrderDetails_shop_countries {
diff --git a/src/orders/types/OrderDraftCancel.ts b/src/orders/types/OrderDraftCancel.ts
index 6c47653b8..d6a74c8c8 100644
--- a/src/orders/types/OrderDraftCancel.ts
+++ b/src/orders/types/OrderDraftCancel.ts
@@ -68,17 +68,9 @@ export interface OrderDraftCancel_draftOrderDelete_order_events {
user: OrderDraftCancel_draftOrderDelete_order_events_user | null;
}
-export interface OrderDraftCancel_draftOrderDelete_order_fulfillments_lines_orderLine_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderDraftCancel_draftOrderDelete_order_fulfillments_lines_orderLine_variant {
__typename: "ProductVariant";
id: string;
- product: OrderDraftCancel_draftOrderDelete_order_fulfillments_lines_orderLine_variant_product;
quantityAvailable: number;
}
@@ -141,17 +133,9 @@ export interface OrderDraftCancel_draftOrderDelete_order_fulfillments {
warehouse: OrderDraftCancel_draftOrderDelete_order_fulfillments_warehouse | null;
}
-export interface OrderDraftCancel_draftOrderDelete_order_lines_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderDraftCancel_draftOrderDelete_order_lines_variant {
__typename: "ProductVariant";
id: string;
- product: OrderDraftCancel_draftOrderDelete_order_lines_variant_product;
quantityAvailable: number;
}
@@ -304,6 +288,14 @@ export interface OrderDraftCancel_draftOrderDelete_order_invoices {
status: JobStatusEnum;
}
+export interface OrderDraftCancel_draftOrderDelete_order_channel {
+ __typename: "Channel";
+ isActive: boolean;
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
export interface OrderDraftCancel_draftOrderDelete_order {
__typename: "Order";
id: string;
@@ -333,6 +325,7 @@ export interface OrderDraftCancel_draftOrderDelete_order {
availableShippingMethods: (OrderDraftCancel_draftOrderDelete_order_availableShippingMethods | null)[] | null;
discount: OrderDraftCancel_draftOrderDelete_order_discount | null;
invoices: (OrderDraftCancel_draftOrderDelete_order_invoices | null)[] | null;
+ channel: OrderDraftCancel_draftOrderDelete_order_channel;
}
export interface OrderDraftCancel_draftOrderDelete {
diff --git a/src/orders/types/OrderDraftCreate.ts b/src/orders/types/OrderDraftCreate.ts
index d4b1fcbe1..a0250f872 100644
--- a/src/orders/types/OrderDraftCreate.ts
+++ b/src/orders/types/OrderDraftCreate.ts
@@ -2,7 +2,7 @@
/* eslint-disable */
// This file was automatically generated and should not be edited.
-import { OrderErrorCode } from "./../../types/globalTypes";
+import { DraftOrderCreateInput, OrderErrorCode } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: OrderDraftCreate
@@ -28,3 +28,7 @@ export interface OrderDraftCreate_draftOrderCreate {
export interface OrderDraftCreate {
draftOrderCreate: OrderDraftCreate_draftOrderCreate | null;
}
+
+export interface OrderDraftCreateVariables {
+ input: DraftOrderCreateInput;
+}
diff --git a/src/orders/types/OrderDraftFinalize.ts b/src/orders/types/OrderDraftFinalize.ts
index 2791df488..b674cd776 100644
--- a/src/orders/types/OrderDraftFinalize.ts
+++ b/src/orders/types/OrderDraftFinalize.ts
@@ -68,17 +68,9 @@ export interface OrderDraftFinalize_draftOrderComplete_order_events {
user: OrderDraftFinalize_draftOrderComplete_order_events_user | null;
}
-export interface OrderDraftFinalize_draftOrderComplete_order_fulfillments_lines_orderLine_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderDraftFinalize_draftOrderComplete_order_fulfillments_lines_orderLine_variant {
__typename: "ProductVariant";
id: string;
- product: OrderDraftFinalize_draftOrderComplete_order_fulfillments_lines_orderLine_variant_product;
quantityAvailable: number;
}
@@ -141,17 +133,9 @@ export interface OrderDraftFinalize_draftOrderComplete_order_fulfillments {
warehouse: OrderDraftFinalize_draftOrderComplete_order_fulfillments_warehouse | null;
}
-export interface OrderDraftFinalize_draftOrderComplete_order_lines_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderDraftFinalize_draftOrderComplete_order_lines_variant {
__typename: "ProductVariant";
id: string;
- product: OrderDraftFinalize_draftOrderComplete_order_lines_variant_product;
quantityAvailable: number;
}
@@ -304,6 +288,14 @@ export interface OrderDraftFinalize_draftOrderComplete_order_invoices {
status: JobStatusEnum;
}
+export interface OrderDraftFinalize_draftOrderComplete_order_channel {
+ __typename: "Channel";
+ isActive: boolean;
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
export interface OrderDraftFinalize_draftOrderComplete_order {
__typename: "Order";
id: string;
@@ -333,6 +325,7 @@ export interface OrderDraftFinalize_draftOrderComplete_order {
availableShippingMethods: (OrderDraftFinalize_draftOrderComplete_order_availableShippingMethods | null)[] | null;
discount: OrderDraftFinalize_draftOrderComplete_order_discount | null;
invoices: (OrderDraftFinalize_draftOrderComplete_order_invoices | null)[] | null;
+ channel: OrderDraftFinalize_draftOrderComplete_order_channel;
}
export interface OrderDraftFinalize_draftOrderComplete {
diff --git a/src/orders/types/OrderDraftUpdate.ts b/src/orders/types/OrderDraftUpdate.ts
index 7245884aa..2e138f858 100644
--- a/src/orders/types/OrderDraftUpdate.ts
+++ b/src/orders/types/OrderDraftUpdate.ts
@@ -68,17 +68,9 @@ export interface OrderDraftUpdate_draftOrderUpdate_order_events {
user: OrderDraftUpdate_draftOrderUpdate_order_events_user | null;
}
-export interface OrderDraftUpdate_draftOrderUpdate_order_fulfillments_lines_orderLine_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderDraftUpdate_draftOrderUpdate_order_fulfillments_lines_orderLine_variant {
__typename: "ProductVariant";
id: string;
- product: OrderDraftUpdate_draftOrderUpdate_order_fulfillments_lines_orderLine_variant_product;
quantityAvailable: number;
}
@@ -141,17 +133,9 @@ export interface OrderDraftUpdate_draftOrderUpdate_order_fulfillments {
warehouse: OrderDraftUpdate_draftOrderUpdate_order_fulfillments_warehouse | null;
}
-export interface OrderDraftUpdate_draftOrderUpdate_order_lines_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderDraftUpdate_draftOrderUpdate_order_lines_variant {
__typename: "ProductVariant";
id: string;
- product: OrderDraftUpdate_draftOrderUpdate_order_lines_variant_product;
quantityAvailable: number;
}
@@ -304,6 +288,14 @@ export interface OrderDraftUpdate_draftOrderUpdate_order_invoices {
status: JobStatusEnum;
}
+export interface OrderDraftUpdate_draftOrderUpdate_order_channel {
+ __typename: "Channel";
+ isActive: boolean;
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
export interface OrderDraftUpdate_draftOrderUpdate_order {
__typename: "Order";
id: string;
@@ -333,6 +325,7 @@ export interface OrderDraftUpdate_draftOrderUpdate_order {
availableShippingMethods: (OrderDraftUpdate_draftOrderUpdate_order_availableShippingMethods | null)[] | null;
discount: OrderDraftUpdate_draftOrderUpdate_order_discount | null;
invoices: (OrderDraftUpdate_draftOrderUpdate_order_invoices | null)[] | null;
+ channel: OrderDraftUpdate_draftOrderUpdate_order_channel;
}
export interface OrderDraftUpdate_draftOrderUpdate {
diff --git a/src/orders/types/OrderFulfillmentCancel.ts b/src/orders/types/OrderFulfillmentCancel.ts
index 4948102da..94c1149dc 100644
--- a/src/orders/types/OrderFulfillmentCancel.ts
+++ b/src/orders/types/OrderFulfillmentCancel.ts
@@ -68,17 +68,9 @@ export interface OrderFulfillmentCancel_orderFulfillmentCancel_order_events {
user: OrderFulfillmentCancel_orderFulfillmentCancel_order_events_user | null;
}
-export interface OrderFulfillmentCancel_orderFulfillmentCancel_order_fulfillments_lines_orderLine_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderFulfillmentCancel_orderFulfillmentCancel_order_fulfillments_lines_orderLine_variant {
__typename: "ProductVariant";
id: string;
- product: OrderFulfillmentCancel_orderFulfillmentCancel_order_fulfillments_lines_orderLine_variant_product;
quantityAvailable: number;
}
@@ -141,17 +133,9 @@ export interface OrderFulfillmentCancel_orderFulfillmentCancel_order_fulfillment
warehouse: OrderFulfillmentCancel_orderFulfillmentCancel_order_fulfillments_warehouse | null;
}
-export interface OrderFulfillmentCancel_orderFulfillmentCancel_order_lines_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderFulfillmentCancel_orderFulfillmentCancel_order_lines_variant {
__typename: "ProductVariant";
id: string;
- product: OrderFulfillmentCancel_orderFulfillmentCancel_order_lines_variant_product;
quantityAvailable: number;
}
@@ -304,6 +288,14 @@ export interface OrderFulfillmentCancel_orderFulfillmentCancel_order_invoices {
status: JobStatusEnum;
}
+export interface OrderFulfillmentCancel_orderFulfillmentCancel_order_channel {
+ __typename: "Channel";
+ isActive: boolean;
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
export interface OrderFulfillmentCancel_orderFulfillmentCancel_order {
__typename: "Order";
id: string;
@@ -333,6 +325,7 @@ export interface OrderFulfillmentCancel_orderFulfillmentCancel_order {
availableShippingMethods: (OrderFulfillmentCancel_orderFulfillmentCancel_order_availableShippingMethods | null)[] | null;
discount: OrderFulfillmentCancel_orderFulfillmentCancel_order_discount | null;
invoices: (OrderFulfillmentCancel_orderFulfillmentCancel_order_invoices | null)[] | null;
+ channel: OrderFulfillmentCancel_orderFulfillmentCancel_order_channel;
}
export interface OrderFulfillmentCancel_orderFulfillmentCancel {
diff --git a/src/orders/types/OrderFulfillmentUpdateTracking.ts b/src/orders/types/OrderFulfillmentUpdateTracking.ts
index 98cbff6ed..7111f736e 100644
--- a/src/orders/types/OrderFulfillmentUpdateTracking.ts
+++ b/src/orders/types/OrderFulfillmentUpdateTracking.ts
@@ -68,17 +68,9 @@ export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_o
user: OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_events_user | null;
}
-export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_fulfillments_lines_orderLine_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_fulfillments_lines_orderLine_variant {
__typename: "ProductVariant";
id: string;
- product: OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_fulfillments_lines_orderLine_variant_product;
quantityAvailable: number;
}
@@ -141,17 +133,9 @@ export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_o
warehouse: OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_fulfillments_warehouse | null;
}
-export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_lines_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_lines_variant {
__typename: "ProductVariant";
id: string;
- product: OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_lines_variant_product;
quantityAvailable: number;
}
@@ -304,6 +288,14 @@ export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_o
status: JobStatusEnum;
}
+export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_channel {
+ __typename: "Channel";
+ isActive: boolean;
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order {
__typename: "Order";
id: string;
@@ -333,6 +325,7 @@ export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_o
availableShippingMethods: (OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_availableShippingMethods | null)[] | null;
discount: OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_discount | null;
invoices: (OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_invoices | null)[] | null;
+ channel: OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_channel;
}
export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking {
diff --git a/src/orders/types/OrderLineDelete.ts b/src/orders/types/OrderLineDelete.ts
index 9fce897f0..97208fb37 100644
--- a/src/orders/types/OrderLineDelete.ts
+++ b/src/orders/types/OrderLineDelete.ts
@@ -68,17 +68,9 @@ export interface OrderLineDelete_draftOrderLineDelete_order_events {
user: OrderLineDelete_draftOrderLineDelete_order_events_user | null;
}
-export interface OrderLineDelete_draftOrderLineDelete_order_fulfillments_lines_orderLine_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderLineDelete_draftOrderLineDelete_order_fulfillments_lines_orderLine_variant {
__typename: "ProductVariant";
id: string;
- product: OrderLineDelete_draftOrderLineDelete_order_fulfillments_lines_orderLine_variant_product;
quantityAvailable: number;
}
@@ -141,17 +133,9 @@ export interface OrderLineDelete_draftOrderLineDelete_order_fulfillments {
warehouse: OrderLineDelete_draftOrderLineDelete_order_fulfillments_warehouse | null;
}
-export interface OrderLineDelete_draftOrderLineDelete_order_lines_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderLineDelete_draftOrderLineDelete_order_lines_variant {
__typename: "ProductVariant";
id: string;
- product: OrderLineDelete_draftOrderLineDelete_order_lines_variant_product;
quantityAvailable: number;
}
@@ -304,6 +288,14 @@ export interface OrderLineDelete_draftOrderLineDelete_order_invoices {
status: JobStatusEnum;
}
+export interface OrderLineDelete_draftOrderLineDelete_order_channel {
+ __typename: "Channel";
+ isActive: boolean;
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
export interface OrderLineDelete_draftOrderLineDelete_order {
__typename: "Order";
id: string;
@@ -333,6 +325,7 @@ export interface OrderLineDelete_draftOrderLineDelete_order {
availableShippingMethods: (OrderLineDelete_draftOrderLineDelete_order_availableShippingMethods | null)[] | null;
discount: OrderLineDelete_draftOrderLineDelete_order_discount | null;
invoices: (OrderLineDelete_draftOrderLineDelete_order_invoices | null)[] | null;
+ channel: OrderLineDelete_draftOrderLineDelete_order_channel;
}
export interface OrderLineDelete_draftOrderLineDelete {
diff --git a/src/orders/types/OrderLineUpdate.ts b/src/orders/types/OrderLineUpdate.ts
index 61abff145..d10573fcb 100644
--- a/src/orders/types/OrderLineUpdate.ts
+++ b/src/orders/types/OrderLineUpdate.ts
@@ -68,17 +68,9 @@ export interface OrderLineUpdate_draftOrderLineUpdate_order_events {
user: OrderLineUpdate_draftOrderLineUpdate_order_events_user | null;
}
-export interface OrderLineUpdate_draftOrderLineUpdate_order_fulfillments_lines_orderLine_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderLineUpdate_draftOrderLineUpdate_order_fulfillments_lines_orderLine_variant {
__typename: "ProductVariant";
id: string;
- product: OrderLineUpdate_draftOrderLineUpdate_order_fulfillments_lines_orderLine_variant_product;
quantityAvailable: number;
}
@@ -141,17 +133,9 @@ export interface OrderLineUpdate_draftOrderLineUpdate_order_fulfillments {
warehouse: OrderLineUpdate_draftOrderLineUpdate_order_fulfillments_warehouse | null;
}
-export interface OrderLineUpdate_draftOrderLineUpdate_order_lines_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderLineUpdate_draftOrderLineUpdate_order_lines_variant {
__typename: "ProductVariant";
id: string;
- product: OrderLineUpdate_draftOrderLineUpdate_order_lines_variant_product;
quantityAvailable: number;
}
@@ -304,6 +288,14 @@ export interface OrderLineUpdate_draftOrderLineUpdate_order_invoices {
status: JobStatusEnum;
}
+export interface OrderLineUpdate_draftOrderLineUpdate_order_channel {
+ __typename: "Channel";
+ isActive: boolean;
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
export interface OrderLineUpdate_draftOrderLineUpdate_order {
__typename: "Order";
id: string;
@@ -333,6 +325,7 @@ export interface OrderLineUpdate_draftOrderLineUpdate_order {
availableShippingMethods: (OrderLineUpdate_draftOrderLineUpdate_order_availableShippingMethods | null)[] | null;
discount: OrderLineUpdate_draftOrderLineUpdate_order_discount | null;
invoices: (OrderLineUpdate_draftOrderLineUpdate_order_invoices | null)[] | null;
+ channel: OrderLineUpdate_draftOrderLineUpdate_order_channel;
}
export interface OrderLineUpdate_draftOrderLineUpdate {
diff --git a/src/orders/types/OrderLinesAdd.ts b/src/orders/types/OrderLinesAdd.ts
index 43d71a9be..ae3e7284b 100644
--- a/src/orders/types/OrderLinesAdd.ts
+++ b/src/orders/types/OrderLinesAdd.ts
@@ -68,17 +68,9 @@ export interface OrderLinesAdd_draftOrderLinesCreate_order_events {
user: OrderLinesAdd_draftOrderLinesCreate_order_events_user | null;
}
-export interface OrderLinesAdd_draftOrderLinesCreate_order_fulfillments_lines_orderLine_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderLinesAdd_draftOrderLinesCreate_order_fulfillments_lines_orderLine_variant {
__typename: "ProductVariant";
id: string;
- product: OrderLinesAdd_draftOrderLinesCreate_order_fulfillments_lines_orderLine_variant_product;
quantityAvailable: number;
}
@@ -141,17 +133,9 @@ export interface OrderLinesAdd_draftOrderLinesCreate_order_fulfillments {
warehouse: OrderLinesAdd_draftOrderLinesCreate_order_fulfillments_warehouse | null;
}
-export interface OrderLinesAdd_draftOrderLinesCreate_order_lines_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderLinesAdd_draftOrderLinesCreate_order_lines_variant {
__typename: "ProductVariant";
id: string;
- product: OrderLinesAdd_draftOrderLinesCreate_order_lines_variant_product;
quantityAvailable: number;
}
@@ -304,6 +288,14 @@ export interface OrderLinesAdd_draftOrderLinesCreate_order_invoices {
status: JobStatusEnum;
}
+export interface OrderLinesAdd_draftOrderLinesCreate_order_channel {
+ __typename: "Channel";
+ isActive: boolean;
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
export interface OrderLinesAdd_draftOrderLinesCreate_order {
__typename: "Order";
id: string;
@@ -333,6 +325,7 @@ export interface OrderLinesAdd_draftOrderLinesCreate_order {
availableShippingMethods: (OrderLinesAdd_draftOrderLinesCreate_order_availableShippingMethods | null)[] | null;
discount: OrderLinesAdd_draftOrderLinesCreate_order_discount | null;
invoices: (OrderLinesAdd_draftOrderLinesCreate_order_invoices | null)[] | null;
+ channel: OrderLinesAdd_draftOrderLinesCreate_order_channel;
}
export interface OrderLinesAdd_draftOrderLinesCreate {
diff --git a/src/orders/types/OrderMarkAsPaid.ts b/src/orders/types/OrderMarkAsPaid.ts
index d1c6eec57..d5caa14ba 100644
--- a/src/orders/types/OrderMarkAsPaid.ts
+++ b/src/orders/types/OrderMarkAsPaid.ts
@@ -68,17 +68,9 @@ export interface OrderMarkAsPaid_orderMarkAsPaid_order_events {
user: OrderMarkAsPaid_orderMarkAsPaid_order_events_user | null;
}
-export interface OrderMarkAsPaid_orderMarkAsPaid_order_fulfillments_lines_orderLine_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderMarkAsPaid_orderMarkAsPaid_order_fulfillments_lines_orderLine_variant {
__typename: "ProductVariant";
id: string;
- product: OrderMarkAsPaid_orderMarkAsPaid_order_fulfillments_lines_orderLine_variant_product;
quantityAvailable: number;
}
@@ -141,17 +133,9 @@ export interface OrderMarkAsPaid_orderMarkAsPaid_order_fulfillments {
warehouse: OrderMarkAsPaid_orderMarkAsPaid_order_fulfillments_warehouse | null;
}
-export interface OrderMarkAsPaid_orderMarkAsPaid_order_lines_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderMarkAsPaid_orderMarkAsPaid_order_lines_variant {
__typename: "ProductVariant";
id: string;
- product: OrderMarkAsPaid_orderMarkAsPaid_order_lines_variant_product;
quantityAvailable: number;
}
@@ -304,6 +288,14 @@ export interface OrderMarkAsPaid_orderMarkAsPaid_order_invoices {
status: JobStatusEnum;
}
+export interface OrderMarkAsPaid_orderMarkAsPaid_order_channel {
+ __typename: "Channel";
+ isActive: boolean;
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
export interface OrderMarkAsPaid_orderMarkAsPaid_order {
__typename: "Order";
id: string;
@@ -333,6 +325,7 @@ export interface OrderMarkAsPaid_orderMarkAsPaid_order {
availableShippingMethods: (OrderMarkAsPaid_orderMarkAsPaid_order_availableShippingMethods | null)[] | null;
discount: OrderMarkAsPaid_orderMarkAsPaid_order_discount | null;
invoices: (OrderMarkAsPaid_orderMarkAsPaid_order_invoices | null)[] | null;
+ channel: OrderMarkAsPaid_orderMarkAsPaid_order_channel;
}
export interface OrderMarkAsPaid_orderMarkAsPaid {
diff --git a/src/orders/types/OrderRefund.ts b/src/orders/types/OrderRefund.ts
index 44bc188cb..515ff4984 100644
--- a/src/orders/types/OrderRefund.ts
+++ b/src/orders/types/OrderRefund.ts
@@ -68,17 +68,9 @@ export interface OrderRefund_orderRefund_order_events {
user: OrderRefund_orderRefund_order_events_user | null;
}
-export interface OrderRefund_orderRefund_order_fulfillments_lines_orderLine_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderRefund_orderRefund_order_fulfillments_lines_orderLine_variant {
__typename: "ProductVariant";
id: string;
- product: OrderRefund_orderRefund_order_fulfillments_lines_orderLine_variant_product;
quantityAvailable: number;
}
@@ -141,17 +133,9 @@ export interface OrderRefund_orderRefund_order_fulfillments {
warehouse: OrderRefund_orderRefund_order_fulfillments_warehouse | null;
}
-export interface OrderRefund_orderRefund_order_lines_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderRefund_orderRefund_order_lines_variant {
__typename: "ProductVariant";
id: string;
- product: OrderRefund_orderRefund_order_lines_variant_product;
quantityAvailable: number;
}
@@ -304,6 +288,14 @@ export interface OrderRefund_orderRefund_order_invoices {
status: JobStatusEnum;
}
+export interface OrderRefund_orderRefund_order_channel {
+ __typename: "Channel";
+ isActive: boolean;
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
export interface OrderRefund_orderRefund_order {
__typename: "Order";
id: string;
@@ -333,6 +325,7 @@ export interface OrderRefund_orderRefund_order {
availableShippingMethods: (OrderRefund_orderRefund_order_availableShippingMethods | null)[] | null;
discount: OrderRefund_orderRefund_order_discount | null;
invoices: (OrderRefund_orderRefund_order_invoices | null)[] | null;
+ channel: OrderRefund_orderRefund_order_channel;
}
export interface OrderRefund_orderRefund {
diff --git a/src/orders/types/OrderUpdate.ts b/src/orders/types/OrderUpdate.ts
index e924dac73..f71308c29 100644
--- a/src/orders/types/OrderUpdate.ts
+++ b/src/orders/types/OrderUpdate.ts
@@ -68,17 +68,9 @@ export interface OrderUpdate_orderUpdate_order_events {
user: OrderUpdate_orderUpdate_order_events_user | null;
}
-export interface OrderUpdate_orderUpdate_order_fulfillments_lines_orderLine_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderUpdate_orderUpdate_order_fulfillments_lines_orderLine_variant {
__typename: "ProductVariant";
id: string;
- product: OrderUpdate_orderUpdate_order_fulfillments_lines_orderLine_variant_product;
quantityAvailable: number;
}
@@ -141,17 +133,9 @@ export interface OrderUpdate_orderUpdate_order_fulfillments {
warehouse: OrderUpdate_orderUpdate_order_fulfillments_warehouse | null;
}
-export interface OrderUpdate_orderUpdate_order_lines_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderUpdate_orderUpdate_order_lines_variant {
__typename: "ProductVariant";
id: string;
- product: OrderUpdate_orderUpdate_order_lines_variant_product;
quantityAvailable: number;
}
@@ -304,6 +288,14 @@ export interface OrderUpdate_orderUpdate_order_invoices {
status: JobStatusEnum;
}
+export interface OrderUpdate_orderUpdate_order_channel {
+ __typename: "Channel";
+ isActive: boolean;
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
export interface OrderUpdate_orderUpdate_order {
__typename: "Order";
id: string;
@@ -333,6 +325,7 @@ export interface OrderUpdate_orderUpdate_order {
availableShippingMethods: (OrderUpdate_orderUpdate_order_availableShippingMethods | null)[] | null;
discount: OrderUpdate_orderUpdate_order_discount | null;
invoices: (OrderUpdate_orderUpdate_order_invoices | null)[] | null;
+ channel: OrderUpdate_orderUpdate_order_channel;
}
export interface OrderUpdate_orderUpdate {
diff --git a/src/orders/types/OrderVoid.ts b/src/orders/types/OrderVoid.ts
index 3a60d9c27..f36614923 100644
--- a/src/orders/types/OrderVoid.ts
+++ b/src/orders/types/OrderVoid.ts
@@ -68,17 +68,9 @@ export interface OrderVoid_orderVoid_order_events {
user: OrderVoid_orderVoid_order_events_user | null;
}
-export interface OrderVoid_orderVoid_order_fulfillments_lines_orderLine_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderVoid_orderVoid_order_fulfillments_lines_orderLine_variant {
__typename: "ProductVariant";
id: string;
- product: OrderVoid_orderVoid_order_fulfillments_lines_orderLine_variant_product;
quantityAvailable: number;
}
@@ -141,17 +133,9 @@ export interface OrderVoid_orderVoid_order_fulfillments {
warehouse: OrderVoid_orderVoid_order_fulfillments_warehouse | null;
}
-export interface OrderVoid_orderVoid_order_lines_variant_product {
- __typename: "Product";
- id: string;
- isAvailableForPurchase: boolean | null;
- isPublished: boolean;
-}
-
export interface OrderVoid_orderVoid_order_lines_variant {
__typename: "ProductVariant";
id: string;
- product: OrderVoid_orderVoid_order_lines_variant_product;
quantityAvailable: number;
}
@@ -304,6 +288,14 @@ export interface OrderVoid_orderVoid_order_invoices {
status: JobStatusEnum;
}
+export interface OrderVoid_orderVoid_order_channel {
+ __typename: "Channel";
+ isActive: boolean;
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
export interface OrderVoid_orderVoid_order {
__typename: "Order";
id: string;
@@ -333,6 +325,7 @@ export interface OrderVoid_orderVoid_order {
availableShippingMethods: (OrderVoid_orderVoid_order_availableShippingMethods | null)[] | null;
discount: OrderVoid_orderVoid_order_discount | null;
invoices: (OrderVoid_orderVoid_order_invoices | null)[] | null;
+ channel: OrderVoid_orderVoid_order_channel;
}
export interface OrderVoid_orderVoid {
diff --git a/src/orders/types/SearchOrderVariant.ts b/src/orders/types/SearchOrderVariant.ts
index 5934b1625..8cad833fb 100644
--- a/src/orders/types/SearchOrderVariant.ts
+++ b/src/orders/types/SearchOrderVariant.ts
@@ -11,20 +11,24 @@ export interface SearchOrderVariant_search_edges_node_thumbnail {
url: string;
}
-export interface SearchOrderVariant_search_edges_node_variants_pricing_priceUndiscounted_net {
+export interface SearchOrderVariant_search_edges_node_variants_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ isActive: boolean;
+ name: string;
+ currencyCode: string;
+}
+
+export interface SearchOrderVariant_search_edges_node_variants_channelListings_price {
__typename: "Money";
amount: number;
currency: string;
}
-export interface SearchOrderVariant_search_edges_node_variants_pricing_priceUndiscounted {
- __typename: "TaxedMoney";
- net: SearchOrderVariant_search_edges_node_variants_pricing_priceUndiscounted_net;
-}
-
-export interface SearchOrderVariant_search_edges_node_variants_pricing {
- __typename: "VariantPricingInfo";
- priceUndiscounted: SearchOrderVariant_search_edges_node_variants_pricing_priceUndiscounted | null;
+export interface SearchOrderVariant_search_edges_node_variants_channelListings {
+ __typename: "ProductVariantChannelListing";
+ channel: SearchOrderVariant_search_edges_node_variants_channelListings_channel;
+ price: SearchOrderVariant_search_edges_node_variants_channelListings_price | null;
}
export interface SearchOrderVariant_search_edges_node_variants {
@@ -32,7 +36,7 @@ export interface SearchOrderVariant_search_edges_node_variants {
id: string;
name: string;
sku: string;
- pricing: SearchOrderVariant_search_edges_node_variants_pricing | null;
+ channelListings: SearchOrderVariant_search_edges_node_variants_channelListings[] | null;
}
export interface SearchOrderVariant_search_edges_node {
diff --git a/src/orders/urls.ts b/src/orders/urls.ts
index 0efa7ffde..745a43582 100644
--- a/src/orders/urls.ts
+++ b/src/orders/urls.ts
@@ -28,7 +28,7 @@ export enum OrderListUrlFiltersWithMultipleValuesEnum {
}
export type OrderListUrlFilters = Filters &
FiltersWithMultipleValues;
-export type OrderListUrlDialog = "cancel" | TabActionDialog;
+export type OrderListUrlDialog = "cancel" | "settings" | TabActionDialog;
export enum OrderListUrlSortField {
number = "number",
customer = "customer",
@@ -61,7 +61,7 @@ export enum OrderDraftListUrlFiltersEnum {
query = "query"
}
export type OrderDraftListUrlFilters = Filters;
-export type OrderDraftListUrlDialog = "remove" | TabActionDialog;
+export type OrderDraftListUrlDialog = "remove" | "settings" | TabActionDialog;
export enum OrderDraftListUrlSortField {
number = "number",
customer = "customer",
diff --git a/src/orders/views/OrderDetails/index.tsx b/src/orders/views/OrderDetails/index.tsx
index 4d843b793..8d03bc4c7 100644
--- a/src/orders/views/OrderDetails/index.tsx
+++ b/src/orders/views/OrderDetails/index.tsx
@@ -62,6 +62,7 @@ interface OrderDetailsProps {
export const OrderDetails: React.FC = ({ id, params }) => {
const navigate = useNavigator();
const { user } = useUser();
+
const {
loadMore: loadMoreCustomers,
search: searchUsers,
@@ -102,7 +103,6 @@ export const OrderDetails: React.FC = ({ id, params }) => {
{({ data, loading }) => {
const order = data?.order;
-
if (order === null) {
return ;
}
@@ -561,6 +561,7 @@ export const OrderDetails: React.FC = ({ id, params }) => {
products={variantSearchOpts.data?.search.edges.map(
edge => edge.node
)}
+ selectedChannel={order?.channel?.id}
onClose={closeModal}
onFetch={variantSearch}
onFetchMore={loadMore}
diff --git a/src/orders/views/OrderDraftList/OrderDraftList.tsx b/src/orders/views/OrderDraftList/OrderDraftList.tsx
index a44b38f25..73b37503a 100644
--- a/src/orders/views/OrderDraftList/OrderDraftList.tsx
+++ b/src/orders/views/OrderDraftList/OrderDraftList.tsx
@@ -1,19 +1,20 @@
import DialogContentText from "@material-ui/core/DialogContentText";
import IconButton from "@material-ui/core/IconButton";
import DeleteIcon from "@material-ui/icons/Delete";
+import ChannelSettingsDialog from "@saleor/channels/components/ChannelSettingsDialog";
import ActionDialog from "@saleor/components/ActionDialog";
import DeleteFilterTabDialog from "@saleor/components/DeleteFilterTabDialog";
import SaveFilterTabDialog, {
SaveFilterTabDialogFormData
} from "@saleor/components/SaveFilterTabDialog";
import useBulkActions from "@saleor/hooks/useBulkActions";
+import useChannelsSettings from "@saleor/hooks/useChannelsSettings";
import useListSettings from "@saleor/hooks/useListSettings";
import useNavigator from "@saleor/hooks/useNavigator";
import useNotifier from "@saleor/hooks/useNotifier";
import usePaginator, {
createPaginationState
} from "@saleor/hooks/usePaginator";
-import useShop from "@saleor/hooks/useShop";
import { maybe } from "@saleor/misc";
import { ListViews } from "@saleor/types";
import createDialogActionHandlers from "@saleor/utils/handlers/dialogActionHandlers";
@@ -64,7 +65,6 @@ export const OrderDraftList: React.FC = ({ params }) => {
ListViews.DRAFT_LIST
);
const intl = useIntl();
- const shop = useShop();
const handleCreateOrderCreateSuccess = (data: OrderDraftCreate) => {
notify({
@@ -106,6 +106,12 @@ export const OrderDraftList: React.FC = ({ params }) => {
OrderDraftListUrlQueryParams
>(navigate, orderDraftListUrl, params);
+ const {
+ channelChoices,
+ handleChannelSelectConfirm,
+ selectedChannel
+ } = useChannelsSettings("ordersDraftListChannel", { closeModal, openModal });
+
const handleTabChange = (tab: number) => {
reset();
navigate(
@@ -162,103 +168,126 @@ export const OrderDraftList: React.FC = ({ params }) => {
};
const handleSort = createSortHandler(navigate, orderDraftListUrl, params);
- const currencySymbol = maybe(() => shop.defaultCurrency, "USD");
return (
-
- {(orderDraftBulkDelete, orderDraftBulkDeleteOpts) => {
- const onOrderDraftBulkDelete = () =>
- orderDraftBulkDelete({
- variables: {
- ids: params.ids
- }
- });
-
- return (
- <>
- openModal("delete-search")}
- onTabSave={() => openModal("save-search")}
- tabs={tabs.map(tab => tab.name)}
- disabled={loading}
- settings={settings}
- orders={maybe(() =>
- data.draftOrders.edges.map(edge => edge.node)
- )}
- pageInfo={pageInfo}
- onAdd={createOrder}
- onNextPage={loadNextPage}
- onPreviousPage={loadPreviousPage}
- onRowClick={id => () => navigate(orderUrl(id))}
- onSort={handleSort}
- onUpdateListSettings={updateListSettings}
- isChecked={isSelected}
- selected={listElements.length}
- sort={getSortParams(params)}
- toggle={toggle}
- toggleAll={toggleAll}
- toolbar={
-
- openModal("remove", {
- ids: listElements
- })
- }
- >
-
-
+ <>
+ {!!channelChoices?.length && (
+
+ )}
+
+ {(orderDraftBulkDelete, orderDraftBulkDeleteOpts) => {
+ const onOrderDraftBulkDelete = () =>
+ orderDraftBulkDelete({
+ variables: {
+ ids: params.ids
}
- />
-
-
- params.ids.length),
- displayQuantity: (
- {maybe(() => params.ids.length)}
- )
- }}
- />
-
-
-
- tabs[currentTab - 1].name, "...")}
- />
- >
- );
- }}
-
+ });
+
+ return (
+ <>
+ openModal("delete-search")}
+ onTabSave={() => openModal("save-search")}
+ tabs={tabs.map(tab => tab.name)}
+ disabled={loading}
+ settings={settings}
+ orders={maybe(() =>
+ data.draftOrders.edges.map(edge => edge.node)
+ )}
+ pageInfo={pageInfo}
+ onAdd={() =>
+ createOrder({
+ variables: {
+ input: { channel: selectedChannel }
+ }
+ })
+ }
+ onNextPage={loadNextPage}
+ onPreviousPage={loadPreviousPage}
+ onRowClick={id => () => navigate(orderUrl(id))}
+ onSort={handleSort}
+ onUpdateListSettings={updateListSettings}
+ isChecked={isSelected}
+ selected={listElements.length}
+ sort={getSortParams(params)}
+ toggle={toggle}
+ toggleAll={toggleAll}
+ toolbar={
+
+ openModal("remove", {
+ ids: listElements
+ })
+ }
+ >
+
+
+ }
+ onSettingsOpen={
+ !!channelChoices?.length
+ ? () => openModal("settings")
+ : undefined
+ }
+ />
+
+
+ params.ids.length),
+ displayQuantity: (
+ {maybe(() => params.ids.length)}
+ )
+ }}
+ />
+
+
+
+ tabs[currentTab - 1].name, "...")}
+ />
+ >
+ );
+ }}
+
+ >
);
};
diff --git a/src/orders/views/OrderDraftList/sort.ts b/src/orders/views/OrderDraftList/sort.ts
index 961bd6b87..faca9d620 100644
--- a/src/orders/views/OrderDraftList/sort.ts
+++ b/src/orders/views/OrderDraftList/sort.ts
@@ -12,8 +12,6 @@ export function getSortQueryField(
return OrderSortField.CREATION_DATE;
case OrderDraftListUrlSortField.customer:
return OrderSortField.CUSTOMER;
- case OrderDraftListUrlSortField.total:
- return OrderSortField.TOTAL;
default:
return undefined;
}
diff --git a/src/orders/views/OrderList/OrderList.tsx b/src/orders/views/OrderList/OrderList.tsx
index 04227b950..88a4b1e7b 100644
--- a/src/orders/views/OrderList/OrderList.tsx
+++ b/src/orders/views/OrderList/OrderList.tsx
@@ -1,14 +1,15 @@
+import ChannelSettingsDialog from "@saleor/channels/components/ChannelSettingsDialog";
import DeleteFilterTabDialog from "@saleor/components/DeleteFilterTabDialog";
import SaveFilterTabDialog, {
SaveFilterTabDialogFormData
} from "@saleor/components/SaveFilterTabDialog";
+import useChannelsSettings from "@saleor/hooks/useChannelsSettings";
import useListSettings from "@saleor/hooks/useListSettings";
import useNavigator from "@saleor/hooks/useNavigator";
import useNotifier from "@saleor/hooks/useNotifier";
import usePaginator, {
createPaginationState
} from "@saleor/hooks/usePaginator";
-import useShop from "@saleor/hooks/useShop";
import { getStringOrPlaceholder, maybe } from "@saleor/misc";
import { ListViews } from "@saleor/types";
import createDialogActionHandlers from "@saleor/utils/handlers/dialogActionHandlers";
@@ -48,7 +49,6 @@ export const OrderList: React.FC = ({ params }) => {
const navigate = useNavigator();
const notify = useNotifier();
const paginate = usePaginator();
- const shop = useShop();
const { updateListSettings, settings } = useListSettings(
ListViews.ORDER_LIST
);
@@ -93,6 +93,12 @@ export const OrderList: React.FC = ({ params }) => {
OrderListUrlQueryParams
>(navigate, orderListUrl, params);
+ const {
+ channelChoices,
+ handleChannelSelectConfirm,
+ selectedChannel
+ } = useChannelsSettings("ordersListChannel", { closeModal, openModal });
+
const handleTabChange = (tab: number) =>
navigate(
orderListUrl({
@@ -112,7 +118,6 @@ export const OrderList: React.FC = ({ params }) => {
};
const paginationState = createPaginationState(settings.rowNumber, params);
- const currencySymbol = maybe(() => shop.defaultCurrency, "USD");
const queryVariables = React.useMemo(
() => ({
@@ -137,8 +142,17 @@ export const OrderList: React.FC = ({ params }) => {
return (
<>
+ {!!channelChoices?.length && (
+
+ )}
= ({ params }) => {
orders={maybe(() => data.orders.edges.map(edge => edge.node))}
pageInfo={pageInfo}
sort={getSortParams(params)}
- onAdd={createOrder}
+ onAdd={() =>
+ createOrder({
+ variables: {
+ input: { channel: selectedChannel }
+ }
+ })
+ }
onNextPage={loadNextPage}
onPreviousPage={loadPreviousPage}
onUpdateListSettings={updateListSettings}
@@ -160,6 +180,9 @@ export const OrderList: React.FC = ({ params }) => {
initialSearch={params.query || ""}
tabs={getFilterTabs().map(tab => tab.name)}
onAll={resetFilters}
+ onSettingsOpen={
+ !!channelChoices?.length ? () => openModal("settings") : undefined
+ }
/>
= ({
- currencySymbol,
currentTab,
initialSearch,
filterOpts,
@@ -59,7 +58,6 @@ const PluginsListPage: React.FC = ({
= ({ params }) => {
const navigate = useNavigator();
const paginate = usePaginator();
- const shop = useShop();
const { updateListSettings, settings } = useListSettings(
ListViews.PLUGINS_LIST
);
@@ -114,12 +112,10 @@ export const PluginsList: React.FC = ({ params }) => {
);
const handleSort = createSortHandler(navigate, pluginListUrl, params);
- const currencySymbol = maybe(() => shop.defaultCurrency, "USD");
return (
<>
= ({
- currencySymbol,
currentTab,
filterOpts,
initialSearch,
@@ -73,7 +72,6 @@ const ProductTypeListPage: React.FC = ({
defaultMessage: "All Product Types",
description: "tab name"
})}
- currencySymbol={currencySymbol}
currentTab={currentTab}
filterStructure={structure}
initialSearch={initialSearch}
diff --git a/src/productTypes/views/ProductTypeList/ProductTypeList.tsx b/src/productTypes/views/ProductTypeList/ProductTypeList.tsx
index 359430b49..e308af9ea 100644
--- a/src/productTypes/views/ProductTypeList/ProductTypeList.tsx
+++ b/src/productTypes/views/ProductTypeList/ProductTypeList.tsx
@@ -13,7 +13,6 @@ import useNotifier from "@saleor/hooks/useNotifier";
import usePaginator, {
createPaginationState
} from "@saleor/hooks/usePaginator";
-import useShop from "@saleor/hooks/useShop";
import { commonMessages } from "@saleor/intl";
import { ListViews } from "@saleor/types";
import createDialogActionHandlers from "@saleor/utils/handlers/dialogActionHandlers";
@@ -56,7 +55,6 @@ export const ProductTypeList: React.FC = ({ params }) => {
const navigate = useNavigator();
const notify = useNotifier();
const paginate = usePaginator();
- const shop = useShop();
const { isSelected, listElements, reset, toggle, toggleAll } = useBulkActions(
params.ids
);
@@ -149,7 +147,6 @@ export const ProductTypeList: React.FC = ({ params }) => {
};
const handleSort = createSortHandler(navigate, productTypeListUrl, params);
- const currencySymbol = maybe(() => shop.defaultCurrency, "USD");
return (
= ({ params }) => {
return (
<>
void;
fetchProductTypes: (data: string) => void;
onWarehouseConfigure: () => void;
+ openChannelsModal: () => void;
+ onChannelsChange: (data: ChannelData[]) => void;
onBack?();
onSubmit?(data: ProductCreateData);
}
export const ProductCreatePage: React.FC = ({
- currency,
+ allChannelsCount,
+ channelsErrors,
+ currentChannels,
disabled,
categories: categoryChoiceList,
collections: collectionChoiceList,
@@ -80,10 +87,11 @@ export const ProductCreatePage: React.FC = ({
fetchProductTypes,
weightUnit,
onSubmit,
- onWarehouseConfigure
+ onChannelsChange,
+ onWarehouseConfigure,
+ openChannelsModal
}: ProductCreatePageProps) => {
const intl = useIntl();
- const localizeDate = useDateLocalize();
// Display values
const [selectedCategory, setSelectedCategory] = useStateFromProps(
@@ -118,10 +126,20 @@ export const ProductCreatePage: React.FC = ({
setSelectedCategory={setSelectedCategory}
setSelectedCollections={setSelectedCollections}
setSelectedTaxType={setSelectedTaxType}
+ setChannels={onChannelsChange}
taxTypes={taxTypeChoices}
warehouses={warehouses}
+ currentChannels={currentChannels}
+ productTypeChoiceList={productTypeChoiceList}
>
- {({ change, data, handlers, hasChanged, submit }) => {
+ {({
+ change,
+ data,
+ disabled: formDisabled,
+ handlers,
+ hasChanged,
+ submit
+ }) => {
// Comparing explicitly to false because `hasVariants` can be undefined
const isSimpleProduct = data.productType?.hasVariants === false;
@@ -161,12 +179,11 @@ export const ProductCreatePage: React.FC = ({
onChange={change}
/>
-
= ({
/>
= ({
onCancel={onBack}
onSave={submit}
state={saveButtonBarState}
- disabled={disabled || !onSubmit || !hasChanged}
+ disabled={disabled || !onSubmit || formDisabled || !hasChanged}
/>
);
diff --git a/src/products/components/ProductCreatePage/form.tsx b/src/products/components/ProductCreatePage/form.tsx
index f24971dbf..e803671ae 100644
--- a/src/products/components/ProductCreatePage/form.tsx
+++ b/src/products/components/ProductCreatePage/form.tsx
@@ -1,4 +1,5 @@
import { OutputData } from "@editorjs/editorjs";
+import { ChannelData, ChannelPriceArgs } from "@saleor/channels/utils";
import { MetadataFormData } from "@saleor/components/Metadata";
import { MultiAutocompleteChoiceType } from "@saleor/components/MultiAutocompleteSelectField";
import { RichTextEditorChange } from "@saleor/components/RichTextEditor";
@@ -13,8 +14,15 @@ import {
import {
createAttributeChangeHandler,
createAttributeMultiChangeHandler,
+ createChannelsChangeHandler,
+ createChannelsPriceChangeHandler,
createProductTypeSelectHandler
} from "@saleor/products/utils/handlers";
+import {
+ validateCostPrice,
+ validatePrice
+} from "@saleor/products/utils/validation";
+import { SearchProductTypes_search_edges_node } from "@saleor/searches/types/SearchProductTypes";
import { SearchWarehouses_search_edges_node } from "@saleor/searches/types/SearchWarehouses";
import createMultiAutocompleteSelectHandler from "@saleor/utils/handlers/multiAutocompleteSelectChangeHandler";
import createSingleAutocompleteSelectHandler from "@saleor/utils/handlers/singleAutocompleteSelectChangeHandler";
@@ -22,7 +30,6 @@ import useMetadataChangeTrigger from "@saleor/utils/metadata/useMetadataChangeTr
import useRichText from "@saleor/utils/richText/useRichText";
import React from "react";
-import { SearchProductTypes_search_edges_node } from "../../../searches/types/SearchProductTypes";
import {
ProductAttributeInput,
ProductAttributeInputData
@@ -30,19 +37,16 @@ import {
import { ProductStockInput } from "../ProductStocks";
export interface ProductCreateFormData extends MetadataFormData {
- availableForPurchase: string;
basePrice: number;
category: string;
changeTaxCode: boolean;
+ channelListings: ChannelData[];
chargeTaxes: boolean;
collections: string[];
description: OutputData;
isAvailable: boolean;
- isAvailableForPurchase: boolean;
- isPublished: boolean;
name: string;
productType: ProductType;
- publicationDate: string;
seoDescription: string;
seoTitle: string;
sku: string;
@@ -50,7 +54,6 @@ export interface ProductCreateFormData extends MetadataFormData {
stockQuantity: number;
taxCode: string;
trackInventory: boolean;
- visibleInListings: boolean;
weight: string;
}
export interface ProductCreateData extends ProductCreateFormData {
@@ -71,12 +74,21 @@ interface ProductCreateHandlers
"changeStock" | "selectAttribute" | "selectAttributeMultiple",
FormsetChange
>,
+ Record<"changeChannelPrice", (id: string, data: ChannelPriceArgs) => void>,
+ Record<
+ "changeChannels",
+ (
+ id: string,
+ data: Omit
+ ) => void
+ >,
Record<"addStock" | "deleteStock", (id: string) => void> {
changeDescription: RichTextEditorChange;
}
export interface UseProductCreateFormResult {
change: FormChange;
data: ProductCreateData;
+ disabled: boolean;
handlers: ProductCreateHandlers;
hasChanged: boolean;
submit: () => Promise;
@@ -92,9 +104,12 @@ export interface UseProductCreateFormOpts
React.SetStateAction
>;
setSelectedTaxType: React.Dispatch>;
+ setChannels: (channels: ChannelData[]) => void;
selectedCollections: MultiAutocompleteChoiceType[];
productTypes: SearchProductTypes_search_edges_node[];
warehouses: SearchWarehouses_search_edges_node[];
+ currentChannels: ChannelData[];
+ productTypeChoiceList: SearchProductTypes_search_edges_node[];
}
export interface ProductCreateFormProps extends UseProductCreateFormOpts {
@@ -103,39 +118,35 @@ export interface ProductCreateFormProps extends UseProductCreateFormOpts {
onSubmit: (data: ProductCreateData) => Promise;
}
-const defaultInitialFormData: ProductCreateFormData &
- Record<"productType", string> = {
- availableForPurchase: "",
- basePrice: 0,
- category: "",
- changeTaxCode: false,
- chargeTaxes: false,
- collections: [],
- description: null,
- isAvailable: false,
- isAvailableForPurchase: false,
- isPublished: false,
- metadata: [],
- name: "",
- privateMetadata: [],
- productType: null,
- publicationDate: "",
- seoDescription: "",
- seoTitle: "",
- sku: "",
- slug: "",
- stockQuantity: null,
- taxCode: null,
- trackInventory: false,
- visibleInListings: false,
- weight: ""
-};
-
function useProductCreateForm(
initial: Partial,
onSubmit: (data: ProductCreateData) => Promise,
opts: UseProductCreateFormOpts
): UseProductCreateFormResult {
+ const defaultInitialFormData: ProductCreateFormData &
+ Record<"productType", string> = {
+ basePrice: 0,
+ category: "",
+ changeTaxCode: false,
+ channelListings: opts.currentChannels,
+ chargeTaxes: false,
+ collections: [],
+ description: null,
+ isAvailable: false,
+ metadata: [],
+ name: "",
+ privateMetadata: [],
+ productType: null,
+ seoDescription: "",
+ seoTitle: "",
+ sku: "",
+ slug: "",
+ stockQuantity: null,
+ taxCode: null,
+ trackInventory: false,
+ weight: ""
+ };
+
const initialProductType =
opts.productTypes?.find(
productType => initial?.productType?.id === productType.id
@@ -219,6 +230,16 @@ function useProductCreateForm(
opts.taxTypes
);
const changeMetadata = makeMetadataChangeHandler(handleChange);
+ const handleChannelsChange = createChannelsChangeHandler(
+ opts.currentChannels,
+ opts.setChannels,
+ triggerChange
+ );
+ const handleChannelPriceChange = createChannelsPriceChangeHandler(
+ opts.currentChannels,
+ opts.setChannels,
+ triggerChange
+ );
const getData = (): ProductCreateData => ({
...form.data,
@@ -227,13 +248,29 @@ function useProductCreateForm(
productType,
stocks: stocks.data
});
- const submit = () => onSubmit(getData());
+ const data = getData();
+ const submit = () => onSubmit(data);
+
+ const productTypeChoice = opts.productTypeChoiceList?.find(
+ choice => choice.id === data.productType?.id
+ );
+
+ const disabled =
+ !productTypeChoice?.hasVariants &&
+ (!data.sku ||
+ data.channelListings.some(
+ channel =>
+ validatePrice(channel.price) || validateCostPrice(channel.costPrice)
+ ));
return {
change: handleChange,
- data: getData(),
+ data,
+ disabled,
handlers: {
addStock: handleStockAdd,
+ changeChannelPrice: handleChannelPriceChange,
+ changeChannels: handleChannelsChange,
changeDescription,
changeMetadata,
changeStock: handleStockChange,
diff --git a/src/products/components/ProductExportDialog/ProductExportDialog.stories.tsx b/src/products/components/ProductExportDialog/ProductExportDialog.stories.tsx
index f81aead66..b1e6f3ca1 100644
--- a/src/products/components/ProductExportDialog/ProductExportDialog.stories.tsx
+++ b/src/products/components/ProductExportDialog/ProductExportDialog.stories.tsx
@@ -1,3 +1,4 @@
+import { channelsList } from "@saleor/channels/fixtures";
import Decorator from "@saleor/storybook/Decorator";
import {
ExportErrorCode,
@@ -18,6 +19,7 @@ const props: ProductExportDialogProps = {
id: attr.id,
name: attr.name
})),
+ channels: channelsList,
confirmButtonState: "default",
errors: [],
hasMore: true,
diff --git a/src/products/components/ProductExportDialog/ProductExportDialog.tsx b/src/products/components/ProductExportDialog/ProductExportDialog.tsx
index 5f9581eeb..d5403ea02 100644
--- a/src/products/components/ProductExportDialog/ProductExportDialog.tsx
+++ b/src/products/components/ProductExportDialog/ProductExportDialog.tsx
@@ -4,6 +4,7 @@ import DialogActions from "@material-ui/core/DialogActions";
import DialogContent from "@material-ui/core/DialogContent";
import DialogTitle from "@material-ui/core/DialogTitle";
import Typography from "@material-ui/core/Typography";
+import { Channels_channels } from "@saleor/channels/types/Channels";
import ConfirmButton, {
ConfirmButtonTransitionState
} from "@saleor/components/ConfirmButton";
@@ -66,6 +67,7 @@ function useSteps(): Array> {
const initialForm: ExportProductsInput = {
exportInfo: {
attributes: [],
+ channels: [],
fields: [],
warehouses: []
},
@@ -77,6 +79,7 @@ const ProductExportSteps = makeCreatorSteps();
export interface ProductExportDialogProps extends DialogProps, FetchMoreProps {
attributes: SearchAttributes_search_edges_node[];
+ channels: Channels_channels[];
confirmButtonState: ConfirmButtonTransitionState;
errors: ExportErrorFragment[];
productQuantity: ProductQuantity;
@@ -88,6 +91,7 @@ export interface ProductExportDialogProps extends DialogProps, FetchMoreProps {
const ProductExportDialog: React.FC = ({
attributes,
+ channels,
confirmButtonState,
errors,
productQuantity,
@@ -109,6 +113,7 @@ const ProductExportDialog: React.FC = ({
const [selectedAttributes, setSelectedAttributes] = React.useState<
MultiAutocompleteChoiceType[]
>([]);
+ const [selectedChannels, setSelectedChannels] = React.useState([]);
const { change, data, reset, submit } = useForm(initialForm, onSubmit);
useModalDialogOpen(open, {
@@ -141,6 +146,45 @@ const ProductExportDialog: React.FC = ({
);
};
+ const handleChannelSelect = (option: Channels_channels) => {
+ change({
+ target: {
+ name: "exportInfo",
+ value: {
+ ...data.exportInfo,
+ channels: toggle(
+ option.id,
+ data.exportInfo.channels,
+ (a, b) => a === b
+ )
+ }
+ }
+ });
+ const choice = channels.find(choice => choice.id === option.id);
+
+ setSelectedChannels(
+ toggle(choice, selectedChannels, (a, b) => a.id === b.id)
+ );
+ };
+
+ const handleToggleAllChannels = (
+ items: Channels_channels[],
+ selected: number
+ ) => {
+ setSelectedChannels(selected === items.length ? [] : channels);
+
+ change({
+ target: {
+ name: "exportInfo",
+ value: {
+ ...data.exportInfo,
+ channels:
+ selected === items.length ? [] : channels.map(channel => channel.id)
+ }
+ }
+ });
+ };
+
const handleWarehouseSelect: FormChange = event =>
change({
target: {
@@ -188,12 +232,16 @@ const ProductExportDialog: React.FC = ({
{step === ProductExportStep.INFO && (
diff --git a/src/products/components/ProductExportDialog/ProductExportDialogInfo.tsx b/src/products/components/ProductExportDialog/ProductExportDialogInfo.tsx
index 14535ad01..e317938bf 100644
--- a/src/products/components/ProductExportDialog/ProductExportDialogInfo.tsx
+++ b/src/products/components/ProductExportDialog/ProductExportDialogInfo.tsx
@@ -4,7 +4,9 @@ import FormControlLabel from "@material-ui/core/FormControlLabel";
import makeStyles from "@material-ui/core/styles/makeStyles";
import TextField from "@material-ui/core/TextField";
import Typography from "@material-ui/core/Typography";
+import { Channels_channels } from "@saleor/channels/types/Channels";
import Accordion, { AccordionProps } from "@saleor/components/Accordion";
+import ChannelsAvailabilityContent from "@saleor/components/ChannelsAvailabilityContent";
import Checkbox from "@saleor/components/Checkbox";
import Chip from "@saleor/components/Chip";
import Hr from "@saleor/components/Hr";
@@ -83,6 +85,7 @@ const useStyles = makeStyles(
marginBottom: theme.spacing()
},
optionLabel: {
+ fontSize: 14,
marginLeft: 0
},
quickPeekContainer: {
@@ -204,6 +207,8 @@ const FieldAccordion: React.FC void;
onSelectAllWarehouses: FormChange;
+ onSelectAllChannels: (items: Channels_channels[], selected: number) => void;
+ onChannelSelect: (option: Channels_channels) => void;
}
const ProductExportDialogInfo: React.FC = ({
attributes,
+ channels,
data,
hasMore,
selectedAttributes,
+ selectedChannels,
loading,
warehouses,
onAttrtibuteSelect,
onWarehouseSelect,
+ onChannelSelect,
onChange,
onFetch,
onFetchMore,
+ onSelectAllChannels,
onSelectAllWarehouses
}) => {
const classes = useStyles({});
@@ -280,6 +291,50 @@ const ProductExportDialogInfo: React.FC = ({
description="select product informations to be exported"
/>
+ 0 && (
+
+ {selectedChannels.slice(0, maxChips).map(channel => (
+ onChannelSelect(channel)}
+ key={channel.id}
+ />
+ ))}
+ {selectedChannels.length > maxChips && (
+
+
+
+ )}
+
+ )
+ }
+ data-test="channels"
+ >
+
+ !!selectedChannels.find(channel => channel.id === option.id)
+ }
+ onChange={onChannelSelect}
+ toggleAll={onSelectAllChannels}
+ />
+
= ({
description: "informations about product prices etc, header"
})}
data={data}
- fields={[
- ProductFieldEnum.CHARGE_TAXES,
- ProductFieldEnum.COST_PRICE,
- ProductFieldEnum.VARIANT_PRICE,
- ProductFieldEnum.VISIBLE,
- ProductFieldEnum.AVAILABLE_FOR_PURCHASE
- ]}
+ fields={[ProductFieldEnum.CHARGE_TAXES]}
onChange={handleFieldChange}
onToggleAll={handleToggleAllFields}
data-test="financial"
diff --git a/src/products/components/ProductExportDialog/messages.ts b/src/products/components/ProductExportDialog/messages.ts
index 3ec171775..e5dd38442 100644
--- a/src/products/components/ProductExportDialog/messages.ts
+++ b/src/products/components/ProductExportDialog/messages.ts
@@ -20,11 +20,6 @@ function useProductExportFieldMessages() {
description: "product field",
id: "productExportFieldCollections"
}),
- [ProductFieldEnum.COST_PRICE]: intl.formatMessage({
- defaultMessage: "Cost Price",
- description: "product field",
- id: "productExportFieldPrice"
- }),
[ProductFieldEnum.DESCRIPTION]: intl.formatMessage({
defaultMessage: "Description",
description: "product field",
@@ -55,11 +50,6 @@ function useProductExportFieldMessages() {
description: "product field",
id: "productExportFieldVariantImages"
}),
- [ProductFieldEnum.VARIANT_PRICE]: intl.formatMessage({
- defaultMessage: "Variant Price",
- description: "product field",
- id: "productExportFieldVariantPrice"
- }),
[ProductFieldEnum.VARIANT_SKU]: intl.formatMessage({
defaultMessage: "Export Variant SKU",
description: "product field",
@@ -74,11 +64,6 @@ function useProductExportFieldMessages() {
defaultMessage: "Visibility",
description: "product field",
id: "productExportFieldVisibility"
- }),
- [ProductFieldEnum.AVAILABLE_FOR_PURCHASE]: intl.formatMessage({
- defaultMessage: "Available for purchase",
- description: "product field",
- id: "productExportFieldAvailability"
})
};
diff --git a/src/products/components/ProductList/ProductList.tsx b/src/products/components/ProductList/ProductList.tsx
index 22113f45f..df16d6f8a 100644
--- a/src/products/components/ProductList/ProductList.tsx
+++ b/src/products/components/ProductList/ProductList.tsx
@@ -4,11 +4,11 @@ import TableCell from "@material-ui/core/TableCell";
import TableFooter from "@material-ui/core/TableFooter";
import TableRow from "@material-ui/core/TableRow";
import Typography from "@material-ui/core/Typography";
+import { ChannelsAvailabilityDropdown } from "@saleor/components/ChannelsAvailabilityDropdown";
import Checkbox from "@saleor/components/Checkbox";
import Money from "@saleor/components/Money";
import ResponsiveTable from "@saleor/components/ResponsiveTable";
import Skeleton from "@saleor/components/Skeleton";
-import StatusLabel from "@saleor/components/StatusLabel";
import TableCellAvatar, {
AVATAR_MARGIN
} from "@saleor/components/TableCellAvatar";
@@ -31,7 +31,7 @@ import TDisplayColumn, {
import { getArrowDirection } from "@saleor/utils/sort";
import classNames from "classnames";
import React from "react";
-import { FormattedMessage, useIntl } from "react-intl";
+import { FormattedMessage } from "react-intl";
const useStyles = makeStyles(
theme => ({
@@ -104,11 +104,14 @@ interface ProductListProps
gridAttributes: GridAttributes_grid_edges_node[];
products: ProductList_products_edges_node[];
loading: boolean;
+ selectedChannel: string;
+ channelsCount: number;
}
export const ProductList: React.FC = props => {
const {
activeAttributeSortId,
+ channelsCount,
settings,
disabled,
isChecked,
@@ -116,7 +119,6 @@ export const ProductList: React.FC = props => {
pageInfo,
products,
selected,
- loading,
sort,
toggle,
toggleAll,
@@ -125,62 +127,16 @@ export const ProductList: React.FC = props => {
onPreviousPage,
onUpdateListSettings,
onRowClick,
- onSort
+ onSort,
+ selectedChannel
} = props;
const classes = useStyles(props);
- const intl = useIntl();
-
const gridAttributesFromSettings = settings.columns.filter(
isAttributeColumnValue
);
const numberOfColumns = 2 + settings.columns.length;
- const getProductPrice = product => {
- const priceRangeUndiscounted = product?.pricing?.priceRangeUndiscounted;
-
- if (!priceRangeUndiscounted) {
- return "-";
- }
-
- const { start, stop } = priceRangeUndiscounted;
- const {
- gross: { amount: startAmount }
- } = start;
- const {
- gross: { amount: stopAmount }
- } = stop;
-
- if (startAmount === stopAmount) {
- return (
-
- );
- } else {
- return (
- <>
-
- {" - "}
-
- >
- );
- }
- };
-
return (
@@ -190,7 +146,10 @@ export const ProductList: React.FC = props => {
-
+
{gridAttributesFromSettings.map(gridAttribute => (
@@ -240,7 +199,10 @@ export const ProductList: React.FC = props => {
/>
-
+
= props => {
onClick={() => onSort(ProductListUrlSortField.status)}
>
@@ -323,6 +285,9 @@ export const ProductList: React.FC = props => {
products,
product => {
const isSelected = product ? isChecked(product.id) : false;
+ const channel = product?.channelListings.find(
+ listing => listing.channel.id === selectedChannel
+ );
return (
= props => {
onClick={product && onRowClick(product.id)}
className={classes.link}
data-test="id"
- data-test-id={maybe(() => product.id)}
+ data-test-id={product?.id}
>
= props => {
className={classes.colType}
data-test="product-type"
>
- {product && product.productType ? (
- product.productType.name
- ) : (
-
- )}
+ {product?.productType?.name || }
product.isPublished)}
+ data-test="availability"
+ data-test-availability={
+ !!product?.channelListings?.length
+ }
>
- {product &&
- maybe(() => product.isPublished !== undefined) ? (
-
) : (
@@ -444,7 +401,11 @@ export const ProductList: React.FC = props => {
displayColumns={settings.columns}
>
- {loading ? : getProductPrice(product)}
+ {product?.channelListings ? (
+
+ ) : (
+
+ )}
diff --git a/src/products/components/ProductListPage/ProductListPage.tsx b/src/products/components/ProductListPage/ProductListPage.tsx
index 892ddeceb..f4923e9a8 100644
--- a/src/products/components/ProductListPage/ProductListPage.tsx
+++ b/src/products/components/ProductListPage/ProductListPage.tsx
@@ -41,17 +41,23 @@ export interface ProductListPageProps
SortPage {
activeAttributeSortId: string;
availableInGridAttributes: GridAttributes_availableInGrid_edges_node[];
+ channelsCount: number;
currencySymbol: string;
gridAttributes: GridAttributes_grid_edges_node[];
totalGridAttributes: number;
products: ProductList_products_edges_node[];
onExport: () => void;
+ selectedChannel: string;
+ onSettingsOpen?: () => void;
}
const useStyles = makeStyles(
theme => ({
columnPicker: {
- margin: theme.spacing(0, 3)
+ marginRight: theme.spacing(3)
+ },
+ settings: {
+ marginRight: theme.spacing(2)
}
}),
{ name: "ProductListPage" }
@@ -59,6 +65,7 @@ const useStyles = makeStyles(
export const ProductListPage: React.FC = props => {
const {
+ channelsCount,
currencySymbol,
currentTab,
defaultSettings,
@@ -77,10 +84,12 @@ export const ProductListPage: React.FC = props => {
onFetchMore,
onFilterChange,
onSearchChange,
+ onSettingsOpen,
onTabChange,
onTabDelete,
onTabSave,
onUpdateListSettings,
+ selectedChannel,
...listProps
} = props;
const intl = useIntl();
@@ -92,13 +101,6 @@ export const ProductListPage: React.FC = props => {
const filterStructure = createFilterStructure(intl, filterOpts);
const columns: ColumnPickerChoice[] = [
- {
- label: intl.formatMessage({
- defaultMessage: "Published",
- description: "product status"
- }),
- value: "isPublished" as ProductListColumns
- },
{
label: intl.formatMessage({
defaultMessage: "Price",
@@ -123,6 +125,7 @@ export const ProductListPage: React.FC = props => {
= props => {
}),
onSelect: onExport,
testId: "export"
+ },
+ onSettingsOpen && {
+ label: intl.formatMessage({
+ defaultMessage: "Settings",
+ description: "button"
+ }),
+ onSelect: onSettingsOpen
}
]}
data-test="menu"
@@ -188,6 +198,8 @@ export const ProductListPage: React.FC = props => {
loading={loading}
gridAttributes={gridAttributes}
settings={settings}
+ channelsCount={channelsCount}
+ selectedChannel={selectedChannel}
onUpdateListSettings={onUpdateListSettings}
/>
diff --git a/src/products/components/ProductListPage/filters.ts b/src/products/components/ProductListPage/filters.ts
index 50683be68..fb12b6695 100644
--- a/src/products/components/ProductListPage/filters.ts
+++ b/src/products/components/ProductListPage/filters.ts
@@ -14,7 +14,6 @@ export enum ProductFilterKeys {
attributes = "attributes",
categories = "categories",
collections = "collections",
- status = "status",
price = "price",
productType = "productType",
stock = "stock"
@@ -32,15 +31,9 @@ export interface ProductListFilterOpts {
collections: FilterOpts & AutocompleteFilterOpts;
price: FilterOpts;
productType: FilterOpts & AutocompleteFilterOpts;
- status: FilterOpts;
stockStatus: FilterOpts;
}
-export enum ProductStatus {
- PUBLISHED = "published",
- HIDDEN = "hidden"
-}
-
const messages = defineMessages({
available: {
defaultMessage: "Available",
@@ -76,25 +69,6 @@ export function createFilterStructure(
opts: ProductListFilterOpts
): IFilter {
return [
- {
- ...createOptionsField(
- ProductFilterKeys.status,
- intl.formatMessage(messages.visibility),
- [opts.status.value],
- false,
- [
- {
- label: intl.formatMessage(messages.visible),
- value: ProductStatus.PUBLISHED
- },
- {
- label: intl.formatMessage(messages.hidden),
- value: ProductStatus.HIDDEN
- }
- ]
- ),
- active: opts.status.active
- },
{
...createOptionsField(
ProductFilterKeys.stock,
diff --git a/src/products/components/ProductPricing/ProductPricing.tsx b/src/products/components/ProductPricing/ProductPricing.tsx
deleted file mode 100644
index fb036ba90..000000000
--- a/src/products/components/ProductPricing/ProductPricing.tsx
+++ /dev/null
@@ -1,72 +0,0 @@
-import Card from "@material-ui/core/Card";
-import CardContent from "@material-ui/core/CardContent";
-import { makeStyles } from "@material-ui/core/styles";
-import CardTitle from "@saleor/components/CardTitle";
-import PriceField from "@saleor/components/PriceField";
-import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment";
-import { getFormErrors, getProductErrorMessage } from "@saleor/utils/errors";
-import createNonNegativeValueChangeHandler from "@saleor/utils/handlers/nonNegativeValueChangeHandler";
-import React from "react";
-import { useIntl } from "react-intl";
-
-const useStyles = makeStyles(
- theme => ({
- root: {
- display: "grid",
- gridColumnGap: theme.spacing(2),
- gridTemplateColumns: "1fr 1fr"
- }
- }),
- { name: "ProductPricing" }
-);
-
-interface ProductPricingProps {
- currency?: string;
- data: {
- basePrice: number;
- };
- disabled: boolean;
- errors: ProductErrorFragment[];
- onChange: (event: React.ChangeEvent) => void;
-}
-
-const ProductPricing: React.FC = props => {
- const { currency, data, disabled, errors, onChange } = props;
-
- const classes = useStyles(props);
- const intl = useIntl();
-
- const formErrors = getFormErrors(["basePrice"], errors);
-
- const handlePriceChange = createNonNegativeValueChangeHandler(onChange);
-
- return (
-
-
-
-
-
-
- );
-};
-ProductPricing.displayName = "ProductPricing";
-export default ProductPricing;
diff --git a/src/products/components/ProductPricing/index.ts b/src/products/components/ProductPricing/index.ts
deleted file mode 100644
index 4a41ac8e5..000000000
--- a/src/products/components/ProductPricing/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export { default } from "./ProductPricing";
-export * from "./ProductPricing";
diff --git a/src/products/components/ProductStocks/ProductStocks.tsx b/src/products/components/ProductStocks/ProductStocks.tsx
index 4484b6840..121f80afc 100644
--- a/src/products/components/ProductStocks/ProductStocks.tsx
+++ b/src/products/components/ProductStocks/ProductStocks.tsx
@@ -153,6 +153,7 @@ const ProductStocks: React.FC = ({
defaultMessage: "SKU (Stock Keeping Unit)"
})}
name="sku"
+ required
onChange={onFormDataChange}
value={data.sku}
/>
diff --git a/src/products/components/ProductUpdatePage/ProductUpdatePage.test.tsx b/src/products/components/ProductUpdatePage/ProductUpdatePage.test.tsx
index 96854aaee..8592de84a 100644
--- a/src/products/components/ProductUpdatePage/ProductUpdatePage.test.tsx
+++ b/src/products/components/ProductUpdatePage/ProductUpdatePage.test.tsx
@@ -1,4 +1,6 @@
import placeholderImage from "@assets/images/placeholder255x255.png";
+import { channelsList } from "@saleor/channels/fixtures";
+import { createChannelsData } from "@saleor/channels/utils";
import { collections } from "@saleor/collections/fixtures";
import { fetchMoreProps, listActionsProps } from "@saleor/fixtures";
import { product as productFixture } from "@saleor/products/fixtures";
@@ -11,6 +13,12 @@ import React from "react";
import ProductUpdatePage, { ProductUpdatePageProps } from "./ProductUpdatePage";
const product = productFixture(placeholderImage);
+const channels = createChannelsData(channelsList);
+const channelChoices = product.channelListings.map(listing => ({
+ label: listing.channel.name,
+ value: listing.channel.id
+}));
+
import Adapter from "enzyme-adapter-react-16";
configure({ adapter: new Adapter() });
@@ -18,8 +26,12 @@ const onSubmit = jest.fn();
const props: ProductUpdatePageProps = {
...listActionsProps,
+ allChannelsCount: 5,
categories: [product.category],
+ channelChoices,
+ channelsErrors: [],
collections,
+ currentChannels: channels,
defaultWeightUnit: "kg",
disabled: false,
errors: [],
@@ -27,9 +39,11 @@ const props: ProductUpdatePageProps = {
fetchCollections: () => undefined,
fetchMoreCategories: fetchMoreProps,
fetchMoreCollections: fetchMoreProps,
+ hasChannelChanged: false,
header: product.name,
images: product.images,
onBack: () => undefined,
+ onChannelsChange: () => undefined,
onDelete: () => undefined,
onImageDelete: () => undefined,
onImageUpload: () => undefined,
@@ -40,6 +54,7 @@ const props: ProductUpdatePageProps = {
onVariantShow: () => undefined,
onVariantsAdd: () => undefined,
onWarehouseConfigure: () => undefined,
+ openChannelsModal: () => undefined,
placeholderImage,
product,
saveButtonBarState: "default",
diff --git a/src/products/components/ProductUpdatePage/ProductUpdatePage.tsx b/src/products/components/ProductUpdatePage/ProductUpdatePage.tsx
index 4d51ad9cd..6d27bb746 100644
--- a/src/products/components/ProductUpdatePage/ProductUpdatePage.tsx
+++ b/src/products/components/ProductUpdatePage/ProductUpdatePage.tsx
@@ -1,6 +1,7 @@
import { OutputData } from "@editorjs/editorjs";
+import { ChannelData } from "@saleor/channels/utils";
import AppHeader from "@saleor/components/AppHeader";
-import AvailabilityCard from "@saleor/components/AvailabilityCard";
+import { AvailabilityCard } from "@saleor/components/AvailabilityCard";
import CardSpacer from "@saleor/components/CardSpacer";
import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton";
import Container from "@saleor/components/Container";
@@ -9,14 +10,16 @@ import Metadata from "@saleor/components/Metadata/Metadata";
import PageHeader from "@saleor/components/PageHeader";
import SaveButtonBar from "@saleor/components/SaveButtonBar";
import SeoForm from "@saleor/components/SeoForm";
+import { SingleAutocompleteChoiceType } from "@saleor/components/SingleAutocompleteSelectField";
+import { ProductChannelListingErrorFragment } from "@saleor/fragments/types/ProductChannelListingErrorFragment";
import { ProductErrorWithAttributesFragment } from "@saleor/fragments/types/ProductErrorWithAttributesFragment";
import { TaxTypeFragment } from "@saleor/fragments/types/TaxTypeFragment";
import { WarehouseFragment } from "@saleor/fragments/types/WarehouseFragment";
-import useDateLocalize from "@saleor/hooks/useDateLocalize";
import { SubmitPromise } from "@saleor/hooks/useForm";
import useStateFromProps from "@saleor/hooks/useStateFromProps";
import { sectionNames } from "@saleor/intl";
import { maybe } from "@saleor/misc";
+import ProductVariantPrice from "@saleor/products/components/ProductVariantPrice";
import { SearchCategories_search_edges_node } from "@saleor/searches/types/SearchCategories";
import { SearchCollections_search_edges_node } from "@saleor/searches/types/SearchCollections";
import { FetchMoreProps, ListActions, ReorderAction } from "@saleor/types";
@@ -33,7 +36,6 @@ import ProductAttributes, { ProductAttributeInput } from "../ProductAttributes";
import ProductDetailsForm from "../ProductDetailsForm";
import ProductImages from "../ProductImages";
import ProductOrganization from "../ProductOrganization";
-import ProductPricing from "../ProductPricing";
import ProductShipping from "../ProductShipping/ProductShipping";
import ProductStocks, { ProductStockInput } from "../ProductStocks";
import ProductTaxes from "../ProductTaxes";
@@ -43,6 +45,10 @@ import ProductUpdateForm from "./form";
export interface ProductUpdatePageProps extends ListActions {
defaultWeightUnit: string;
errors: ProductErrorWithAttributesFragment[];
+ channelsErrors: ProductChannelListingErrorFragment[];
+ allChannelsCount: number;
+ currentChannels: ChannelData[];
+ channelChoices: SingleAutocompleteChoiceType[];
placeholderImage: string;
collections: SearchCollections_search_edges_node[];
categories: SearchCategories_search_edges_node[];
@@ -51,6 +57,7 @@ export interface ProductUpdatePageProps extends ListActions {
fetchMoreCollections: FetchMoreProps;
variants: ProductDetails_product_variants[];
images: ProductDetails_product_images[];
+ hasChannelChanged: boolean;
product: ProductDetails_product;
header: string;
saveButtonBarState: ConfirmButtonTransitionState;
@@ -63,6 +70,8 @@ export interface ProductUpdatePageProps extends ListActions {
onVariantReorder: ReorderAction;
onImageDelete: (id: string) => () => void;
onSubmit: (data: ProductUpdatePageSubmitData) => SubmitPromise;
+ openChannelsModal: () => void;
+ onChannelsChange: (data: ChannelData[]) => void;
onBack?();
onDelete();
onImageEdit?(id: string);
@@ -87,6 +96,10 @@ export const ProductUpdatePage: React.FC = ({
defaultWeightUnit,
disabled,
categories: categoryChoiceList,
+ channelChoices,
+ channelsErrors,
+ allChannelsCount,
+ currentChannels = [],
collections: collectionChoiceList,
errors,
fetchCategories,
@@ -94,6 +107,7 @@ export const ProductUpdatePage: React.FC = ({
fetchMoreCategories,
fetchMoreCollections,
images,
+ hasChannelChanged,
header,
placeholderImage,
product,
@@ -107,6 +121,8 @@ export const ProductUpdatePage: React.FC = ({
onImageEdit,
onImageReorder,
onImageUpload,
+ onChannelsChange,
+ openChannelsModal,
onSeoClick,
onSubmit,
onVariantAdd,
@@ -122,7 +138,6 @@ export const ProductUpdatePage: React.FC = ({
toolbar
}) => {
const intl = useIntl();
- const localizeDate = useDateLocalize();
const [selectedCategory, setSelectedCategory] = useStateFromProps(
product?.category?.name || ""
@@ -138,7 +153,6 @@ export const ProductUpdatePage: React.FC = ({
const categories = getChoices(categoryChoiceList);
const collections = getChoices(collectionChoiceList);
- const currency = product?.variants[0]?.price.currency;
const hasVariants = product?.productType?.hasVariants;
const taxTypeChoices =
taxTypes?.map(taxType => ({
@@ -156,10 +170,20 @@ export const ProductUpdatePage: React.FC = ({
setSelectedCategory={setSelectedCategory}
setSelectedCollections={setSelectedCollections}
setSelectedTaxType={setSelectedTaxType}
+ setChannels={onChannelsChange}
taxTypes={taxTypeChoices}
warehouses={warehouses}
+ currentChannels={currentChannels}
+ hasVariants={hasVariants}
>
- {({ change, data, handlers, hasChanged, submit }) => (
+ {({
+ change,
+ data,
+ disabled: formDisabled,
+ handlers,
+ hasChanged,
+ submit
+ }) => (
<>
@@ -197,12 +221,11 @@ export const ProductUpdatePage: React.FC = ({
{!!product?.productType && !hasVariants && (
<>
-
>
@@ -212,11 +235,7 @@ export const ProductUpdatePage: React.FC = ({
disabled={disabled}
variants={variants}
product={product}
- fallbackPrice={
- product?.variants?.length
- ? product.variants[0].price
- : undefined
- }
+ channelChoices={channelChoices}
onRowClick={onVariantShow}
onVariantAdd={onVariantAdd}
onVariantsAdd={onVariantsAdd}
@@ -293,29 +312,24 @@ export const ProductUpdatePage: React.FC = ({
/>
= ({
onDelete={onDelete}
onSave={submit}
state={saveButtonBarState}
- disabled={disabled || !hasChanged}
+ disabled={
+ disabled || formDisabled || (!hasChanged && !hasChannelChanged)
+ }
/>
>
diff --git a/src/products/components/ProductUpdatePage/form.tsx b/src/products/components/ProductUpdatePage/form.tsx
index 21e59cd0e..c83e17b4f 100644
--- a/src/products/components/ProductUpdatePage/form.tsx
+++ b/src/products/components/ProductUpdatePage/form.tsx
@@ -1,4 +1,5 @@
import { OutputData } from "@editorjs/editorjs";
+import { ChannelData, ChannelPriceArgs } from "@saleor/channels/utils";
import { MetadataFormData } from "@saleor/components/Metadata";
import { MultiAutocompleteChoiceType } from "@saleor/components/MultiAutocompleteSelectField";
import { RichTextEditorChange } from "@saleor/components/RichTextEditor";
@@ -16,8 +17,14 @@ import {
} from "@saleor/products/utils/data";
import {
createAttributeChangeHandler,
- createAttributeMultiChangeHandler
+ createAttributeMultiChangeHandler,
+ createChannelsChangeHandler,
+ createChannelsPriceChangeHandler
} from "@saleor/products/utils/handlers";
+import {
+ validateCostPrice,
+ validatePrice
+} from "@saleor/products/utils/validation";
import { SearchWarehouses_search_edges_node } from "@saleor/searches/types/SearchWarehouses";
import handleFormSubmit from "@saleor/utils/handlers/handleFormSubmit";
import createMultiAutocompleteSelectHandler from "@saleor/utils/handlers/multiAutocompleteSelectChangeHandler";
@@ -32,24 +39,20 @@ import { ProductAttributeInput } from "../ProductAttributes";
import { ProductStockInput } from "../ProductStocks";
export interface ProductUpdateFormData extends MetadataFormData {
- availableForPurchase: string;
basePrice: number;
category: string | null;
changeTaxCode: boolean;
+ channelListings: ChannelData[];
chargeTaxes: boolean;
collections: string[];
isAvailable: boolean;
- isAvailableForPurchase: boolean;
- isPublished: boolean;
name: string;
slug: string;
- publicationDate: string;
seoDescription: string;
seoTitle: string;
sku: string;
taxCode: string;
trackInventory: boolean;
- visibleInListings: boolean;
weight: string;
}
export interface ProductUpdateData extends ProductUpdateFormData {
@@ -78,6 +81,14 @@ interface ProductUpdateHandlers
"changeStock" | "selectAttribute" | "selectAttributeMultiple",
FormsetChange
>,
+ Record<"changeChannelPrice", (id: string, data: ChannelPriceArgs) => void>,
+ Record<
+ "changeChannels",
+ (
+ id: string,
+ data: Omit
+ ) => void
+ >,
Record<"addStock" | "deleteStock", (id: string) => void> {
changeDescription: RichTextEditorChange;
}
@@ -85,6 +96,7 @@ export interface UseProductUpdateFormResult {
change: FormChange;
data: ProductUpdateData;
+ disabled: boolean;
handlers: ProductUpdateHandlers;
hasChanged: boolean;
submit: () => Promise;
@@ -100,8 +112,11 @@ export interface UseProductUpdateFormOpts
React.SetStateAction
>;
setSelectedTaxType: React.Dispatch>;
+ setChannels: (channels: ChannelData[]) => void;
selectedCollections: MultiAutocompleteChoiceType[];
warehouses: SearchWarehouses_search_edges_node[];
+ currentChannels: ChannelData[];
+ hasVariants: boolean;
}
export interface ProductUpdateFormProps extends UseProductUpdateFormOpts {
@@ -110,16 +125,6 @@ export interface ProductUpdateFormProps extends UseProductUpdateFormOpts {
onSubmit: (data: ProductUpdateSubmitData) => SubmitPromise;
}
-const getAvailabilityData = ({
- availableForPurchase,
- isAvailableForPurchase,
- isPublished,
- publicationDate
-}: ProductUpdateFormData) => ({
- isAvailableForPurchase: isAvailableForPurchase || !!availableForPurchase,
- isPublished: isPublished || !!publicationDate
-});
-
const getStocksData = (
product: ProductDetails_product,
stocks: FormsetData
@@ -153,7 +158,11 @@ function useProductUpdateForm(
const triggerChange = () => setChanged(true);
const form = useForm(
- getProductUpdatePageFormData(product, product?.variants)
+ getProductUpdatePageFormData(
+ product,
+ product?.variants,
+ opts.currentChannels
+ )
);
const attributes = useFormset(getAttributeInputFromProduct(product));
const stocks = useFormset(getStockInputFromProduct(product));
@@ -215,6 +224,16 @@ function useProductUpdateForm(
opts.taxTypes
);
const changeMetadata = makeMetadataChangeHandler(handleChange);
+ const handleChannelsChange = createChannelsChangeHandler(
+ opts.currentChannels,
+ opts.setChannels,
+ triggerChange
+ );
+ const handleChannelPriceChange = createChannelsPriceChangeHandler(
+ opts.currentChannels,
+ opts.setChannels,
+ triggerChange
+ );
const data: ProductUpdateData = {
...form.data,
@@ -225,7 +244,6 @@ function useProductUpdateForm(
// Need to make it function to always have description.current up to date
const getSubmitData = (): ProductUpdateSubmitData => ({
...data,
- ...getAvailabilityData(data),
...getStocksData(product, stocks.data),
...getMetadata(data, isMetadataModified, isPrivateMetadataModified),
addStocks: [],
@@ -235,11 +253,22 @@ function useProductUpdateForm(
const submit = () => handleFormSubmit(getSubmitData(), onSubmit, setChanged);
+ const disabled =
+ !opts.hasVariants &&
+ (!data.sku ||
+ data.channelListings.some(
+ channel =>
+ validatePrice(channel.price) || validateCostPrice(channel.costPrice)
+ ));
+
return {
change: handleChange,
data,
+ disabled,
handlers: {
addStock: handleStockAdd,
+ changeChannelPrice: handleChannelPriceChange,
+ changeChannels: handleChannelsChange,
changeDescription,
changeMetadata,
changeStock: handleStockChange,
diff --git a/src/products/components/ProductVariantCreatePage/ProductVariantCreatePage.tsx b/src/products/components/ProductVariantCreatePage/ProductVariantCreatePage.tsx
index cbe8fa284..f8b45c959 100644
--- a/src/products/components/ProductVariantCreatePage/ProductVariantCreatePage.tsx
+++ b/src/products/components/ProductVariantCreatePage/ProductVariantCreatePage.tsx
@@ -1,3 +1,4 @@
+import { ChannelPriceData } from "@saleor/channels/utils";
import AppHeader from "@saleor/components/AppHeader";
import CardSpacer from "@saleor/components/CardSpacer";
import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton";
@@ -6,6 +7,7 @@ import Grid from "@saleor/components/Grid";
import Metadata from "@saleor/components/Metadata";
import PageHeader from "@saleor/components/PageHeader";
import SaveButtonBar from "@saleor/components/SaveButtonBar";
+import { ProductChannelListingErrorFragment } from "@saleor/fragments/types/ProductChannelListingErrorFragment";
import { ProductErrorWithAttributesFragment } from "@saleor/fragments/types/ProductErrorWithAttributesFragment";
import { SearchWarehouses_search_edges_node } from "@saleor/searches/types/SearchWarehouses";
import { ReorderAction } from "@saleor/types";
@@ -21,7 +23,8 @@ import ProductVariantPrice from "../ProductVariantPrice";
import ProductVariantCreateForm, { ProductVariantCreateData } from "./form";
interface ProductVariantCreatePageProps {
- currencySymbol: string;
+ channels: ChannelPriceData[];
+ channelErrors: ProductChannelListingErrorFragment[] | undefined;
disabled: boolean;
errors: ProductErrorWithAttributesFragment[];
header: string;
@@ -37,7 +40,8 @@ interface ProductVariantCreatePageProps {
}
const ProductVariantCreatePage: React.FC = ({
- currencySymbol,
+ channels,
+ channelErrors = [],
disabled,
errors,
header,
@@ -58,8 +62,16 @@ const ProductVariantCreatePage: React.FC = ({
product={product}
onSubmit={onSubmit}
warehouses={warehouses}
+ currentChannels={channels}
>
- {({ change, data, handlers, hasChanged, submit }) => (
+ {({
+ change,
+ data,
+ disabled: formDisabled,
+ handlers,
+ hasChanged,
+ submit
+ }) => (
{product?.name}
@@ -84,14 +96,6 @@ const ProductVariantCreatePage: React.FC = ({
onChange={handlers.selectAttribute}
/>
-
-
= ({
onChange={change}
/>
+ ({
+ ...channel.data,
+ ...channel.value
+ })
+ )}
+ errors={channelErrors}
+ loading={disabled}
+ onChange={handlers.changeChannels}
+ />
+
= ({
;
+ channelListings: FormsetData;
stocks: ProductStockInput[];
}
export interface UseProductVariantCreateFormOpts {
warehouses: SearchWarehouses_search_edges_node[];
+ currentChannels: ChannelPriceData[];
}
export interface UseProductVariantCreateFormResult {
change: FormChange;
data: ProductVariantCreateData;
+ disabled: boolean;
// TODO: type FormsetChange
- handlers: Record<"changeStock" | "selectAttribute", FormsetChange> &
+ handlers: Record<
+ "changeStock" | "selectAttribute" | "changeChannels",
+ FormsetChange
+ > &
Record<"addStock" | "deleteStock", (id: string) => void> & {
changeMetadata: FormChange;
};
@@ -49,9 +59,7 @@ export interface ProductVariantCreateFormProps
}
const initial: ProductVariantCreateFormData = {
- costPrice: "",
metadata: [],
- price: "",
privateMetadata: [],
sku: "",
trackInventory: true,
@@ -67,10 +75,12 @@ function useProductVariantCreateForm(
const triggerChange = () => setChanged(true);
const attributeInput = getVariantAttributeInputFromProduct(product);
+ const channelsInput = getChannelsInput(opts.currentChannels);
const form = useForm(initial);
const attributes = useFormset(attributeInput);
const stocks = useFormset([]);
+ const channels = useFormset(channelsInput);
const {
makeChangeHandler: makeMetadataChangeHandler
} = useMetadataChangeTrigger();
@@ -101,10 +111,21 @@ function useProductVariantCreateForm(
triggerChange();
stocks.remove(id);
};
+ const handleChannelChange: FormsetChange = (id, value) => {
+ channels.change(id, value);
+ triggerChange();
+ };
+
+ const disabled = channels?.data.some(
+ channelData =>
+ validatePrice(channelData.value.price) ||
+ validateCostPrice(channelData.value.costPrice)
+ );
const data: ProductVariantCreateData = {
...form.data,
attributes: attributes.data,
+ channelListings: channels.data,
stocks: stocks.data
};
@@ -113,8 +134,10 @@ function useProductVariantCreateForm(
return {
change: handleChange,
data,
+ disabled,
handlers: {
addStock: handleStockAdd,
+ changeChannels: handleChannelChange,
changeMetadata,
changeStock: handleStockChange,
deleteStock: handleStockDelete,
diff --git a/src/products/components/ProductVariantCreatorPage/ProductVariantCreator.stories.tsx b/src/products/components/ProductVariantCreatorPage/ProductVariantCreator.stories.tsx
index 806d3bb75..ac44f9042 100644
--- a/src/products/components/ProductVariantCreatorPage/ProductVariantCreator.stories.tsx
+++ b/src/products/components/ProductVariantCreatorPage/ProductVariantCreator.stories.tsx
@@ -1,4 +1,5 @@
import { attributes } from "@saleor/attributes/fixtures";
+import { productChannels } from "@saleor/channels/fixtures";
import Container from "@saleor/components/Container";
import { ProductVariantBulkCreate_productVariantBulkCreate_errors } from "@saleor/products/types/ProductVariantBulkCreate";
import { ProductErrorCode } from "@saleor/types/globalTypes";
@@ -8,7 +9,12 @@ import React from "react";
import Decorator from "../../../storybook/Decorator";
import { createVariants } from "./createVariants";
-import { AllOrAttribute, ProductVariantCreateFormData } from "./form";
+import {
+ ChannelPrice,
+ Price,
+ ProductVariantCreateFormData,
+ Stock
+} from "./form";
import ProductVariantCreatorContent, {
ProductVariantCreatorContentProps
} from "./ProductVariantCreatorContent";
@@ -18,17 +24,22 @@ import { ProductVariantCreatorStep } from "./types";
const selectedAttributes = [1, 4, 5].map(index => attributes[index]);
const selectedWarehouses = [0, 1, 3].map(index => warehouseList[index]);
-const price: AllOrAttribute = {
+const channels: ChannelPrice[] = productChannels.map(channel => ({
+ channelId: channel.channel.id,
+ price: channel.discountedPrice.amount.toString()
+}));
+
+const price: Price = {
attribute: selectedAttributes[0].id,
+ channels,
mode: "attribute",
- value: "2.79",
- values: selectedAttributes[0].values.map((attribute, attributeIndex) => ({
+ values: selectedAttributes[0].values.map(attribute => ({
slug: attribute.slug,
- value: (attributeIndex + 4).toFixed(2)
+ value: channels
}))
};
-const stock: AllOrAttribute = {
+const stock: Stock = {
attribute: selectedAttributes[0].id,
mode: "attribute",
value: selectedWarehouses.map(
@@ -53,6 +64,7 @@ const dataAttributes = selectedAttributes.map(attribute => ({
const errors: ProductVariantBulkCreate_productVariantBulkCreate_errors[] = [
{
__typename: "BulkProductError",
+ channels: [channels[0].channelId],
code: ProductErrorCode.UNIQUE,
field: "sku",
index: 3
@@ -74,7 +86,12 @@ const data: ProductVariantCreateFormData = {
};
const props: ProductVariantCreatorContentProps = {
attributes: [0, 1, 4, 6].map(index => attributes[index]),
- currencySymbol: "USD",
+ channelListings: productChannels.map(listing => ({
+ currency: listing.discountedPrice.currency,
+ id: listing.channel.id,
+ name: listing.channel.name,
+ price: listing.discountedPrice?.amount.toString() || ""
+ })),
data: {
...data,
variants: createVariants(data)
@@ -173,9 +190,5 @@ storiesOf("Views / Products / Create multiple variants / summary", module)
storiesOf("Views / Products / Create multiple variants", module)
.addDecorator(Decorator)
.add("interactive", () => (
- undefined}
- />
+ undefined} />
));
diff --git a/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorContent.tsx b/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorContent.tsx
index 9919e5a3f..07ea7a8b4 100644
--- a/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorContent.tsx
+++ b/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorContent.tsx
@@ -1,3 +1,4 @@
+import { ChannelPriceData } from "@saleor/channels/utils";
import { WarehouseFragment } from "@saleor/fragments/types/WarehouseFragment";
import { ProductDetails_product_productType_variantAttributes } from "@saleor/products/types/ProductDetails";
import { ProductVariantBulkCreate_productVariantBulkCreate_errors } from "@saleor/products/types/ProductVariantBulkCreate";
@@ -16,7 +17,7 @@ import { ProductVariantCreatorStep } from "./types";
export interface ProductVariantCreatorContentProps {
attributes: ProductDetails_product_productType_variantAttributes[];
- currencySymbol: string;
+ channelListings: ChannelPriceData[];
data: ProductVariantCreateFormData;
dispatchFormDataAction: React.Dispatch;
errors: ProductVariantBulkCreate_productVariantBulkCreate_errors[];
@@ -26,7 +27,7 @@ export interface ProductVariantCreatorContentProps {
const ProductVariantCreatorContent: React.FC = ({
attributes,
- currencySymbol,
+ channelListings,
data,
dispatchFormDataAction,
errors,
@@ -61,8 +62,8 @@ const ProductVariantCreatorContent: React.FC
{step === ProductVariantCreatorStep.prices && (
dispatchFormDataAction({
@@ -75,9 +76,10 @@ const ProductVariantCreatorContent: React.FC
: ProductVariantCreateReducerActionType.applyStockToAll
})
}
- onApplyToAllPriceChange={price =>
+ onApplyToAllPriceChange={(channelId, price) =>
dispatchFormDataAction({
changeApplyPriceToAllValue: {
+ channelId,
price
},
type:
@@ -105,9 +107,10 @@ const ProductVariantCreatorContent: React.FC
: ProductVariantCreateReducerActionType.changeApplyStockToAttributeId
})
}
- onAttributePriceChange={(valueId, price) =>
+ onAttributePriceChange={(valueId, price, channelId) =>
dispatchFormDataAction({
changeAttributeValuePrice: {
+ channelId,
price,
valueId
},
@@ -139,17 +142,25 @@ const ProductVariantCreatorContent: React.FC
{step === ProductVariantCreatorStep.summary && (
+ onVariantSkuChange={(variantIndex, value) =>
dispatchFormDataAction({
- changeVariantData: {
- field,
+ changeVariantSku: {
value,
variantIndex
},
- type: ProductVariantCreateReducerActionType.changeVariantData
+ type: ProductVariantCreateReducerActionType.changeVariantSku
+ })
+ }
+ onVariantPriceDataChange={(variantIndex, value) =>
+ dispatchFormDataAction({
+ changeVariantPriceData: {
+ value,
+ variantIndex
+ },
+ type: ProductVariantCreateReducerActionType.changeVariantPriceData
})
}
onVariantStockDataChange={(variantIndex, warehouse, value) =>
diff --git a/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorPage.tsx b/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorPage.tsx
index 011e60b86..7d98048cc 100644
--- a/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorPage.tsx
+++ b/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorPage.tsx
@@ -5,6 +5,7 @@ import Container from "@saleor/components/Container";
import Hr from "@saleor/components/Hr";
import PageHeader from "@saleor/components/PageHeader";
import useWizard from "@saleor/hooks/useWizard";
+import { validatePrice } from "@saleor/products/utils/validation";
import React from "react";
import { FormattedMessage, IntlShape, useIntl } from "react-intl";
@@ -48,13 +49,17 @@ function canHitNext(
return data.attributes.every(attribute => attribute.values.length > 0);
case ProductVariantCreatorStep.prices:
if (data.price.mode === "all") {
- if (data.price.value === "") {
+ if (data.price.channels.some(channel => validatePrice(channel.price))) {
return false;
}
} else if (data.price.mode === "attribute") {
if (
- data.price.attribute === "" ||
- data.price.values.some(attributeValue => attributeValue.value === "")
+ !data.price.attribute ||
+ data.price.values.some(
+ attribute =>
+ attribute.value.length < data.price.channels.length ||
+ attribute.value.some(channel => validatePrice(channel.price))
+ )
) {
return false;
}
@@ -66,7 +71,11 @@ function canHitNext(
return true;
case ProductVariantCreatorStep.summary:
- return data.variants.every(variant => variant.sku !== "");
+ return !data.variants.some(
+ variant =>
+ variant.sku === "" ||
+ variant.channelListings.some(channel => validatePrice(channel.price))
+ );
default:
return false;
@@ -78,7 +87,6 @@ export interface ProductVariantCreatePageProps
ProductVariantCreatorContentProps,
"data" | "dispatchFormDataAction" | "step" | "onStepClick"
> {
- defaultPrice: string;
onSubmit: (data: ProductVariantBulkCreateInput[]) => void;
}
@@ -128,7 +136,7 @@ function getDescription(
const ProductVariantCreatePage: React.FC = props => {
const {
attributes,
- defaultPrice,
+ channelListings,
errors,
onSubmit,
warehouses,
@@ -138,7 +146,7 @@ const ProductVariantCreatePage: React.FC = props
const intl = useIntl();
const [wizardData, dispatchFormDataAction] = React.useReducer(
reduceProductVariantCreateFormData,
- createInitialForm(attributes, defaultPrice, warehouses)
+ createInitialForm(attributes, channelListings, warehouses)
);
const [step, { next: nextStep, prev: prevStep, set: setStep }] = useWizard<
ProductVariantCreatorStep
@@ -162,7 +170,7 @@ const ProductVariantCreatePage: React.FC = props
const reloadForm = () =>
dispatchFormDataAction({
reload: {
- data: createInitialForm(attributes, defaultPrice, warehouses)
+ data: createInitialForm(attributes, channelListings, warehouses)
},
type: ProductVariantCreateReducerActionType.reload
});
@@ -219,6 +227,7 @@ const ProductVariantCreatePage: React.FC = props
void;
- onApplyToAllPriceChange: (value: string) => void;
+ onApplyToAllPriceChange: (channelId: string, value: string) => void;
onApplyToAllStockChange: (quantity: number, warehouseIndex: number) => void;
onAttributeSelect: (id: string, type: PriceOrStock) => void;
- onAttributePriceChange: (id: string, value: string) => void;
+ onAttributePriceChange: (
+ id: string,
+ value: string,
+ channelId: string
+ ) => void;
onAttributeStockChange: (
id: string,
quantity: number,
@@ -34,7 +39,7 @@ export interface ProductVariantCreatorPriceAndSkuProps {
const ProductVariantCreatorPriceAndSku: React.FC = ({
attributes,
- currencySymbol,
+ channelListings,
data,
warehouses,
onApplyToAllChange,
@@ -48,7 +53,7 @@ const ProductVariantCreatorPriceAndSku: React.FC
onApplyToAllChange(value, "price")}
onApplyToAllPriceChange={onApplyToAllPriceChange}
diff --git a/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorPrices.tsx b/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorPrices.tsx
index 31100a0cb..f3dd26612 100644
--- a/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorPrices.tsx
+++ b/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorPrices.tsx
@@ -4,12 +4,13 @@ import FormControlLabel from "@material-ui/core/FormControlLabel";
import Radio from "@material-ui/core/Radio";
import RadioGroup from "@material-ui/core/RadioGroup";
import { makeStyles } from "@material-ui/core/styles";
-import TextField from "@material-ui/core/TextField";
import Typography from "@material-ui/core/Typography";
+import { ChannelPriceData } from "@saleor/channels/utils";
import CardTitle from "@saleor/components/CardTitle";
import FormSpacer from "@saleor/components/FormSpacer";
import Grid from "@saleor/components/Grid";
import Hr from "@saleor/components/Hr";
+import PriceField from "@saleor/components/PriceField";
import SingleSelectField from "@saleor/components/SingleSelectField";
import { ProductDetails_product_productType_variantAttributes } from "@saleor/products/types/ProductDetails";
import React from "react";
@@ -23,6 +24,18 @@ import { getPriceAttributeValues } from "./utils";
const useStyles = makeStyles(
theme => ({
+ attrInputsContainer: {
+ display: "grid",
+ gap: theme.spacing(2) + "px",
+ gridTemplateColumns:
+ "minmax(80px, 150px) repeat(auto-fit, minmax(150px, 250px))"
+ },
+ channelName: {
+ marginBottom: theme.spacing(1)
+ },
+ container: {
+ display: "block"
+ },
hr: {
marginBottom: theme.spacing(),
marginTop: theme.spacing(0.5)
@@ -30,11 +43,13 @@ const useStyles = makeStyles(
hrAttribute: {
marginTop: theme.spacing(2)
},
+ inputsContainer: {
+ display: "grid",
+ gap: theme.spacing(2) + "px",
+ gridTemplateColumns: "repeat(auto-fit, minmax(150px, 250px))"
+ },
label: {
alignSelf: "center"
- },
- shortInput: {
- width: "33%"
}
}),
{ name: "ProductVariantCreatorPrices" }
@@ -42,18 +57,22 @@ const useStyles = makeStyles(
export interface ProductVariantCreatorPricesProps {
attributes: ProductDetails_product_productType_variantAttributes[];
- currencySymbol: string;
+ channelListings: ChannelPriceData[];
data: ProductVariantCreateFormData;
onApplyToAllChange: (applyToAll: VariantCreatorPricesAndSkuMode) => void;
- onApplyToAllPriceChange: (value: string) => void;
+ onApplyToAllPriceChange: (channelId: string, value: string) => void;
onAttributeSelect: (id: string) => void;
- onAttributeValueChange: (id: string, value: string) => void;
+ onAttributeValueChange: (
+ id: string,
+ value: string,
+ channelId: string
+ ) => void;
}
const ProductVariantCreatorPrices: React.FC = props => {
const {
attributes,
- currencySymbol,
+ channelListings,
data,
onApplyToAllChange,
onApplyToAllPriceChange,
@@ -78,7 +97,7 @@ const ProductVariantCreatorPrices: React.FC =
})}
/>
-
+
}
@@ -87,23 +106,40 @@ const ProductVariantCreatorPrices: React.FC =
})}
onChange={() => onApplyToAllChange("all")}
/>
-
- onApplyToAllPriceChange(event.target.value)}
- />
+ {data.price.mode === "all" && (
+ <>
+
+
+ {channelListings?.map(listing => (
+
+
+ {listing.name}
+
+ channel.channelId === listing.id
+ )?.price
+ }
+ label={intl.formatMessage({
+ defaultMessage: "Price",
+ description: "input label",
+ id: "productVariantCreatePricesSetPricePlaceholder"
+ })}
+ currencySymbol={listing.currency}
+ onChange={event =>
+ onApplyToAllPriceChange(listing.id, event.target.value)
+ }
+ />
+
+ ))}
+
+ >
+ )}
=
})}
onChange={() => onApplyToAllChange("attribute")}
/>
-
- {data.price.mode === "attribute" && (
- <>
-
-
-
-
-
+
+
+
+
+
+
+
+
+ onAttributeSelect(event.target.value)}
/>
-
-
-
- onAttributeSelect(event.target.value)}
- />
-
-
- {priceAttributeValues &&
- priceAttributeValues.map(attributeValue => (
-
-
-
-
-
- {attributeValue.name}
-
-
- value.slug === attributeValue.slug
- ).value
- }
- onChange={event =>
- onAttributeValueChange(
- attributeValue.slug,
- event.target.value
- )
- }
- />
-
-
-
- ))}
- >
- )}
+
+
+ {priceAttributeValues &&
+ priceAttributeValues.map(attributeValue => {
+ const attributesChannels = data.price.values.find(
+ value => value.slug === attributeValue.slug
+ ).value;
+ return (
+
+
+
+
+
+ {attributeValue.name}
+
+ {channelListings?.map(listing => (
+
+
+ {listing.name}
+
+
+ attrChannel.channelId === listing.id
+ )?.price || ""
+ }
+ onChange={event =>
+ onAttributeValueChange(
+ attributeValue.slug,
+ event.target.value,
+ listing.id
+ )
+ }
+ />
+
+ ))}
+
+
+ );
+ })}
+ >
+ )}
+
+ }
+ label={intl.formatMessage({
+ defaultMessage: "Skip pricing for now"
+ })}
+ onChange={() => onApplyToAllChange("skip")}
+ />
+
);
diff --git a/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorSummary.tsx b/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorSummary.tsx
index 904a2e181..4630da88f 100644
--- a/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorSummary.tsx
+++ b/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorSummary.tsx
@@ -8,8 +8,10 @@ import IconButton from "@material-ui/core/IconButton";
import { makeStyles, Theme } from "@material-ui/core/styles";
import TextField from "@material-ui/core/TextField";
import DeleteIcon from "@material-ui/icons/Delete";
+import { ChannelPriceData } from "@saleor/channels/utils";
import CardTitle from "@saleor/components/CardTitle";
import Hr from "@saleor/components/Hr";
+import PriceField from "@saleor/components/PriceField";
import { WarehouseFragment } from "@saleor/fragments/types/WarehouseFragment";
import { ProductVariantBulkCreate_productVariantBulkCreate_errors } from "@saleor/products/types/ProductVariantBulkCreate";
import { ProductVariantBulkCreateInput } from "@saleor/types/globalTypes";
@@ -20,26 +22,22 @@ import React from "react";
import { FormattedMessage, useIntl } from "react-intl";
import { ProductDetails_product_productType_variantAttributes } from "../../types/ProductDetails";
-import { ProductVariantCreateFormData } from "./form";
-import { VariantField } from "./reducer";
+import { ChannelPrice, ProductVariantCreateFormData } from "./form";
export interface ProductVariantCreatorSummaryProps {
attributes: ProductDetails_product_productType_variantAttributes[];
- currencySymbol: string;
+ channelListings: ChannelPriceData[];
data: ProductVariantCreateFormData;
errors: ProductVariantBulkCreate_productVariantBulkCreate_errors[];
warehouses: WarehouseFragment[];
- onVariantDataChange: (
- variantIndex: number,
- field: VariantField,
- value: string
- ) => void;
+ onVariantSkuChange: (variantIndex: number, value: string) => void;
onVariantStockDataChange: (
variantIndex: number,
warehouseId: string,
value: string
) => void;
onVariantDelete: (variantIndex: number) => void;
+ onVariantPriceDataChange: (variantIndex: number, value: ChannelPrice) => void;
}
type ClassKey =
| "attributeValue"
@@ -92,7 +90,10 @@ const useStyles = makeStyles<
marginTop: theme.spacing(0.5)
},
hr: {
- gridColumn: props => `span ${4 + props.data.variants[0].stocks.length}`
+ gridColumn: props =>
+ `span ${4 +
+ props.data.variants[0].stocks.length +
+ props.data.variants[0].channelListings.length}`
},
input: {
"& input": {
@@ -103,7 +104,10 @@ const useStyles = makeStyles<
columnGap: theme.spacing(3),
display: "grid",
gridTemplateColumns: props =>
- `minmax(240px, auto) 170px repeat(${props.data.variants[0].stocks.length}, 140px) 140px 64px`,
+ `minmax(180px, auto) repeat(${props.data.variants[0].channelListings
+ .length +
+ props.data.variants[0].stocks
+ .length}, minmax(180px, auto)) 140px 64px`,
overflowX: "scroll",
rowGap: theme.spacing() + "px"
}
@@ -135,11 +139,12 @@ function getVariantName(
const ProductVariantCreatorSummary: React.FC = props => {
const {
attributes,
- currencySymbol,
+ channelListings,
data,
errors,
warehouses,
- onVariantDataChange,
+ onVariantPriceDataChange,
+ onVariantSkuChange,
onVariantDelete,
onVariantStockDataChange
} = props;
@@ -167,18 +172,26 @@ const ProductVariantCreatorSummary: React.FC
description="variant name"
/>
-
-
-
+
+ {channelListings.map(listing => (
+
+
+
+ ))}
+
{data.warehouses.map(warehouseId => (
["price", "quantity", "sku"],
variantErrors
);
-
return (
)
)}
-
-
- onVariantDataChange(
- variantIndex,
- "price",
- event.target.value
- )
- }
- />
-
+ {channelListings.map(listing => {
+ const error = variantFormErrors.price?.channels?.find(
+ id => id === listing.id
+ );
+ return (
+
+ channel.channelId === listing.id
+ )?.price
+ }
+ required
+ onChange={event =>
+ onVariantPriceDataChange(variantIndex, {
+ channelId: listing.id,
+ price: event.target.value
+ })
+ }
+ />
+
+ );
+ })}
{variant.stocks.map(stock => (
fullWidth
value={variant.sku}
onChange={event =>
- onVariantDataChange(variantIndex, "sku", event.target.value)
+ onVariantSkuChange(variantIndex, event.target.value)
}
/>
diff --git a/src/products/components/ProductVariantCreatorPage/__snapshots__/reducer.test.ts.snap b/src/products/components/ProductVariantCreatorPage/__snapshots__/reducer.test.ts.snap
index 23447aca2..1609ff601 100644
--- a/src/products/components/ProductVariantCreatorPage/__snapshots__/reducer.test.ts.snap
+++ b/src/products/components/ProductVariantCreatorPage/__snapshots__/reducer.test.ts.snap
@@ -27,16 +27,55 @@ Object {
],
"price": Object {
"attribute": "attr-2",
+ "channels": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "0",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "2",
+ },
+ ],
"mode": "attribute",
- "value": "",
"values": Array [
Object {
"slug": "val-2-2",
- "value": "24.99",
+ "value": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "0",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "2",
+ },
+ ],
},
Object {
"slug": "val-2-4",
- "value": "26.99",
+ "value": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "0",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "2",
+ },
+ ],
},
],
},
@@ -87,7 +126,20 @@ Object {
],
},
],
- "price": "24.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "0",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "2",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -129,7 +181,20 @@ Object {
],
},
],
- "price": "24.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "0",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "2",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -171,7 +236,20 @@ Object {
],
},
],
- "price": "26.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "0",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "2",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -213,7 +291,20 @@ Object {
],
},
],
- "price": "49.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "7",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "2",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -255,7 +346,20 @@ Object {
],
},
],
- "price": "24.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "0",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "2",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -297,7 +401,20 @@ Object {
],
},
],
- "price": "24.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "0",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "2",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -339,7 +456,20 @@ Object {
],
},
],
- "price": "26.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "0",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "2",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -381,7 +511,20 @@ Object {
],
},
],
- "price": "26.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "0",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "2",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -439,16 +582,55 @@ Object {
],
"price": Object {
"attribute": "attr-2",
+ "channels": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "0",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "2",
+ },
+ ],
"mode": "attribute",
- "value": "",
"values": Array [
Object {
"slug": "val-2-2",
- "value": "24.99",
+ "value": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "0",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "2",
+ },
+ ],
},
Object {
"slug": "val-2-4",
- "value": "26.99",
+ "value": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "0",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "2",
+ },
+ ],
},
],
},
@@ -499,7 +681,20 @@ Object {
],
},
],
- "price": "24.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "0",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "2",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -541,7 +736,20 @@ Object {
],
},
],
- "price": "24.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "0",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "2",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -583,7 +791,20 @@ Object {
],
},
],
- "price": "26.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "0",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "2",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -625,7 +846,20 @@ Object {
],
},
],
- "price": "26.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "0",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "2",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -667,7 +901,20 @@ Object {
],
},
],
- "price": "24.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "0",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "2",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -709,7 +956,20 @@ Object {
],
},
],
- "price": "24.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "0",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "2",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -751,7 +1011,20 @@ Object {
],
},
],
- "price": "26.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "0",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "2",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -793,7 +1066,20 @@ Object {
],
},
],
- "price": "26.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "0",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "2",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -851,8 +1137,21 @@ Object {
],
"price": Object {
"attribute": undefined,
+ "channels": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "1",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"mode": "all",
- "value": "10.99",
"values": Array [],
},
"stock": Object {
@@ -893,8 +1192,21 @@ Object {
],
"price": Object {
"attribute": undefined,
+ "channels": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "22.99",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"mode": "all",
- "value": "45.99",
"values": Array [],
},
"stock": Object {
@@ -930,7 +1242,20 @@ Object {
],
},
],
- "price": "45.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "22.99",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -972,7 +1297,20 @@ Object {
],
},
],
- "price": "45.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "22.99",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -1014,7 +1352,20 @@ Object {
],
},
],
- "price": "45.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "22.99",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -1056,7 +1407,20 @@ Object {
],
},
],
- "price": "45.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "22.99",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -1098,7 +1462,20 @@ Object {
],
},
],
- "price": "45.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "22.99",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -1140,7 +1517,20 @@ Object {
],
},
],
- "price": "45.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "22.99",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -1182,7 +1572,20 @@ Object {
],
},
],
- "price": "45.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "22.99",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -1224,7 +1627,20 @@ Object {
],
},
],
- "price": "45.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "22.99",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -1282,16 +1698,39 @@ Object {
],
"price": Object {
"attribute": "attr-1",
+ "channels": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "1",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"mode": "attribute",
- "value": "10.99",
"values": Array [
Object {
"slug": "val-1-1",
- "value": "45.99",
+ "value": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "45.99",
+ },
+ ],
},
Object {
"slug": "val-1-7",
- "value": "51.99",
+ "value": Array [
+ Object {
+ "channelId": "channel-2",
+ "price": "51.99",
+ },
+ ],
},
],
},
@@ -1328,7 +1767,12 @@ Object {
],
},
],
- "price": "45.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "45.99",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -1370,7 +1814,12 @@ Object {
],
},
],
- "price": "45.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "45.99",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -1412,7 +1861,12 @@ Object {
],
},
],
- "price": "45.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "45.99",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -1454,7 +1908,12 @@ Object {
],
},
],
- "price": "45.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "45.99",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -1496,7 +1955,12 @@ Object {
],
},
],
- "price": "51.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-2",
+ "price": "51.99",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -1538,7 +2002,12 @@ Object {
],
},
],
- "price": "51.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-2",
+ "price": "51.99",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -1580,7 +2049,12 @@ Object {
],
},
],
- "price": "51.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-2",
+ "price": "51.99",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -1622,7 +2096,12 @@ Object {
],
},
],
- "price": "51.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-2",
+ "price": "51.99",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -1680,8 +2159,21 @@ Object {
],
"price": Object {
"attribute": undefined,
+ "channels": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "1",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"mode": "all",
- "value": "10.99",
"values": Array [],
},
"stock": Object {
@@ -1717,7 +2209,20 @@ Object {
],
},
],
- "price": "10.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "1",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -1759,7 +2264,20 @@ Object {
],
},
],
- "price": "10.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "1",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -1801,7 +2319,20 @@ Object {
],
},
],
- "price": "10.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "1",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -1843,7 +2374,20 @@ Object {
],
},
],
- "price": "10.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "1",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -1885,7 +2429,20 @@ Object {
],
},
],
- "price": "10.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "1",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -1927,7 +2484,20 @@ Object {
],
},
],
- "price": "10.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "1",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -1969,7 +2539,20 @@ Object {
],
},
],
- "price": "10.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "1",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -2011,7 +2594,20 @@ Object {
],
},
],
- "price": "10.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "1",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -2069,8 +2665,21 @@ Object {
],
"price": Object {
"attribute": undefined,
+ "channels": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "1",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"mode": "all",
- "value": "10.99",
"values": Array [],
},
"stock": Object {
@@ -2119,7 +2728,20 @@ Object {
],
},
],
- "price": "10.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "1",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -2149,7 +2771,20 @@ Object {
],
},
],
- "price": "10.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "1",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -2179,7 +2814,20 @@ Object {
],
},
],
- "price": "10.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "1",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -2209,7 +2857,20 @@ Object {
],
},
],
- "price": "10.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "1",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -2239,7 +2900,20 @@ Object {
],
},
],
- "price": "10.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "1",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -2269,7 +2943,20 @@ Object {
],
},
],
- "price": "10.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "1",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -2299,7 +2986,20 @@ Object {
],
},
],
- "price": "10.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "1",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -2329,7 +3029,20 @@ Object {
],
},
],
- "price": "10.99",
+ "channelListings": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "1",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"sku": "",
"stocks": Array [
Object {
@@ -2375,8 +3088,21 @@ Object {
],
"price": Object {
"attribute": undefined,
+ "channels": Array [
+ Object {
+ "channelId": "channel-1",
+ "price": "1",
+ },
+ Object {
+ "channelId": "channel-2",
+ "price": "2",
+ },
+ Object {
+ "channelId": "channel-3",
+ "price": "3",
+ },
+ ],
"mode": "all",
- "value": "10.99",
"values": Array [],
},
"stock": Object {
diff --git a/src/products/components/ProductVariantCreatorPage/createVariants.test.ts b/src/products/components/ProductVariantCreatorPage/createVariants.test.ts
index e0319c1ab..6eed8d71d 100644
--- a/src/products/components/ProductVariantCreatorPage/createVariants.test.ts
+++ b/src/products/components/ProductVariantCreatorPage/createVariants.test.ts
@@ -2,8 +2,8 @@ import {
createVariantFlatMatrixDimension,
createVariants
} from "./createVariants";
-import { attributes, thirdStep } from "./fixtures";
-import { ProductVariantCreateFormData } from "./form";
+import { attributes, channels, thirdStep } from "./fixtures";
+import { ChannelPrice, ProductVariantCreateFormData } from "./form";
describe("Creates variant matrix", () => {
it("with proper size", () => {
@@ -17,15 +17,15 @@ describe("Creates variant matrix", () => {
});
it("with constant price and stock", () => {
- const price = "49.99";
+ const channels: ChannelPrice[] = [{ channelId: "1", price: "2" }];
const stock = [80, 40, 30];
const data: ProductVariantCreateFormData = {
...thirdStep,
price: {
...thirdStep.price,
- mode: "all",
- value: price
+ channels,
+ mode: "all"
},
stock: {
...thirdStep.stock,
@@ -43,7 +43,7 @@ describe("Creates variant matrix", () => {
);
variants.forEach(variant => {
- expect(variant.price).toBe(price);
+ expect(variant.channelListings[0].price).toBe(channels[0].price);
variant.stocks.forEach((_, stockIndex) => {
expect(variant.stocks[stockIndex].quantity).toBe(stock[stockIndex]);
});
@@ -51,7 +51,6 @@ describe("Creates variant matrix", () => {
});
it("with constant stock and attribute dependent price", () => {
- const price = 49.99;
const stock = [80, 40, 30];
const attribute = attributes.find(
attribute => attribute.id === thirdStep.attributes[0].id
@@ -63,9 +62,12 @@ describe("Creates variant matrix", () => {
...thirdStep.price,
attribute: attribute.id,
mode: "attribute",
- values: attribute.values.map((attributeValue, attributeValueIndex) => ({
+ values: attribute.values.map((attributeValue, index) => ({
slug: attributeValue,
- value: (price * (attributeValueIndex + 1)).toString()
+ value: channels.map(channel => ({
+ channelId: channel.id,
+ price: (channel.price + index).toString()
+ }))
}))
},
stock: {
@@ -98,15 +100,17 @@ describe("Creates variant matrix", () => {
).values[0] === attributeValue
)
.forEach(variant => {
- expect(variant.price).toBe(
- (price * (attributeValueIndex + 1)).toString()
- );
+ variant.channelListings.map((channel, index) => {
+ expect(channel.price).toBe(
+ (channels[index].price + attributeValueIndex).toString()
+ );
+ });
});
});
});
it("with constant price and attribute dependent stock", () => {
- const price = "49.99";
+ const price: ChannelPrice[] = [{ channelId: "1", price: "2" }];
const stock = [80, 40, 30];
const attribute = attributes.find(
attribute => attribute.id === thirdStep.attributes[0].id
@@ -116,8 +120,8 @@ describe("Creates variant matrix", () => {
...thirdStep,
price: {
...thirdStep.price,
- mode: "all",
- value: price
+ channels: price,
+ mode: "all"
},
stock: {
...thirdStep.stock,
@@ -141,7 +145,7 @@ describe("Creates variant matrix", () => {
);
variants.forEach(variant => {
- expect(variant.price).toBe(price);
+ expect(variant.channelListings).toBe(price);
});
attribute.values.forEach((attributeValue, attributeValueIndex) => {
@@ -163,7 +167,6 @@ describe("Creates variant matrix", () => {
});
it("with attribute dependent price and stock", () => {
- const price = 49.99;
const stock = [80, 40, 30];
const attribute = attributes.find(
attribute => attribute.id === thirdStep.attributes[0].id
@@ -175,9 +178,12 @@ describe("Creates variant matrix", () => {
...thirdStep.price,
attribute: attribute.id,
mode: "attribute",
- values: attribute.values.map((attributeValue, attributeValueIndex) => ({
+ values: attribute.values.map((attributeValue, index) => ({
slug: attributeValue,
- value: (price * (attributeValueIndex + 1)).toString()
+ value: channels.map(channel => ({
+ channelId: channel.id,
+ price: (channel.price + index).toString()
+ }))
}))
},
stock: {
@@ -210,9 +216,11 @@ describe("Creates variant matrix", () => {
).values[0] === attributeValue
)
.forEach(variant => {
- expect(variant.price).toBe(
- (price * (attributeValueIndex + 1)).toString()
- );
+ variant.channelListings.map((channel, index) => {
+ expect(channel.price).toBe(
+ (channels[index].price + attributeValueIndex).toString()
+ );
+ });
});
});
diff --git a/src/products/components/ProductVariantCreatorPage/createVariants.ts b/src/products/components/ProductVariantCreatorPage/createVariants.ts
index 462be5760..5d51db996 100644
--- a/src/products/components/ProductVariantCreatorPage/createVariants.ts
+++ b/src/products/components/ProductVariantCreatorPage/createVariants.ts
@@ -1,9 +1,11 @@
import { ProductVariantBulkCreateInput } from "@saleor/types/globalTypes";
import {
- AllOrAttribute,
Attribute,
- ProductVariantCreateFormData
+ ChannelPrice,
+ Price,
+ ProductVariantCreateFormData,
+ Stock
} from "./form";
interface CreateVariantAttributeValueInput {
@@ -12,31 +14,66 @@ interface CreateVariantAttributeValueInput {
}
type CreateVariantInput = CreateVariantAttributeValueInput[];
-function getAttributeValuePriceOrStock(
+function findAttribute(
attributes: CreateVariantInput,
- priceOrStock: AllOrAttribute
-): T {
- const attribute = attributes.find(
- attribute => attribute.attributeId === priceOrStock.attribute
+ stockOrPrice: Stock | Price
+) {
+ return attributes.find(
+ attribute => attribute.attributeId === stockOrPrice.attribute
);
+}
- const attributeValue = priceOrStock.values.find(
+function getAttributeValueStock(
+ attributes: CreateVariantInput,
+ stock: Stock
+): number[] {
+ const attribute = findAttribute(attributes, stock);
+
+ const attributeValue = stock.values.find(
attributeValue => attribute.attributeValueSlug === attributeValue.slug
);
return attributeValue.value;
}
-function getValueFromMode(
+function getAttributeValuePrice(
attributes: CreateVariantInput,
- priceOrStock: AllOrAttribute,
- skipValue: T
-): T {
- switch (priceOrStock.mode) {
+ price: Price
+): ChannelPrice[] {
+ const attribute = findAttribute(attributes, price);
+
+ const attributeValue = price.values.find(
+ attributeValue => attribute.attributeValueSlug === attributeValue.slug
+ );
+
+ return attributeValue.value;
+}
+
+function getStockFromMode(
+ attributes: CreateVariantInput,
+ stock: Stock,
+ skipValue: number[]
+): number[] {
+ switch (stock.mode) {
case "all":
- return priceOrStock.value;
+ return stock.value;
case "attribute":
- return getAttributeValuePriceOrStock(attributes, priceOrStock);
+ return getAttributeValueStock(attributes, stock);
+ case "skip":
+ return skipValue;
+ }
+}
+
+function getPriceFromMode(
+ attributes: CreateVariantInput,
+ price: Price,
+ skipValue: ChannelPrice[]
+): ChannelPrice[] {
+ switch (price.mode) {
+ case "all":
+ return price.channels;
+ case "attribute":
+ return getAttributeValuePrice(attributes, price);
case "skip":
return skipValue;
}
@@ -46,8 +83,12 @@ function createVariant(
data: ProductVariantCreateFormData,
attributes: CreateVariantInput
): ProductVariantBulkCreateInput {
- const price = getValueFromMode(attributes, data.price, "0");
- const stocks = getValueFromMode(
+ const price = getPriceFromMode(
+ attributes,
+ data.price,
+ data.price.channels.map(channel => ({ ...channel, price: "" }))
+ );
+ const stocks = getStockFromMode(
attributes,
data.stock,
data.warehouses.map(() => 0)
@@ -58,7 +99,7 @@ function createVariant(
id: attribute.attributeId,
values: [attribute.attributeValueSlug]
})),
- price,
+ channelListings: price,
sku: "",
stocks: stocks.map((quantity, stockIndex) => ({
quantity,
diff --git a/src/products/components/ProductVariantCreatorPage/fixtures.ts b/src/products/components/ProductVariantCreatorPage/fixtures.ts
index c0878f527..8dcde4aa9 100644
--- a/src/products/components/ProductVariantCreatorPage/fixtures.ts
+++ b/src/products/components/ProductVariantCreatorPage/fixtures.ts
@@ -1,12 +1,20 @@
+import { ChannelPriceData } from "@saleor/channels/utils";
import { WarehouseFragment } from "@saleor/fragments/types/WarehouseFragment";
import { createVariants } from "./createVariants";
import {
- AllOrAttribute,
createInitialForm,
- ProductVariantCreateFormData
+ Price,
+ ProductVariantCreateFormData,
+ Stock
} from "./form";
+export const channels: ChannelPriceData[] = [
+ { currency: "USD", id: "channel-1", name: "Channel1", price: "1" },
+ { currency: "USD", id: "channel-2", name: "Channel2", price: "2" },
+ { currency: "USD", id: "channel-3", name: "Channel3", price: "3" }
+];
+
export const attributes = [
{
id: "attr-1",
@@ -58,7 +66,7 @@ export const warehouses: WarehouseFragment[] = [
];
export const secondStep: ProductVariantCreateFormData = {
- ...createInitialForm([], "10.99", warehouses),
+ ...createInitialForm([], channels, warehouses),
attributes: [
{
id: attributes[0].id,
@@ -98,22 +106,34 @@ export const thirdStep: ProductVariantCreateFormData = {
warehouses: warehouses.map(warehouse => warehouse.id)
};
-const price: AllOrAttribute = {
+const price: Price = {
attribute: thirdStep.attributes[1].id,
+ channels: [
+ { channelId: channels[0].id, price: "0" },
+ { channelId: channels[1].id, price: "2" },
+ { channelId: channels[2].id, price: "2" }
+ ],
mode: "attribute",
- value: "",
values: [
{
slug: thirdStep.attributes[1].values[0],
- value: "24.99"
+ value: [
+ { channelId: channels[0].id, price: "0" },
+ { channelId: channels[1].id, price: "2" },
+ { channelId: channels[2].id, price: "2" }
+ ]
},
{
slug: thirdStep.attributes[1].values[1],
- value: "26.99"
+ value: [
+ { channelId: channels[0].id, price: "0" },
+ { channelId: channels[1].id, price: "2" },
+ { channelId: channels[2].id, price: "2" }
+ ]
}
]
};
-const stock: AllOrAttribute = {
+const stock: Stock = {
attribute: thirdStep.attributes[2].id,
mode: "attribute",
value: [],
diff --git a/src/products/components/ProductVariantCreatorPage/form.ts b/src/products/components/ProductVariantCreatorPage/form.ts
index 1622dd86e..2e3fbf8a5 100644
--- a/src/products/components/ProductVariantCreatorPage/form.ts
+++ b/src/products/components/ProductVariantCreatorPage/form.ts
@@ -1,18 +1,30 @@
+import { ChannelPriceData } from "@saleor/channels/utils";
import { WarehouseFragment } from "@saleor/fragments/types/WarehouseFragment";
import { ProductDetails_product_productType_variantAttributes } from "@saleor/products/types/ProductDetails";
import { ProductVariantBulkCreateInput } from "../../../types/globalTypes";
+export interface ChannelPrice {
+ channelId: string;
+ price: string;
+}
+
export interface AttributeValue {
slug: string;
value: T;
}
export type VariantCreatorPricesAndSkuMode = "all" | "attribute" | "skip";
-export interface AllOrAttribute {
+export interface Price {
mode: VariantCreatorPricesAndSkuMode;
attribute: string;
- value: T;
- values: Array>;
+ channels: ChannelPrice[];
+ values: Array>;
+}
+export interface Stock {
+ mode: VariantCreatorPricesAndSkuMode;
+ attribute: string;
+ value: number[];
+ values: Array>;
}
export interface Attribute {
id: string;
@@ -20,33 +32,40 @@ export interface Attribute {
}
export interface ProductVariantCreateFormData {
attributes: Attribute[];
- price: AllOrAttribute;
- stock: AllOrAttribute;
+ price: Price;
+ stock: Stock;
variants: ProductVariantBulkCreateInput[];
warehouses: string[];
}
export const createInitialForm = (
attributes: ProductDetails_product_productType_variantAttributes[],
- price: string,
+ channels: ChannelPriceData[],
warehouses: WarehouseFragment[]
-): ProductVariantCreateFormData => ({
- attributes: attributes.map(attribute => ({
- id: attribute.id,
- values: []
- })),
- price: {
- attribute: undefined,
- mode: "all",
- value: price || "",
- values: []
- },
- stock: {
- attribute: undefined,
- mode: "all",
- value: warehouses.length === 1 ? [0] : [],
- values: []
- },
- variants: [],
- warehouses: warehouses.length === 1 ? [warehouses[0].id] : []
-});
+): ProductVariantCreateFormData => {
+ const channelListings =
+ channels?.map(channel => ({
+ channelId: channel.id,
+ price: channel.price?.toString() || ""
+ })) || [];
+ return {
+ attributes: attributes.map(attribute => ({
+ id: attribute.id,
+ values: []
+ })),
+ price: {
+ attribute: undefined,
+ channels: channelListings,
+ mode: "all",
+ values: []
+ },
+ stock: {
+ attribute: undefined,
+ mode: "all",
+ value: warehouses.length === 1 ? [0] : [],
+ values: []
+ },
+ variants: [],
+ warehouses: warehouses.length === 1 ? [warehouses[0].id] : []
+ };
+};
diff --git a/src/products/components/ProductVariantCreatorPage/reducer.test.ts b/src/products/components/ProductVariantCreatorPage/reducer.test.ts
index ce6f8debf..42f18d87a 100644
--- a/src/products/components/ProductVariantCreatorPage/reducer.test.ts
+++ b/src/products/components/ProductVariantCreatorPage/reducer.test.ts
@@ -1,14 +1,13 @@
import {
attributes,
+ channels,
fourthStep,
secondStep,
thirdStep,
warehouses
} from "./fixtures";
-import reducer, {
- ProductVariantCreateReducerActionType,
- VariantField
-} from "./reducer";
+import { ChannelPrice } from "./form";
+import reducer, { ProductVariantCreateReducerActionType } from "./reducer";
function execActions(
initialState: TState,
@@ -73,7 +72,7 @@ describe("Reducer is able to", () => {
});
it("select price for all variants", () => {
- const price = "45.99";
+ const price = "22.99";
const state = execActions(thirdStep, reducer, [
{
applyPriceOrStockToAll: {
@@ -83,6 +82,7 @@ describe("Reducer is able to", () => {
},
{
changeApplyPriceToAllValue: {
+ channelId: channels[0].id,
price
},
type: ProductVariantCreateReducerActionType.changeApplyPriceToAllValue
@@ -91,9 +91,8 @@ describe("Reducer is able to", () => {
type: ProductVariantCreateReducerActionType.reload
}
]);
-
expect(state.price.mode).toBe("all");
- expect(state.price.value).toBe(price);
+ expect(state.price.channels[0].price).toBe(price);
expect(state).toMatchSnapshot();
});
@@ -163,6 +162,7 @@ describe("Reducer is able to", () => {
},
{
changeAttributeValuePrice: {
+ channelId: channels[0].id,
price: value.toString(),
valueId: attribute.values[0]
},
@@ -170,6 +170,7 @@ describe("Reducer is able to", () => {
},
{
changeAttributeValuePrice: {
+ channelId: channels[1].id,
price: (value + 6).toString(),
valueId: attribute.values[1]
},
@@ -235,24 +236,24 @@ describe("Reducer is able to", () => {
});
it("modify individual variant price", () => {
- const field: VariantField = "price";
- const value = "49.99";
+ const value: ChannelPrice = { channelId: channels[0].id, price: "7" };
const variantIndex = 3;
const state = execActions(fourthStep, reducer, [
{
- changeVariantData: {
- field,
+ changeVariantPriceData: {
value,
variantIndex
},
- type: ProductVariantCreateReducerActionType.changeVariantData
+ type: ProductVariantCreateReducerActionType.changeVariantPriceData
}
]);
- expect(state.variants[variantIndex].price).toBe(value);
- expect(state.variants[variantIndex - 1].price).toBe(
- fourthStep.variants[variantIndex - 1].price
+ expect(state.variants[variantIndex].channelListings[0].price).toBe(
+ value.price
+ );
+ expect(state.variants[variantIndex - 1].channelListings).toBe(
+ fourthStep.variants[variantIndex - 1].channelListings
);
expect(state).toMatchSnapshot();
});
diff --git a/src/products/components/ProductVariantCreatorPage/reducer.ts b/src/products/components/ProductVariantCreatorPage/reducer.ts
index 5f702218c..bc312763f 100644
--- a/src/products/components/ProductVariantCreatorPage/reducer.ts
+++ b/src/products/components/ProductVariantCreatorPage/reducer.ts
@@ -25,36 +25,40 @@ export enum ProductVariantCreateReducerActionType {
changeApplyStockToAttributeId,
changeAttributeValuePrice,
changeAttributeValueStock,
- changeVariantData,
+ changeVariantSku,
+ changeVariantPriceData,
changeVariantStockData,
changeWarehouses,
deleteVariant,
reload,
selectValue
}
-export type VariantField = "price" | "sku";
export interface ProductVariantCreateReducerAction {
applyPriceOrStockToAll?: {
mode: VariantCreatorPricesAndSkuMode;
};
changeApplyPriceToAllValue?: {
+ channelId: string;
price: string;
};
changeApplyPriceOrStockToAttributeId?: {
attributeId: string;
};
changeApplyStockToAllValue?: Record<"quantity" | "warehouseIndex", number>;
- changeAttributeValuePrice?: Record<"valueId" | "price", string>;
+ changeAttributeValuePrice?: Record<"valueId" | "price" | "channelId", string>;
changeAttributeValueStock?: {
valueId: string;
quantity: number;
warehouseIndex: number;
};
- changeVariantData?: {
- field: VariantField;
+ changeVariantSku?: {
value: string;
variantIndex: number;
};
+ changeVariantPriceData?: {
+ value: { channelId: string; price: string };
+ variantIndex: number;
+ };
changeVariantStockData?: {
stock: StockInput;
variantIndex: number;
@@ -94,7 +98,7 @@ function selectValue(
? toggle(
{
slug: valueSlug,
- value: ""
+ value: []
},
prevState.price.values,
(a, b) => a.slug === b.slug
@@ -156,7 +160,8 @@ function applyStockToAll(
function changeAttributeValuePrice(
state: ProductVariantCreateFormData,
attributeValueSlug: string,
- price: string
+ price: string,
+ channelId: string
): ProductVariantCreateFormData {
const index = state.price.values.findIndex(
value => value.slug === attributeValueSlug
@@ -166,10 +171,15 @@ function changeAttributeValuePrice(
throw new Error(`Value with id ${attributeValueSlug} not found`);
}
+ const channels = state.price.values[index].value;
+ const channelIndex = channels.findIndex(
+ channel => channel.channelId === channelId
+ );
+
const values = updateAtIndex(
{
slug: attributeValueSlug,
- value: price
+ value: updateAtIndex({ channelId, price }, channels, channelIndex)
},
state.price.values,
index
@@ -229,7 +239,7 @@ function changeApplyPriceToAttributeId(
);
const values = attribute.values.map(slug => ({
slug,
- value: ""
+ value: []
}));
return {
@@ -266,13 +276,19 @@ function changeApplyStockToAttributeId(
function changeApplyPriceToAllValue(
state: ProductVariantCreateFormData,
- value: string
+ channelId: string,
+ price: string
): ProductVariantCreateFormData {
+ const prevChannels = [...state.price.channels];
+ const channelIndex = prevChannels?.findIndex(
+ channel => channelId === channel.channelId
+ );
+ prevChannels[channelIndex] = { channelId, price };
return {
...state,
price: {
...state.price,
- value
+ channels: prevChannels
}
};
}
@@ -291,20 +307,15 @@ function changeApplyStockToAllValue(
};
}
-function changeVariantData(
+function changeVariantSku(
state: ProductVariantCreateFormData,
- field: VariantField,
value: string,
variantIndex: number
): ProductVariantCreateFormData {
const variant = {
...state.variants[variantIndex]
};
- if (field === "price") {
- variant.price = value;
- } else if (field === "sku") {
- variant.sku = value;
- }
+ variant.sku = value;
return {
...state,
@@ -332,6 +343,32 @@ function changeVariantStockData(
};
}
+function changeVariantPriceData(
+ state: ProductVariantCreateFormData,
+ value: { channelId: string; price: string },
+ variantIndex: number
+): ProductVariantCreateFormData {
+ const { channelId, price } = value;
+ const variant = {
+ ...state.variants[variantIndex]
+ };
+ const channelIndex = variant.channelListings.findIndex(
+ listing => listing.channelId === channelId
+ );
+ const updatedVariant = {
+ ...variant,
+ channelListings: updateAtIndex(
+ { channelId, price },
+ [...variant.channelListings],
+ channelIndex
+ )
+ };
+ return {
+ ...state,
+ variants: updateAtIndex(updatedVariant, [...state.variants], variantIndex)
+ };
+}
+
function changeWarehouses(
state: ProductVariantCreateFormData,
warehouseId: string
@@ -408,7 +445,8 @@ function reduceProductVariantCreateFormData(
return changeAttributeValuePrice(
prevState,
action.changeAttributeValuePrice.valueId,
- action.changeAttributeValuePrice.price
+ action.changeAttributeValuePrice.price,
+ action.changeAttributeValuePrice.channelId
);
case ProductVariantCreateReducerActionType.changeAttributeValueStock:
return changeAttributeValueStock(
@@ -430,6 +468,7 @@ function reduceProductVariantCreateFormData(
case ProductVariantCreateReducerActionType.changeApplyPriceToAllValue:
return changeApplyPriceToAllValue(
prevState,
+ action.changeApplyPriceToAllValue.channelId,
action.changeApplyPriceToAllValue.price
);
case ProductVariantCreateReducerActionType.changeApplyStockToAllValue:
@@ -438,12 +477,17 @@ function reduceProductVariantCreateFormData(
action.changeApplyStockToAllValue.warehouseIndex,
action.changeApplyStockToAllValue.quantity
);
- case ProductVariantCreateReducerActionType.changeVariantData:
- return changeVariantData(
+ case ProductVariantCreateReducerActionType.changeVariantSku:
+ return changeVariantSku(
prevState,
- action.changeVariantData.field,
- action.changeVariantData.value,
- action.changeVariantData.variantIndex
+ action.changeVariantSku.value,
+ action.changeVariantSku.variantIndex
+ );
+ case ProductVariantCreateReducerActionType.changeVariantPriceData:
+ return changeVariantPriceData(
+ prevState,
+ action.changeVariantPriceData.value,
+ action.changeVariantPriceData.variantIndex
);
case ProductVariantCreateReducerActionType.changeVariantStockData:
return changeVariantStockData(
diff --git a/src/products/components/ProductVariantPage/ProductVariantPage.tsx b/src/products/components/ProductVariantPage/ProductVariantPage.tsx
index 09b9d4497..8fc69efd9 100644
--- a/src/products/components/ProductVariantPage/ProductVariantPage.tsx
+++ b/src/products/components/ProductVariantPage/ProductVariantPage.tsx
@@ -1,48 +1,32 @@
+import { ChannelPriceData } from "@saleor/channels/utils";
import AppHeader from "@saleor/components/AppHeader";
import CardSpacer from "@saleor/components/CardSpacer";
import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton";
import Container from "@saleor/components/Container";
import Grid from "@saleor/components/Grid";
-import { MetadataFormData } from "@saleor/components/Metadata";
import Metadata from "@saleor/components/Metadata/Metadata";
import PageHeader from "@saleor/components/PageHeader";
import SaveButtonBar from "@saleor/components/SaveButtonBar";
+import { ProductChannelListingErrorFragment } from "@saleor/fragments/types/ProductChannelListingErrorFragment";
import { ProductErrorWithAttributesFragment } from "@saleor/fragments/types/ProductErrorWithAttributesFragment";
import { ProductVariant } from "@saleor/fragments/types/ProductVariant";
import { WarehouseFragment } from "@saleor/fragments/types/WarehouseFragment";
-import { FormsetData } from "@saleor/hooks/useFormset";
import { VariantUpdate_productVariantUpdate_errors } from "@saleor/products/types/VariantUpdate";
import { ReorderAction } from "@saleor/types";
import React from "react";
import { maybe } from "../../../misc";
import ProductShipping from "../ProductShipping/ProductShipping";
-import ProductStocks, { ProductStockInput } from "../ProductStocks";
-import ProductVariantAttributes, {
- VariantAttributeInputData
-} from "../ProductVariantAttributes";
+import ProductStocks from "../ProductStocks";
+import ProductVariantAttributes from "../ProductVariantAttributes";
import ProductVariantImages from "../ProductVariantImages";
import ProductVariantImageSelectDialog from "../ProductVariantImageSelectDialog";
import ProductVariantNavigation from "../ProductVariantNavigation";
import ProductVariantPrice from "../ProductVariantPrice";
import ProductVariantSetDefault from "../ProductVariantSetDefault";
-import ProductVariantUpdateForm from "./form";
-
-export interface ProductVariantPageFormData extends MetadataFormData {
- costPrice: string;
- price: string;
- sku: string;
- trackInventory: boolean;
- weight: string;
-}
-
-export interface ProductVariantPageSubmitData
- extends ProductVariantPageFormData {
- attributes: FormsetData;
- addStocks: ProductStockInput[];
- updateStocks: ProductStockInput[];
- removeStocks: string[];
-}
+import ProductVariantUpdateForm, {
+ ProductVariantUpdateSubmitData
+} from "./form";
interface ProductVariantPageProps {
defaultVariantId?: string;
@@ -51,6 +35,8 @@ interface ProductVariantPageProps {
| ProductErrorWithAttributesFragment[]
| VariantUpdate_productVariantUpdate_errors[];
header: string;
+ channels: ChannelPriceData[];
+ channelErrors: ProductChannelListingErrorFragment[];
loading?: boolean;
placeholderImage?: string;
saveButtonBarState: ConfirmButtonTransitionState;
@@ -60,7 +46,7 @@ interface ProductVariantPageProps {
onAdd();
onBack();
onDelete();
- onSubmit(data: ProductVariantPageSubmitData);
+ onSubmit(data: ProductVariantUpdateSubmitData);
onImageSelect(id: string);
onVariantClick(variantId: string);
onSetDefaultVariant();
@@ -68,6 +54,8 @@ interface ProductVariantPageProps {
}
const ProductVariantPage: React.FC = ({
+ channels,
+ channelErrors,
defaultVariantId,
defaultWeightUnit,
errors,
@@ -101,9 +89,7 @@ const ProductVariantPage: React.FC = ({
return (
<>
-
- {maybe(() => variant.product.name)}
-
+ {variant?.product?.name}
{variant?.product?.defaultVariant?.id !== variant?.id && (
= ({
variant={variant}
onSubmit={onSubmit}
warehouses={warehouses}
+ currentChannels={channels}
>
- {({ change, data, handlers, hasChanged, submit }) => (
+ {({
+ change,
+ data,
+ disabled: formDisabled,
+ handlers,
+ hasChanged,
+ submit
+ }) => (
<>
@@ -152,17 +146,15 @@ const ProductVariantPage: React.FC = ({
/>
({
+ ...channel.data,
+ ...channel.value
+ })
+ )}
+ errors={channelErrors}
loading={loading}
- onChange={change}
+ onChange={handlers.changeChannels}
/>
= ({
;
+ channelListings: FormsetData;
stocks: ProductStockInput[];
}
export interface ProductVariantUpdateSubmitData
extends ProductVariantUpdateFormData {
attributes: FormsetData;
addStocks: ProductStockInput[];
+ channelListings: FormsetData;
updateStocks: ProductStockInput[];
removeStocks: string[];
}
export interface UseProductVariantUpdateFormOpts {
warehouses: SearchWarehouses_search_edges_node[];
+ currentChannels: ChannelPriceData[];
}
export interface UseProductVariantUpdateFormResult {
change: FormChange;
data: ProductVariantUpdateData;
- handlers: Record<"changeStock" | "selectAttribute", FormsetChange> &
+ disabled: boolean;
+ handlers: Record<
+ "changeStock" | "selectAttribute" | "changeChannels",
+ FormsetChange
+ > &
Record<"addStock" | "deleteStock", (id: string) => void> & {
changeMetadata: FormChange;
};
@@ -71,11 +82,10 @@ function useProductVariantUpdateForm(
const attributeInput = getAttributeInputFromVariant(variant);
const stockInput = getStockInputFromVariant(variant);
+ const channelsInput = getChannelsInput(opts.currentChannels);
const initial: ProductVariantUpdateFormData = {
- costPrice: variant?.costPrice?.amount.toString() || "",
metadata: variant?.metadata?.map(mapMetadataItemToInput),
- price: variant?.price?.amount.toString() || "",
privateMetadata: variant?.privateMetadata?.map(mapMetadataItemToInput),
sku: variant?.sku || "",
trackInventory: variant?.trackInventory,
@@ -85,6 +95,7 @@ function useProductVariantUpdateForm(
const form = useForm(initial);
const attributes = useFormset(attributeInput);
const stocks = useFormset(stockInput);
+ const channels = useFormset(channelsInput);
const {
isMetadataModified,
isPrivateMetadataModified,
@@ -117,6 +128,10 @@ function useProductVariantUpdateForm(
triggerChange();
stocks.remove(id);
};
+ const handleChannelChange: FormsetChange = (id, value) => {
+ channels.change(id, value);
+ triggerChange();
+ };
const dataStocks = stocks.data.map(stock => stock.id);
const variantStocks = variant?.stocks.map(stock => stock.warehouse.id) || [];
@@ -129,9 +144,15 @@ function useProductVariantUpdateForm(
stock => !stockDiff.added.some(addedStock => addedStock === stock.id)
);
+ const disabled = channels?.data.some(
+ channelData =>
+ validatePrice(channelData.value.price) ||
+ validateCostPrice(channelData.value.costPrice)
+ );
const data: ProductVariantUpdateData = {
...form.data,
attributes: attributes.data,
+ channelListings: channels.data,
stocks: stocks.data
};
const submitData: ProductVariantUpdateSubmitData = {
@@ -139,6 +160,7 @@ function useProductVariantUpdateForm(
...getMetadata(form.data, isMetadataModified, isPrivateMetadataModified),
addStocks,
attributes: attributes.data,
+ channelListings: channels.data,
removeStocks: stockDiff.removed,
updateStocks
};
@@ -148,8 +170,10 @@ function useProductVariantUpdateForm(
return {
change: handleChange,
data,
+ disabled,
handlers: {
addStock: handleStockAdd,
+ changeChannels: handleChannelChange,
changeMetadata,
changeStock: handleStockChange,
deleteStock: handleStockDelete,
diff --git a/src/products/components/ProductVariantPrice/ProductVariantPrice.tsx b/src/products/components/ProductVariantPrice/ProductVariantPrice.tsx
index ff812d36e..2efbb9d60 100644
--- a/src/products/components/ProductVariantPrice/ProductVariantPrice.tsx
+++ b/src/products/components/ProductVariantPrice/ProductVariantPrice.tsx
@@ -1,42 +1,85 @@
+import {
+ TableBody,
+ TableCell,
+ TableHead,
+ TableRow,
+ Typography
+} from "@material-ui/core";
import Card from "@material-ui/core/Card";
import CardContent from "@material-ui/core/CardContent";
import { makeStyles } from "@material-ui/core/styles";
+import { ChannelPriceArgs, ChannelPriceData } from "@saleor/channels/utils";
import CardTitle from "@saleor/components/CardTitle";
import PriceField from "@saleor/components/PriceField";
-import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment";
-import { getFormErrors, getProductErrorMessage } from "@saleor/utils/errors";
-import createNonNegativeValueChangeHandler from "@saleor/utils/handlers/nonNegativeValueChangeHandler";
+import ResponsiveTable from "@saleor/components/ResponsiveTable";
+import Skeleton from "@saleor/components/Skeleton";
+import { ProductChannelListingErrorFragment } from "@saleor/fragments/types/ProductChannelListingErrorFragment";
+import { renderCollection } from "@saleor/misc";
+import {
+ getFormChannelError,
+ getFormChannelErrors
+} from "@saleor/utils/errors";
+import getProductErrorMessage from "@saleor/utils/errors/product";
import React from "react";
-import { useIntl } from "react-intl";
+import { FormattedMessage, useIntl } from "react-intl";
const useStyles = makeStyles(
theme => ({
- grid: {
- display: "grid",
- gridColumnGap: theme.spacing(2),
- gridTemplateColumns: "1fr 1fr"
+ caption: {
+ fontSize: 14,
+ padding: theme.spacing(0, 3, 2, 3)
+ },
+ colName: {
+ fontSize: 14,
+ paddingLeft: 0,
+ width: "auto"
+ },
+ colPrice: {
+ textAlign: "right",
+ verticalAlign: "top",
+ width: 200
+ },
+ colType: {
+ fontSize: 14,
+ textAlign: "right",
+ width: 200
+ },
+ input: {
+ textAlign: "left"
+ },
+ pricingContent: {
+ "&:last-child": {
+ paddingBottom: 0
+ },
+ paddingLeft: 0,
+ paddingRight: 0
+ },
+ table: {
+ tableLayout: "fixed"
}
}),
{ name: "ProductVariantPrice" }
);
interface ProductVariantPriceProps {
- currencySymbol?: string;
- data: Record<"price" | "costPrice", string>;
- errors: ProductErrorFragment[];
+ ProductVariantChannelListings: ChannelPriceData[];
+ errors: ProductChannelListingErrorFragment[];
loading?: boolean;
- onChange(event: any);
+ onChange: (id: string, data: ChannelPriceArgs) => void;
}
-const ProductVariantPrice: React.FC = props => {
- const { currencySymbol, data, errors, loading, onChange } = props;
+const numberOfColumns = 2;
+const ProductVariantPrice: React.FC = props => {
+ const {
+ errors = [],
+ ProductVariantChannelListings,
+ loading,
+ onChange
+ } = props;
const classes = useStyles(props);
const intl = useIntl();
-
- const formErrors = getFormErrors(["price", "costPrice"], errors);
-
- const handlePriceChange = createNonNegativeValueChangeHandler(onChange);
+ const formErrors = getFormChannelErrors(["price", "costPrice"], errors);
return (
@@ -46,54 +89,123 @@ const ProductVariantPrice: React.FC = props => {
description: "product pricing, section header"
})}
/>
-
-
+
+
+ {intl.formatMessage({
+ defaultMessage:
+ "Channels that don’t have assigned prices will use their parent channel to define the price. Price will be converted to channel’s currency",
+ description: "info text"
+ })}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {renderCollection(
+ ProductVariantChannelListings,
+ (listing, index) => {
+ const priceError = getFormChannelError(
+ formErrors.price,
+ listing.id
+ );
+ const costPriceError = getFormChannelError(
+ formErrors.costPrice,
+ listing.id
+ );
+
+ return (
+
+ {listing?.name || }
+
+ {listing ? (
+
+ onChange(listing.id, {
+ costPrice: listing.costPrice,
+ price: e.target.value
+ })
+ }
+ disabled={loading}
+ required
+ hint={
+ priceError &&
+ getProductErrorMessage(priceError, intl)
+ }
+ />
+ ) : (
+
+ )}
+
+
+ {listing ? (
+
+ onChange(listing.id, {
+ costPrice: e.target.value,
+ price: listing.price
+ })
+ }
+ disabled={loading}
+ hint={
+ costPriceError
+ ? getProductErrorMessage(costPriceError, intl)
+ : ""
+ }
+ />
+ ) : (
+
+ )}
+
+
+ );
+ },
+ () => (
+
+
+
+
+
+ )
+ )}
+
+
);
diff --git a/src/products/components/ProductVariants/ProductVariants.tsx b/src/products/components/ProductVariants/ProductVariants.tsx
index cb533e8a1..b104ae2ec 100644
--- a/src/products/components/ProductVariants/ProductVariants.tsx
+++ b/src/products/components/ProductVariants/ProductVariants.tsx
@@ -7,6 +7,7 @@ import { fade } from "@material-ui/core/styles/colorManipulator";
import TableCell from "@material-ui/core/TableCell";
import Typography from "@material-ui/core/Typography";
import CardTitle from "@saleor/components/CardTitle";
+import { ChannelsSelect } from "@saleor/components/ChannelsSelect";
import Checkbox from "@saleor/components/Checkbox";
import LinkChoice from "@saleor/components/LinkChoice";
import Money from "@saleor/components/Money";
@@ -18,7 +19,7 @@ import {
SortableTableRow
} from "@saleor/components/SortableTable";
import TableHead from "@saleor/components/TableHead";
-import { ProductVariant_costPrice } from "@saleor/fragments/types/ProductVariant";
+import useStateFromProps from "@saleor/hooks/useStateFromProps";
import React from "react";
import { FormattedMessage, IntlShape, useIntl } from "react-intl";
@@ -83,6 +84,9 @@ const useStyles = makeStyles(
width: 200
}
},
+ channelSelect: {
+ marginRight: theme.spacing(1)
+ },
colGrab: {
width: 60
},
@@ -183,8 +187,8 @@ interface ProductVariantsProps extends ListActions {
disabled: boolean;
product: ProductDetails_product;
variants: ProductDetails_product_variants[];
- fallbackPrice?: ProductVariant_costPrice;
onVariantReorder: ReorderAction;
+ channelChoices: SingleAutocompleteChoiceType[];
onRowClick: (id: string) => () => void;
onSetDefaultVariant(variant: ProductDetails_product_variants);
onVariantAdd?();
@@ -195,10 +199,10 @@ const numberOfColumns = 7;
export const ProductVariants: React.FC = props => {
const {
+ channelChoices,
disabled,
variants,
product,
- fallbackPrice,
onRowClick,
onVariantAdd,
onVariantsAdd,
@@ -214,6 +218,9 @@ export const ProductVariants: React.FC = props => {
const intl = useIntl();
const [warehouse, setWarehouse] = React.useState(null);
+ const [channelChoice, setChannelChoice] = useStateFromProps(
+ channelChoices[0]?.value
+ );
const hasVariants = maybe(() => variants.length > 0, true);
return (
@@ -254,6 +261,11 @@ export const ProductVariants: React.FC = props => {
{variants.length > 0 ? (
+
= props => {
0
)
: null;
+ const channel = variant.channelListings.find(
+ listing => listing.channel.id === channelChoice
+ );
return (
= props => {
{variant ? (
- variant.price ? (
-
- ) : fallbackPrice ? (
-
- ) : (
-
- )
+
) : (
)}
diff --git a/src/products/fixtures.ts b/src/products/fixtures.ts
index 734843360..39580d37a 100644
--- a/src/products/fixtures.ts
+++ b/src/products/fixtures.ts
@@ -109,6 +109,46 @@ export const product: (
id: "Q2F0ZWdvcnk6MQ==",
name: "Apparel"
},
+ channelListings: [
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123",
+ name: "Channel1"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 1,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: true,
+ publicationDate: "2020-07-14",
+ visibleInListings: true
+ },
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "124",
+ name: "Channel2"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 1,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: false,
+ publicationDate: "2020-07-30",
+ visibleInListings: true
+ }
+ ],
chargeTaxes: true,
collections: [
{
@@ -160,7 +200,6 @@ export const product: (
isAvailable: false,
isAvailableForPurchase: false,
isFeatured: false,
- isPublished: true,
margin: { __typename: "Margin", start: 2, stop: 7 },
metadata: [
{
@@ -170,38 +209,6 @@ export const product: (
}
],
name: "Ergonomic Plastic Bacon",
- pricing: {
- __typename: "ProductPricingInfo",
- priceRangeUndiscounted: {
- __typename: "TaxedMoneyRange",
- start: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 12.3,
- currency: "USD"
- },
- net: {
- __typename: "Money",
- amount: 10,
- currency: "USD"
- }
- },
- stop: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 24.6,
- currency: "USD"
- },
- net: {
- __typename: "Money",
- amount: 20,
- currency: "USD"
- }
- }
- }
- },
privateMetadata: [],
productType: {
__typename: "ProductType",
@@ -270,6 +277,7 @@ export const product: (
variants: [
{
__typename: "ProductVariant",
+ channelListings: [],
id: "pv75934",
images: [
{
@@ -285,11 +293,6 @@ export const product: (
],
margin: 2,
name: "Cordoba Oro",
- price: {
- __typename: "Money",
- amount: 678.78,
- currency: "USD"
- },
sku: "87192-94370",
stocks: [
{
@@ -316,6 +319,46 @@ export const product: (
},
{
__typename: "ProductVariant",
+ channelListings: [
+ {
+ __typename: "ProductVariantChannelListing",
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123",
+ name: "Channel1"
+ },
+ costPrice: {
+ __typename: "Money",
+ amount: 10,
+ currency: "USD"
+ },
+ price: {
+ __typename: "Money",
+ amount: 1,
+ currency: "USD"
+ }
+ },
+ {
+ __typename: "ProductVariantChannelListing",
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "124",
+ name: "Channel2"
+ },
+ costPrice: {
+ __typename: "Money",
+ amount: 10,
+ currency: "USD"
+ },
+ price: {
+ __typename: "Money",
+ amount: 1,
+ currency: "USD"
+ }
+ }
+ ],
id: "pv68615",
images: [
{
@@ -331,7 +374,6 @@ export const product: (
],
margin: 7,
name: "silver",
- price: null,
sku: "69055-15190",
stocks: [
{
@@ -363,32 +405,48 @@ export const products = (
{
__typename: "Product",
attributes: [],
+ channelListings: [
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123",
+ name: "Channel1"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: true,
+ publicationDate: "2020-07-14",
+ visibleInListings: true
+ },
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "124",
+ name: "Channel2"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: false,
+ publicationDate: "2020-07-30",
+ visibleInListings: true
+ }
+ ],
id: "UHJvZHVjdDo2MQ==",
- isAvailable: true,
- isPublished: true,
name: "Nebula Night Sky Paint",
- pricing: {
- __typename: "ProductPricingInfo",
- priceRangeUndiscounted: {
- __typename: "TaxedMoneyRange",
- start: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 3,
- currency: "USD"
- }
- },
- stop: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 8,
- currency: "USD"
- }
- }
- }
- },
productType: {
__typename: "ProductType",
hasVariants: true,
@@ -403,32 +461,48 @@ export const products = (
{
__typename: "Product",
attributes: [],
+ channelListings: [
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123",
+ name: "Channel1"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: true,
+ publicationDate: "2020-07-14",
+ visibleInListings: false
+ },
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "124",
+ name: "Channel2"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: false,
+ publicationDate: "2020-07-30",
+ visibleInListings: false
+ }
+ ],
id: "UHJvZHVjdDo2NA==",
- isAvailable: true,
- isPublished: false,
name: "Light Speed Yellow Paint",
- pricing: {
- __typename: "ProductPricingInfo",
- priceRangeUndiscounted: {
- __typename: "TaxedMoneyRange",
- start: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 3,
- currency: "USD"
- }
- },
- stop: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 8,
- currency: "USD"
- }
- }
- }
- },
productType: {
__typename: "ProductType",
hasVariants: true,
@@ -443,33 +517,48 @@ export const products = (
{
__typename: "Product",
attributes: [],
- id: "UHJvZHVjdDo2NQ==",
- isAvailable: true,
- isPublished: false,
- name: "Hyperspace Turquoise Paint",
-
- pricing: {
- __typename: "ProductPricingInfo",
- priceRangeUndiscounted: {
- __typename: "TaxedMoneyRange",
- start: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 3,
- currency: "USD"
- }
+ channelListings: [
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123",
+ name: "Channel1"
},
- stop: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 8,
- currency: "USD"
- }
- }
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: true,
+ publicationDate: "2020-07-14",
+ visibleInListings: false
+ },
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "124",
+ name: "Channel2"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: false,
+ publicationDate: "2020-07-30",
+ visibleInListings: false
}
- },
+ ],
+ id: "UHJvZHVjdDo2NQ==",
+ name: "Hyperspace Turquoise Paint",
productType: {
__typename: "ProductType",
hasVariants: true,
@@ -499,33 +588,48 @@ export const products = (
]
}
],
- id: "UHJvZHVjdDo3NQ==",
- isAvailable: true,
- isPublished: true,
- name: "Pineapple Juice",
-
- pricing: {
- __typename: "ProductPricingInfo",
- priceRangeUndiscounted: {
- __typename: "TaxedMoneyRange",
- start: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 3,
- currency: "USD"
- }
+ channelListings: [
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123",
+ name: "Channel1"
},
- stop: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 8,
- currency: "USD"
- }
- }
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: true,
+ publicationDate: "2020-07-14",
+ visibleInListings: false
+ },
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "124",
+ name: "Channel2"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: false,
+ publicationDate: "2020-07-30",
+ visibleInListings: false
}
- },
+ ],
+ id: "UHJvZHVjdDo3NQ==",
+ name: "Pineapple Juice",
productType: {
__typename: "ProductType",
hasVariants: true,
@@ -555,33 +659,48 @@ export const products = (
]
}
],
- id: "UHJvZHVjdDo3Ng==",
- isAvailable: true,
- isPublished: true,
- name: "Coconut Juice",
-
- pricing: {
- __typename: "ProductPricingInfo",
- priceRangeUndiscounted: {
- __typename: "TaxedMoneyRange",
- start: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 3,
- currency: "USD"
- }
+ channelListings: [
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123",
+ name: "Channel1"
},
- stop: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 8,
- currency: "USD"
- }
- }
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: true,
+ publicationDate: "2020-07-14",
+ visibleInListings: false
+ },
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "124",
+ name: "Channel2"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: false,
+ publicationDate: "2020-07-30",
+ visibleInListings: false
}
- },
+ ],
+ id: "UHJvZHVjdDo3Ng==",
+ name: "Coconut Juice",
productType: {
__typename: "ProductType",
hasVariants: true,
@@ -611,33 +730,49 @@ export const products = (
]
}
],
- id: "UHJvZHVjdDo3Mg==",
- isAvailable: true,
- isPublished: true,
- name: "Apple Juice",
-
- pricing: {
- __typename: "ProductPricingInfo",
- priceRangeUndiscounted: {
- __typename: "TaxedMoneyRange",
- start: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 3,
- currency: "USD"
- }
+ channelListings: [
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123",
+ name: "Channel1"
},
- stop: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 8,
- currency: "USD"
- }
- }
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: true,
+ publicationDate: "2020-07-14",
+ visibleInListings: false
+ },
+
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "124",
+ name: "Channel2"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: false,
+ publicationDate: "2020-07-30",
+ visibleInListings: false
}
- },
+ ],
+ id: "UHJvZHVjdDo3Mg==",
+ name: "Apple Juice",
productType: {
__typename: "ProductType",
hasVariants: true,
@@ -667,33 +802,48 @@ export const products = (
]
}
],
- id: "UHJvZHVjdDo3MQ==",
- isAvailable: true,
- isPublished: true,
- name: "Orange Juice",
-
- pricing: {
- __typename: "ProductPricingInfo",
- priceRangeUndiscounted: {
- __typename: "TaxedMoneyRange",
- start: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 3,
- currency: "USD"
- }
+ channelListings: [
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123",
+ name: "Channel1"
},
- stop: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 8,
- currency: "USD"
- }
- }
+ discountedPrice: {
+ __typename: "Money",
+ amount: 1,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: true,
+ publicationDate: "2020-07-14",
+ visibleInListings: false
+ },
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "124",
+ name: "Channel2"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: false,
+ publicationDate: "2020-07-30",
+ visibleInListings: false
}
- },
+ ],
+ id: "UHJvZHVjdDo3MQ==",
+ name: "Orange Juice",
productType: {
__typename: "ProductType",
hasVariants: true,
@@ -723,33 +873,48 @@ export const products = (
]
}
],
- id: "UHJvZHVjdDo3NA==",
- isAvailable: true,
- isPublished: true,
- name: "Banana Juice",
-
- pricing: {
- __typename: "ProductPricingInfo",
- priceRangeUndiscounted: {
- __typename: "TaxedMoneyRange",
- start: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 3,
- currency: "USD"
- }
+ channelListings: [
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123",
+ name: "Channel1"
},
- stop: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 8,
- currency: "USD"
- }
- }
+ discountedPrice: {
+ __typename: "Money",
+ amount: 1,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: true,
+ publicationDate: "2020-07-14",
+ visibleInListings: false
+ },
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "124",
+ name: "Channel2"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 1,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: false,
+ publicationDate: "2020-07-30",
+ visibleInListings: false
}
- },
+ ],
+ id: "UHJvZHVjdDo3NA==",
+ name: "Banana Juice",
productType: {
__typename: "ProductType",
hasVariants: true,
@@ -779,33 +944,48 @@ export const products = (
]
}
],
- id: "UHJvZHVjdDo3OQ==",
- isAvailable: true,
- isPublished: false,
- name: "Bean Juice",
-
- pricing: {
- __typename: "ProductPricingInfo",
- priceRangeUndiscounted: {
- __typename: "TaxedMoneyRange",
- start: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 3,
- currency: "USD"
- }
+ channelListings: [
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123",
+ name: "Channel1"
},
- stop: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 8,
- currency: "USD"
- }
- }
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: true,
+ publicationDate: "2020-07-14",
+ visibleInListings: true
+ },
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "124",
+ name: "Channel2"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: false,
+ publicationDate: "2020-07-30",
+ visibleInListings: true
}
- },
+ ],
+ id: "UHJvZHVjdDo3OQ==",
+ name: "Bean Juice",
productType: {
__typename: "ProductType",
hasVariants: true,
@@ -835,33 +1015,48 @@ export const products = (
]
}
],
- id: "UHJvZHVjdDo3Mw==",
- isAvailable: true,
- isPublished: true,
- name: "Carrot Juice",
-
- pricing: {
- __typename: "ProductPricingInfo",
- priceRangeUndiscounted: {
- __typename: "TaxedMoneyRange",
- start: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 3,
- currency: "USD"
- }
+ channelListings: [
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123",
+ name: "Channel1"
},
- stop: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 8,
- currency: "USD"
- }
- }
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: true,
+ publicationDate: "2020-07-14",
+ visibleInListings: false
+ },
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "124",
+ name: "Channel2"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: false,
+ publicationDate: "2020-07-30",
+ visibleInListings: false
}
- },
+ ],
+ id: "UHJvZHVjdDo3Mw==",
+ name: "Carrot Juice",
productType: {
__typename: "ProductType",
hasVariants: true,
@@ -891,33 +1086,48 @@ export const products = (
]
}
],
- id: "UHJvZHVjdDo3OA==",
- isAvailable: true,
- isPublished: true,
- name: "Green Juice",
-
- pricing: {
- __typename: "ProductPricingInfo",
- priceRangeUndiscounted: {
- __typename: "TaxedMoneyRange",
- start: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 3,
- currency: "USD"
- }
+ channelListings: [
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123",
+ name: "Channel1"
},
- stop: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 8,
- currency: "USD"
- }
- }
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: true,
+ publicationDate: "2020-07-14",
+ visibleInListings: true
+ },
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "124",
+ name: "Channel2"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: false,
+ publicationDate: "2020-07-30",
+ visibleInListings: true
}
- },
+ ],
+ id: "UHJvZHVjdDo3OA==",
+ name: "Green Juice",
productType: {
__typename: "ProductType",
hasVariants: true,
@@ -947,33 +1157,48 @@ export const products = (
]
}
],
- id: "UHJvZHVjdDo4OQ==",
- isAvailable: true,
- isPublished: true,
- name: "Code Division T-shirt",
-
- pricing: {
- __typename: "ProductPricingInfo",
- priceRangeUndiscounted: {
- __typename: "TaxedMoneyRange",
- start: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 3,
- currency: "USD"
- }
+ channelListings: [
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123",
+ name: "Channel1"
},
- stop: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 8,
- currency: "USD"
- }
- }
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: true,
+ publicationDate: "2020-07-14",
+ visibleInListings: true
+ },
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "124",
+ name: "Channel2"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: false,
+ publicationDate: "2020-07-30",
+ visibleInListings: true
}
- },
+ ],
+ id: "UHJvZHVjdDo4OQ==",
+ name: "Code Division T-shirt",
productType: {
__typename: "ProductType",
hasVariants: true,
@@ -1003,33 +1228,48 @@ export const products = (
]
}
],
+ channelListings: [
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123",
+ name: "Channel1"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: true,
+ publicationDate: "2020-07-14",
+ visibleInListings: true
+ },
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "124",
+ name: "Channel2"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: false,
+ publicationDate: "2020-07-30",
+ visibleInListings: true
+ }
+ ],
id: "UHJvZHVjdDoxMDc=",
- isAvailable: true,
- isPublished: true,
name: "Polo Shirt",
-
- pricing: {
- __typename: "ProductPricingInfo",
- priceRangeUndiscounted: {
- __typename: "TaxedMoneyRange",
- start: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 3,
- currency: "USD"
- }
- },
- stop: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 8,
- currency: "USD"
- }
- }
- }
- },
productType: {
__typename: "ProductType",
hasVariants: true,
@@ -1059,33 +1299,48 @@ export const products = (
]
}
],
+ channelListings: [
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123",
+ name: "Channel1"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: true,
+ publicationDate: "2020-07-14",
+ visibleInListings: false
+ },
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "124",
+ name: "Channel2"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: false,
+ publicationDate: "2020-07-30",
+ visibleInListings: false
+ }
+ ],
id: "UHJvZHVjdDoxMDg=",
- isAvailable: true,
- isPublished: true,
name: "Polo Shirt",
-
- pricing: {
- __typename: "ProductPricingInfo",
- priceRangeUndiscounted: {
- __typename: "TaxedMoneyRange",
- start: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 3,
- currency: "USD"
- }
- },
- stop: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 8,
- currency: "USD"
- }
- }
- }
- },
productType: {
__typename: "ProductType",
hasVariants: true,
@@ -1115,33 +1370,48 @@ export const products = (
]
}
],
+ channelListings: [
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123",
+ name: "Channel1"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: true,
+ publicationDate: "2020-07-14",
+ visibleInListings: false
+ },
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "124",
+ name: "Channel2"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: false,
+ publicationDate: "2020-07-30",
+ visibleInListings: false
+ }
+ ],
id: "UHJvZHVjdDoxMDk=",
- isAvailable: true,
- isPublished: true,
name: "Polo Shirt",
-
- pricing: {
- __typename: "ProductPricingInfo",
- priceRangeUndiscounted: {
- __typename: "TaxedMoneyRange",
- start: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 3,
- currency: "USD"
- }
- },
- stop: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 8,
- currency: "USD"
- }
- }
- }
- },
productType: {
__typename: "ProductType",
hasVariants: true,
@@ -1171,33 +1441,48 @@ export const products = (
]
}
],
+ channelListings: [
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123",
+ name: "Channel1"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: true,
+ publicationDate: "2020-07-14",
+ visibleInListings: true
+ },
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "124",
+ name: "Channel2"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: false,
+ publicationDate: "2020-07-30",
+ visibleInListings: true
+ }
+ ],
id: "UHJvZHVjdDoxMTA=",
- isAvailable: true,
- isPublished: true,
name: "Polo Shirt",
-
- pricing: {
- __typename: "ProductPricingInfo",
- priceRangeUndiscounted: {
- __typename: "TaxedMoneyRange",
- start: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 3,
- currency: "USD"
- }
- },
- stop: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 8,
- currency: "USD"
- }
- }
- }
- },
productType: {
__typename: "ProductType",
hasVariants: true,
@@ -1227,33 +1512,48 @@ export const products = (
]
}
],
+ channelListings: [
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123",
+ name: "Channel1"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: true,
+ publicationDate: "2020-07-14",
+ visibleInListings: false
+ },
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "124",
+ name: "Channel2"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: false,
+ publicationDate: "2020-07-30",
+ visibleInListings: false
+ }
+ ],
id: "UHJvZHVjdDoxMTU=",
- isAvailable: true,
- isPublished: false,
name: "Black Hoodie",
-
- pricing: {
- __typename: "ProductPricingInfo",
- priceRangeUndiscounted: {
- __typename: "TaxedMoneyRange",
- start: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 3,
- currency: "USD"
- }
- },
- stop: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 8,
- currency: "USD"
- }
- }
- }
- },
productType: {
__typename: "ProductType",
hasVariants: true,
@@ -1283,33 +1583,48 @@ export const products = (
]
}
],
+ channelListings: [
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123",
+ name: "Channel1"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: true,
+ publicationDate: "2020-07-14",
+ visibleInListings: true
+ },
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "124",
+ name: "Channel2"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 3.99,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: false,
+ publicationDate: "2020-07-30",
+ visibleInListings: true
+ }
+ ],
id: "UHJvZHVjdDoxMTY=",
- isAvailable: true,
- isPublished: true,
name: "Blue Hoodie",
-
- pricing: {
- __typename: "ProductPricingInfo",
- priceRangeUndiscounted: {
- __typename: "TaxedMoneyRange",
- start: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 3,
- currency: "USD"
- }
- },
- stop: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 8,
- currency: "USD"
- }
- }
- }
- },
productType: {
__typename: "ProductType",
hasVariants: true,
@@ -1339,33 +1654,48 @@ export const products = (
]
}
],
- id: "UHJvZHVjdDoxMTc=",
- isAvailable: true,
- isPublished: true,
- name: "Mustard Hoodie",
-
- pricing: {
- __typename: "ProductPricingInfo",
- priceRangeUndiscounted: {
- __typename: "TaxedMoneyRange",
- start: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 3,
- currency: "USD"
- }
+ channelListings: [
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123",
+ name: "Channel1"
},
- stop: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 8,
- currency: "USD"
- }
- }
+ discountedPrice: {
+ __typename: "Money",
+ amount: 1,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: true,
+ publicationDate: "2020-07-14",
+ visibleInListings: true
+ },
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "124",
+ name: "Channel2"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 1,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: false,
+ publicationDate: "2020-07-30",
+ visibleInListings: true
}
- },
+ ],
+ id: "UHJvZHVjdDoxMTc=",
+ name: "Mustard Hoodie",
productType: {
__typename: "ProductType",
hasVariants: true,
@@ -1395,33 +1725,48 @@ export const products = (
]
}
],
- id: "UHJvZHVjdDo4NQ==",
- isAvailable: true,
- isPublished: false,
- name: "Colored Parrot Cushion",
-
- pricing: {
- __typename: "ProductPricingInfo",
- priceRangeUndiscounted: {
- __typename: "TaxedMoneyRange",
- start: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 3,
- currency: "USD"
- }
+ channelListings: [
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "123",
+ name: "Channel1"
},
- stop: {
- __typename: "TaxedMoney",
- gross: {
- __typename: "Money",
- amount: 8,
- currency: "USD"
- }
- }
+ discountedPrice: {
+ __typename: "Money",
+ amount: 1,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: true,
+ publicationDate: "2020-07-14",
+ visibleInListings: true
+ },
+ {
+ __typename: "ProductChannelListing",
+ availableForPurchase: null,
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "124",
+ name: "Channel2"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 1,
+ currency: "USD"
+ },
+ isAvailableForPurchase: false,
+ isPublished: false,
+ publicationDate: "2020-07-30",
+ visibleInListings: true
}
- },
+ ],
+ id: "UHJvZHVjdDo4NQ==",
+ name: "Colored Parrot Cushion",
productType: {
__typename: "ProductType",
hasVariants: true,
@@ -1515,11 +1860,46 @@ export const variant = (placeholderImage: string): ProductVariant => ({
]
}
],
- costPrice: {
- __typename: "Money",
- amount: 12,
- currency: "USD"
- },
+ channelListings: [
+ {
+ __typename: "ProductVariantChannelListing",
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "test1",
+ name: "Test channel"
+ },
+ costPrice: {
+ __typename: "Money",
+ amount: 10,
+ currency: "USD"
+ },
+ price: {
+ __typename: "Money",
+ amount: 10,
+ currency: "USD"
+ }
+ },
+ {
+ __typename: "ProductVariantChannelListing",
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "test2",
+ name: "Test channel other"
+ },
+ costPrice: {
+ __typename: "Money",
+ amount: 10,
+ currency: "USD"
+ },
+ price: {
+ __typename: "Money",
+ amount: 20,
+ currency: "USD"
+ }
+ }
+ ],
id: "var1",
images: [
{
@@ -1551,14 +1931,39 @@ export const variant = (placeholderImage: string): ProductVariant => ({
}
],
name: "Extended Hard",
- price: {
- __typename: "Money",
- amount: 100,
- currency: "USD"
- },
privateMetadata: [],
product: {
__typename: "Product" as "Product",
+ channelListings: [
+ {
+ __typename: "ProductChannelListing",
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "test1",
+ name: "Test channel"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 10,
+ currency: "USD"
+ }
+ },
+ {
+ __typename: "ProductChannelListing",
+ channel: {
+ __typename: "Channel",
+ currencyCode: "USD",
+ id: "test2",
+ name: "Test channel other"
+ },
+ discountedPrice: {
+ __typename: "Money",
+ amount: 20,
+ currency: "USD"
+ }
+ }
+ ],
defaultVariant: {
__typename: "ProductVariant",
id: "var1"
diff --git a/src/products/mutations.ts b/src/products/mutations.ts
index 1b63cf258..f7928dcce 100644
--- a/src/products/mutations.ts
+++ b/src/products/mutations.ts
@@ -2,6 +2,7 @@ import {
bulkProductErrorFragment,
bulkStockErrorFragment,
exportErrorFragment,
+ productChannelListingErrorFragment,
productErrorFragment,
productErrorWithAttributesFragment,
stockErrorFragment
@@ -19,9 +20,9 @@ import {
productBulkDeleteVariables
} from "./types/productBulkDelete";
import {
- productBulkPublish,
- productBulkPublishVariables
-} from "./types/productBulkPublish";
+ ProductChannelListingUpdate,
+ ProductChannelListingUpdateVariables
+} from "./types/ProductChannelListingUpdate";
import { ProductCreate, ProductCreateVariables } from "./types/ProductCreate";
import { ProductDelete, ProductDeleteVariables } from "./types/ProductDelete";
import { ProductExport, ProductExportVariables } from "./types/ProductExport";
@@ -41,10 +42,6 @@ import {
ProductImageUpdate,
ProductImageUpdateVariables
} from "./types/ProductImageUpdate";
-import {
- ProductSetAvailabilityForPurchase,
- ProductSetAvailabilityForPurchaseVariables
-} from "./types/ProductSetAvailabilityForPurchase";
import { ProductUpdate, ProductUpdateVariables } from "./types/ProductUpdate";
import {
ProductVariantBulkCreate,
@@ -54,6 +51,10 @@ import {
ProductVariantBulkDelete,
ProductVariantBulkDeleteVariables
} from "./types/ProductVariantBulkDelete";
+import {
+ ProductVariantChannelListingUpdate,
+ ProductVariantChannelListingUpdateVariables
+} from "./types/ProductVariantChannelListingUpdate";
import {
ProductVariantReorder,
ProductVariantReorderVariables
@@ -295,8 +296,6 @@ export const variantUpdateMutation = gql`
$removeStocks: [ID!]!
$id: ID!
$attributes: [AttributeValueInput]
- $costPrice: PositiveDecimal
- $price: PositiveDecimal
$sku: String
$trackInventory: Boolean!
$stocks: [StockInput!]!
@@ -306,8 +305,6 @@ export const variantUpdateMutation = gql`
id: $id
input: {
attributes: $attributes
- costPrice: $costPrice
- price: $price
sku: $sku
trackInventory: $trackInventory
weight: $weight
@@ -470,21 +467,6 @@ export const useProductBulkDeleteMutation = makeMutation<
productBulkDeleteVariables
>(productBulkDeleteMutation);
-export const productBulkPublishMutation = gql`
- ${productErrorFragment}
- mutation productBulkPublish($ids: [ID!]!, $isPublished: Boolean!) {
- productBulkPublish(ids: $ids, isPublished: $isPublished) {
- errors: productErrors {
- ...ProductErrorFragment
- }
- }
- }
-`;
-export const useProductBulkPublishMutation = makeMutation<
- productBulkPublish,
- productBulkPublishVariables
->(productBulkPublishMutation);
-
export const ProductVariantBulkCreateMutation = gql`
${bulkProductErrorFragment}
mutation ProductVariantBulkCreate(
@@ -537,36 +519,24 @@ export const useProductExport = makeMutation<
ProductExportVariables
>(productExportMutation);
-const productSetAvailabilityForPurchase = gql`
- ${productErrorFragment}
- mutation ProductSetAvailabilityForPurchase(
- $isAvailable: Boolean!
- $productId: ID!
- $startDate: Date
+export const ProductChannelListingUpdateMutation = gql`
+ ${productFragmentDetails}
+ ${productChannelListingErrorFragment}
+ mutation ProductChannelListingUpdate(
+ $id: ID!
+ $input: ProductChannelListingUpdateInput!
) {
- productSetAvailabilityForPurchase(
- isAvailable: $isAvailable
- productId: $productId
- startDate: $startDate
- ) {
+ productChannelListingUpdate(id: $id, input: $input) {
product {
- id
- availableForPurchase
- isAvailableForPurchase
+ ...Product
}
- errors: productErrors {
- ...ProductErrorFragment
- message
+ errors: productChannelListingErrors {
+ ...ProductChannelListingErrorFragment
}
}
}
`;
-export const useProductSetAvailabilityForPurchase = makeMutation<
- ProductSetAvailabilityForPurchase,
- ProductSetAvailabilityForPurchaseVariables
->(productSetAvailabilityForPurchase);
-
const productVariantReorder = gql`
${productErrorFragment}
${productFragmentDetails}
@@ -585,3 +555,30 @@ export const useProductVariantReorderMutation = makeMutation<
ProductVariantReorder,
ProductVariantReorderVariables
>(productVariantReorder);
+export const useProductChannelListingUpdate = makeMutation<
+ ProductChannelListingUpdate,
+ ProductChannelListingUpdateVariables
+>(ProductChannelListingUpdateMutation);
+
+export const ProductVariantChannelListingUpdateMutation = gql`
+ ${fragmentVariant}
+ ${productChannelListingErrorFragment}
+ mutation ProductVariantChannelListingUpdate(
+ $id: ID!
+ $input: [ProductVariantChannelListingAddInput!]!
+ ) {
+ productVariantChannelListingUpdate(id: $id, input: $input) {
+ variant {
+ ...ProductVariant
+ }
+ errors: productChannelListingErrors {
+ ...ProductChannelListingErrorFragment
+ }
+ }
+ }
+`;
+
+export const useProductVariantChannelListingUpdate = makeMutation<
+ ProductVariantChannelListingUpdate,
+ ProductVariantChannelListingUpdateVariables
+>(ProductVariantChannelListingUpdateMutation);
diff --git a/src/products/queries.ts b/src/products/queries.ts
index 68ebb6873..895e002e0 100644
--- a/src/products/queries.ts
+++ b/src/products/queries.ts
@@ -1,6 +1,5 @@
import { pageInfoFragment } from "@saleor/fragments/pageInfo";
import {
- fragmentMoney,
fragmentVariant,
productFragment,
productFragmentDetails,
@@ -94,7 +93,6 @@ export const useInitialProductFilterDataQuery = makeQuery<
>(initialProductFilterDataQuery);
const productListQuery = gql`
- ${fragmentMoney}
${productFragment}
query ProductList(
$first: Int
@@ -124,20 +122,6 @@ const productListQuery = gql`
name
}
}
- pricing {
- priceRangeUndiscounted {
- start {
- gross {
- ...Money
- }
- }
- stop {
- gross {
- ...Money
- }
- }
- }
- }
}
}
pageInfo {
@@ -168,8 +152,8 @@ export const useCountAllProducts = makeQuery(
const productDetailsQuery = gql`
${productFragmentDetails}
${taxTypeFragment}
- query ProductDetails($id: ID!) {
- product(id: $id) {
+ query ProductDetails($id: ID!, $channel: String) {
+ product(id: $id, channel: $channel) {
...Product
}
taxTypes {
@@ -182,6 +166,11 @@ export const useProductDetails = makeQuery<
ProductDetailsVariables
>(productDetailsQuery);
+export const useProductDetailsQuery = makeQuery<
+ ProductDetails,
+ ProductDetailsVariables
+>(productDetailsQuery);
+
const productVariantQuery = gql`
${fragmentVariant}
query ProductVariantDetails($id: ID!) {
@@ -204,6 +193,13 @@ const productVariantCreateQuery = gql`
sortOrder
url
}
+ channelListings {
+ channel {
+ id
+ name
+ currencyCode
+ }
+ }
name
productType {
id
diff --git a/src/products/types/CreateMultipleVariantsData.ts b/src/products/types/CreateMultipleVariantsData.ts
index ea2d1909f..1d3f7a8b5 100644
--- a/src/products/types/CreateMultipleVariantsData.ts
+++ b/src/products/types/CreateMultipleVariantsData.ts
@@ -58,37 +58,23 @@ export interface CreateMultipleVariantsData_product_productType {
variantAttributes: (CreateMultipleVariantsData_product_productType_variantAttributes | null)[] | null;
}
-export interface CreateMultipleVariantsData_product_pricing_priceRangeUndiscounted_start_gross {
+export interface CreateMultipleVariantsData_product_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface CreateMultipleVariantsData_product_channelListings_discountedPrice {
__typename: "Money";
amount: number;
currency: string;
}
-export interface CreateMultipleVariantsData_product_pricing_priceRangeUndiscounted_start {
- __typename: "TaxedMoney";
- gross: CreateMultipleVariantsData_product_pricing_priceRangeUndiscounted_start_gross;
-}
-
-export interface CreateMultipleVariantsData_product_pricing_priceRangeUndiscounted_stop_gross {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
-export interface CreateMultipleVariantsData_product_pricing_priceRangeUndiscounted_stop {
- __typename: "TaxedMoney";
- gross: CreateMultipleVariantsData_product_pricing_priceRangeUndiscounted_stop_gross;
-}
-
-export interface CreateMultipleVariantsData_product_pricing_priceRangeUndiscounted {
- __typename: "TaxedMoneyRange";
- start: CreateMultipleVariantsData_product_pricing_priceRangeUndiscounted_start | null;
- stop: CreateMultipleVariantsData_product_pricing_priceRangeUndiscounted_stop | null;
-}
-
-export interface CreateMultipleVariantsData_product_pricing {
- __typename: "ProductPricingInfo";
- priceRangeUndiscounted: CreateMultipleVariantsData_product_pricing_priceRangeUndiscounted | null;
+export interface CreateMultipleVariantsData_product_channelListings {
+ __typename: "ProductChannelListing";
+ channel: CreateMultipleVariantsData_product_channelListings_channel;
+ discountedPrice: CreateMultipleVariantsData_product_channelListings_discountedPrice | null;
}
export interface CreateMultipleVariantsData_product {
@@ -96,7 +82,7 @@ export interface CreateMultipleVariantsData_product {
id: string;
attributes: CreateMultipleVariantsData_product_attributes[];
productType: CreateMultipleVariantsData_product_productType;
- pricing: CreateMultipleVariantsData_product_pricing | null;
+ channelListings: CreateMultipleVariantsData_product_channelListings[] | null;
}
export interface CreateMultipleVariantsData_warehouses_edges_node {
diff --git a/src/products/types/ProductChannelListingUpdate.ts b/src/products/types/ProductChannelListingUpdate.ts
new file mode 100644
index 000000000..1cb1a786d
--- /dev/null
+++ b/src/products/types/ProductChannelListingUpdate.ts
@@ -0,0 +1,239 @@
+/* tslint:disable */
+/* eslint-disable */
+// This file was automatically generated and should not be edited.
+
+import { ProductChannelListingUpdateInput, AttributeInputTypeEnum, WeightUnitsEnum, ProductErrorCode } from "./../../types/globalTypes";
+
+// ====================================================
+// GraphQL mutation operation: ProductChannelListingUpdate
+// ====================================================
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate_product_attributes_attribute_values {
+ __typename: "AttributeValue";
+ id: string;
+ name: string | null;
+ slug: string | null;
+}
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate_product_attributes_attribute {
+ __typename: "Attribute";
+ id: string;
+ slug: string | null;
+ name: string | null;
+ inputType: AttributeInputTypeEnum | null;
+ valueRequired: boolean;
+ values: (ProductChannelListingUpdate_productChannelListingUpdate_product_attributes_attribute_values | null)[] | null;
+}
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate_product_attributes_values {
+ __typename: "AttributeValue";
+ id: string;
+ name: string | null;
+ slug: string | null;
+}
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate_product_attributes {
+ __typename: "SelectedAttribute";
+ attribute: ProductChannelListingUpdate_productChannelListingUpdate_product_attributes_attribute;
+ values: (ProductChannelListingUpdate_productChannelListingUpdate_product_attributes_values | null)[];
+}
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate_product_productType_variantAttributes_values {
+ __typename: "AttributeValue";
+ id: string;
+ name: string | null;
+ slug: string | null;
+}
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate_product_productType_variantAttributes {
+ __typename: "Attribute";
+ id: string;
+ name: string | null;
+ values: (ProductChannelListingUpdate_productChannelListingUpdate_product_productType_variantAttributes_values | null)[] | null;
+}
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate_product_productType_taxType {
+ __typename: "TaxType";
+ description: string | null;
+ taxCode: string | null;
+}
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate_product_productType {
+ __typename: "ProductType";
+ id: string;
+ variantAttributes: (ProductChannelListingUpdate_productChannelListingUpdate_product_productType_variantAttributes | null)[] | null;
+ name: string;
+ hasVariants: boolean;
+ taxType: ProductChannelListingUpdate_productChannelListingUpdate_product_productType_taxType | null;
+}
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate_product_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate_product_channelListings_discountedPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate_product_channelListings {
+ __typename: "ProductChannelListing";
+ channel: ProductChannelListingUpdate_productChannelListingUpdate_product_channelListings_channel;
+ discountedPrice: ProductChannelListingUpdate_productChannelListingUpdate_product_channelListings_discountedPrice | null;
+ isPublished: boolean;
+ publicationDate: any | null;
+ isAvailableForPurchase: boolean | null;
+ availableForPurchase: any | null;
+ visibleInListings: boolean;
+}
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate_product_metadata {
+ __typename: "MetadataItem";
+ key: string;
+ value: string;
+}
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate_product_privateMetadata {
+ __typename: "MetadataItem";
+ key: string;
+ value: string;
+}
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate_product_defaultVariant {
+ __typename: "ProductVariant";
+ id: string;
+}
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate_product_category {
+ __typename: "Category";
+ id: string;
+ name: string;
+}
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate_product_collections {
+ __typename: "Collection";
+ id: string;
+ name: string;
+}
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate_product_images {
+ __typename: "ProductImage";
+ id: string;
+ alt: string;
+ sortOrder: number | null;
+ url: string;
+}
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate_product_variants_stocks_warehouse {
+ __typename: "Warehouse";
+ id: string;
+ name: string;
+}
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate_product_variants_stocks {
+ __typename: "Stock";
+ id: string;
+ quantity: number;
+ quantityAllocated: number;
+ warehouse: ProductChannelListingUpdate_productChannelListingUpdate_product_variants_stocks_warehouse;
+}
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate_product_variants_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate_product_variants_channelListings_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate_product_variants_channelListings_costPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate_product_variants_channelListings {
+ __typename: "ProductVariantChannelListing";
+ channel: ProductChannelListingUpdate_productChannelListingUpdate_product_variants_channelListings_channel;
+ price: ProductChannelListingUpdate_productChannelListingUpdate_product_variants_channelListings_price | null;
+ costPrice: ProductChannelListingUpdate_productChannelListingUpdate_product_variants_channelListings_costPrice | null;
+}
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate_product_variants {
+ __typename: "ProductVariant";
+ id: string;
+ sku: string;
+ name: string;
+ margin: number | null;
+ stocks: (ProductChannelListingUpdate_productChannelListingUpdate_product_variants_stocks | null)[] | null;
+ trackInventory: boolean;
+ channelListings: ProductChannelListingUpdate_productChannelListingUpdate_product_variants_channelListings[] | null;
+}
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate_product_weight {
+ __typename: "Weight";
+ unit: WeightUnitsEnum;
+ value: number;
+}
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate_product_taxType {
+ __typename: "TaxType";
+ description: string | null;
+ taxCode: string | null;
+}
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate_product {
+ __typename: "Product";
+ id: string;
+ attributes: ProductChannelListingUpdate_productChannelListingUpdate_product_attributes[];
+ productType: ProductChannelListingUpdate_productChannelListingUpdate_product_productType;
+ channelListings: ProductChannelListingUpdate_productChannelListingUpdate_product_channelListings[] | null;
+ metadata: (ProductChannelListingUpdate_productChannelListingUpdate_product_metadata | null)[];
+ privateMetadata: (ProductChannelListingUpdate_productChannelListingUpdate_product_privateMetadata | null)[];
+ name: string;
+ slug: string;
+ descriptionJson: any;
+ seoTitle: string | null;
+ seoDescription: string | null;
+ defaultVariant: ProductChannelListingUpdate_productChannelListingUpdate_product_defaultVariant | null;
+ category: ProductChannelListingUpdate_productChannelListingUpdate_product_category | null;
+ collections: (ProductChannelListingUpdate_productChannelListingUpdate_product_collections | null)[] | null;
+ chargeTaxes: boolean;
+ images: (ProductChannelListingUpdate_productChannelListingUpdate_product_images | null)[] | null;
+ isAvailable: boolean | null;
+ variants: (ProductChannelListingUpdate_productChannelListingUpdate_product_variants | null)[] | null;
+ weight: ProductChannelListingUpdate_productChannelListingUpdate_product_weight | null;
+ taxType: ProductChannelListingUpdate_productChannelListingUpdate_product_taxType | null;
+}
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate_errors {
+ __typename: "ProductChannelListingError";
+ code: ProductErrorCode;
+ field: string | null;
+ message: string | null;
+ channels: string[] | null;
+}
+
+export interface ProductChannelListingUpdate_productChannelListingUpdate {
+ __typename: "ProductChannelListingUpdate";
+ product: ProductChannelListingUpdate_productChannelListingUpdate_product | null;
+ errors: ProductChannelListingUpdate_productChannelListingUpdate_errors[];
+}
+
+export interface ProductChannelListingUpdate {
+ productChannelListingUpdate: ProductChannelListingUpdate_productChannelListingUpdate | null;
+}
+
+export interface ProductChannelListingUpdateVariables {
+ id: string;
+ input: ProductChannelListingUpdateInput;
+}
diff --git a/src/products/types/ProductCreate.ts b/src/products/types/ProductCreate.ts
index 6db6a62df..ce83caf3d 100644
--- a/src/products/types/ProductCreate.ts
+++ b/src/products/types/ProductCreate.ts
@@ -74,37 +74,28 @@ export interface ProductCreate_productCreate_product_productType {
taxType: ProductCreate_productCreate_product_productType_taxType | null;
}
-export interface ProductCreate_productCreate_product_pricing_priceRangeUndiscounted_start_gross {
+export interface ProductCreate_productCreate_product_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface ProductCreate_productCreate_product_channelListings_discountedPrice {
__typename: "Money";
amount: number;
currency: string;
}
-export interface ProductCreate_productCreate_product_pricing_priceRangeUndiscounted_start {
- __typename: "TaxedMoney";
- gross: ProductCreate_productCreate_product_pricing_priceRangeUndiscounted_start_gross;
-}
-
-export interface ProductCreate_productCreate_product_pricing_priceRangeUndiscounted_stop_gross {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
-export interface ProductCreate_productCreate_product_pricing_priceRangeUndiscounted_stop {
- __typename: "TaxedMoney";
- gross: ProductCreate_productCreate_product_pricing_priceRangeUndiscounted_stop_gross;
-}
-
-export interface ProductCreate_productCreate_product_pricing_priceRangeUndiscounted {
- __typename: "TaxedMoneyRange";
- start: ProductCreate_productCreate_product_pricing_priceRangeUndiscounted_start | null;
- stop: ProductCreate_productCreate_product_pricing_priceRangeUndiscounted_stop | null;
-}
-
-export interface ProductCreate_productCreate_product_pricing {
- __typename: "ProductPricingInfo";
- priceRangeUndiscounted: ProductCreate_productCreate_product_pricing_priceRangeUndiscounted | null;
+export interface ProductCreate_productCreate_product_channelListings {
+ __typename: "ProductChannelListing";
+ channel: ProductCreate_productCreate_product_channelListings_channel;
+ discountedPrice: ProductCreate_productCreate_product_channelListings_discountedPrice | null;
+ isPublished: boolean;
+ publicationDate: any | null;
+ isAvailableForPurchase: boolean | null;
+ availableForPurchase: any | null;
+ visibleInListings: boolean;
}
export interface ProductCreate_productCreate_product_metadata {
@@ -136,30 +127,6 @@ export interface ProductCreate_productCreate_product_collections {
name: string;
}
-export interface ProductCreate_productCreate_product_margin {
- __typename: "Margin";
- start: number | null;
- stop: number | null;
-}
-
-export interface ProductCreate_productCreate_product_purchaseCost_start {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
-export interface ProductCreate_productCreate_product_purchaseCost_stop {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
-export interface ProductCreate_productCreate_product_purchaseCost {
- __typename: "MoneyRange";
- start: ProductCreate_productCreate_product_purchaseCost_start | null;
- stop: ProductCreate_productCreate_product_purchaseCost_stop | null;
-}
-
export interface ProductCreate_productCreate_product_images {
__typename: "ProductImage";
id: string;
@@ -168,12 +135,6 @@ export interface ProductCreate_productCreate_product_images {
url: string;
}
-export interface ProductCreate_productCreate_product_variants_price {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
export interface ProductCreate_productCreate_product_variants_stocks_warehouse {
__typename: "Warehouse";
id: string;
@@ -188,15 +149,41 @@ export interface ProductCreate_productCreate_product_variants_stocks {
warehouse: ProductCreate_productCreate_product_variants_stocks_warehouse;
}
+export interface ProductCreate_productCreate_product_variants_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface ProductCreate_productCreate_product_variants_channelListings_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ProductCreate_productCreate_product_variants_channelListings_costPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ProductCreate_productCreate_product_variants_channelListings {
+ __typename: "ProductVariantChannelListing";
+ channel: ProductCreate_productCreate_product_variants_channelListings_channel;
+ price: ProductCreate_productCreate_product_variants_channelListings_price | null;
+ costPrice: ProductCreate_productCreate_product_variants_channelListings_costPrice | null;
+}
+
export interface ProductCreate_productCreate_product_variants {
__typename: "ProductVariant";
id: string;
sku: string;
name: string;
- price: ProductCreate_productCreate_product_variants_price | null;
margin: number | null;
stocks: (ProductCreate_productCreate_product_variants_stocks | null)[] | null;
trackInventory: boolean;
+ channelListings: ProductCreate_productCreate_product_variants_channelListings[] | null;
}
export interface ProductCreate_productCreate_product_weight {
@@ -216,7 +203,7 @@ export interface ProductCreate_productCreate_product {
id: string;
attributes: ProductCreate_productCreate_product_attributes[];
productType: ProductCreate_productCreate_product_productType;
- pricing: ProductCreate_productCreate_product_pricing | null;
+ channelListings: ProductCreate_productCreate_product_channelListings[] | null;
metadata: (ProductCreate_productCreate_product_metadata | null)[];
privateMetadata: (ProductCreate_productCreate_product_privateMetadata | null)[];
name: string;
@@ -227,19 +214,12 @@ export interface ProductCreate_productCreate_product {
defaultVariant: ProductCreate_productCreate_product_defaultVariant | null;
category: ProductCreate_productCreate_product_category | null;
collections: (ProductCreate_productCreate_product_collections | null)[] | null;
- margin: ProductCreate_productCreate_product_margin | null;
- purchaseCost: ProductCreate_productCreate_product_purchaseCost | null;
- isAvailableForPurchase: boolean | null;
- isAvailable: boolean | null;
- isPublished: boolean;
chargeTaxes: boolean;
- publicationDate: any | null;
images: (ProductCreate_productCreate_product_images | null)[] | null;
+ isAvailable: boolean | null;
variants: (ProductCreate_productCreate_product_variants | null)[] | null;
weight: ProductCreate_productCreate_product_weight | null;
taxType: ProductCreate_productCreate_product_taxType | null;
- availableForPurchase: any | null;
- visibleInListings: boolean;
}
export interface ProductCreate_productCreate {
diff --git a/src/products/types/ProductDetails.ts b/src/products/types/ProductDetails.ts
index 21a614bc0..0d81e2f8e 100644
--- a/src/products/types/ProductDetails.ts
+++ b/src/products/types/ProductDetails.ts
@@ -67,37 +67,28 @@ export interface ProductDetails_product_productType {
taxType: ProductDetails_product_productType_taxType | null;
}
-export interface ProductDetails_product_pricing_priceRangeUndiscounted_start_gross {
+export interface ProductDetails_product_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface ProductDetails_product_channelListings_discountedPrice {
__typename: "Money";
amount: number;
currency: string;
}
-export interface ProductDetails_product_pricing_priceRangeUndiscounted_start {
- __typename: "TaxedMoney";
- gross: ProductDetails_product_pricing_priceRangeUndiscounted_start_gross;
-}
-
-export interface ProductDetails_product_pricing_priceRangeUndiscounted_stop_gross {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
-export interface ProductDetails_product_pricing_priceRangeUndiscounted_stop {
- __typename: "TaxedMoney";
- gross: ProductDetails_product_pricing_priceRangeUndiscounted_stop_gross;
-}
-
-export interface ProductDetails_product_pricing_priceRangeUndiscounted {
- __typename: "TaxedMoneyRange";
- start: ProductDetails_product_pricing_priceRangeUndiscounted_start | null;
- stop: ProductDetails_product_pricing_priceRangeUndiscounted_stop | null;
-}
-
-export interface ProductDetails_product_pricing {
- __typename: "ProductPricingInfo";
- priceRangeUndiscounted: ProductDetails_product_pricing_priceRangeUndiscounted | null;
+export interface ProductDetails_product_channelListings {
+ __typename: "ProductChannelListing";
+ channel: ProductDetails_product_channelListings_channel;
+ discountedPrice: ProductDetails_product_channelListings_discountedPrice | null;
+ isPublished: boolean;
+ publicationDate: any | null;
+ isAvailableForPurchase: boolean | null;
+ availableForPurchase: any | null;
+ visibleInListings: boolean;
}
export interface ProductDetails_product_metadata {
@@ -129,30 +120,6 @@ export interface ProductDetails_product_collections {
name: string;
}
-export interface ProductDetails_product_margin {
- __typename: "Margin";
- start: number | null;
- stop: number | null;
-}
-
-export interface ProductDetails_product_purchaseCost_start {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
-export interface ProductDetails_product_purchaseCost_stop {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
-export interface ProductDetails_product_purchaseCost {
- __typename: "MoneyRange";
- start: ProductDetails_product_purchaseCost_start | null;
- stop: ProductDetails_product_purchaseCost_stop | null;
-}
-
export interface ProductDetails_product_images {
__typename: "ProductImage";
id: string;
@@ -161,12 +128,6 @@ export interface ProductDetails_product_images {
url: string;
}
-export interface ProductDetails_product_variants_price {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
export interface ProductDetails_product_variants_stocks_warehouse {
__typename: "Warehouse";
id: string;
@@ -181,15 +142,41 @@ export interface ProductDetails_product_variants_stocks {
warehouse: ProductDetails_product_variants_stocks_warehouse;
}
+export interface ProductDetails_product_variants_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface ProductDetails_product_variants_channelListings_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ProductDetails_product_variants_channelListings_costPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ProductDetails_product_variants_channelListings {
+ __typename: "ProductVariantChannelListing";
+ channel: ProductDetails_product_variants_channelListings_channel;
+ price: ProductDetails_product_variants_channelListings_price | null;
+ costPrice: ProductDetails_product_variants_channelListings_costPrice | null;
+}
+
export interface ProductDetails_product_variants {
__typename: "ProductVariant";
id: string;
sku: string;
name: string;
- price: ProductDetails_product_variants_price | null;
margin: number | null;
stocks: (ProductDetails_product_variants_stocks | null)[] | null;
trackInventory: boolean;
+ channelListings: ProductDetails_product_variants_channelListings[] | null;
}
export interface ProductDetails_product_weight {
@@ -209,7 +196,7 @@ export interface ProductDetails_product {
id: string;
attributes: ProductDetails_product_attributes[];
productType: ProductDetails_product_productType;
- pricing: ProductDetails_product_pricing | null;
+ channelListings: ProductDetails_product_channelListings[] | null;
metadata: (ProductDetails_product_metadata | null)[];
privateMetadata: (ProductDetails_product_privateMetadata | null)[];
name: string;
@@ -220,19 +207,12 @@ export interface ProductDetails_product {
defaultVariant: ProductDetails_product_defaultVariant | null;
category: ProductDetails_product_category | null;
collections: (ProductDetails_product_collections | null)[] | null;
- margin: ProductDetails_product_margin | null;
- purchaseCost: ProductDetails_product_purchaseCost | null;
- isAvailableForPurchase: boolean | null;
- isAvailable: boolean | null;
- isPublished: boolean;
chargeTaxes: boolean;
- publicationDate: any | null;
images: (ProductDetails_product_images | null)[] | null;
+ isAvailable: boolean | null;
variants: (ProductDetails_product_variants | null)[] | null;
weight: ProductDetails_product_weight | null;
taxType: ProductDetails_product_taxType | null;
- availableForPurchase: any | null;
- visibleInListings: boolean;
}
export interface ProductDetails_taxTypes {
@@ -248,4 +228,5 @@ export interface ProductDetails {
export interface ProductDetailsVariables {
id: string;
+ channel?: string | null;
}
diff --git a/src/products/types/ProductImageCreate.ts b/src/products/types/ProductImageCreate.ts
index c1782b45b..9074d1f99 100644
--- a/src/products/types/ProductImageCreate.ts
+++ b/src/products/types/ProductImageCreate.ts
@@ -73,37 +73,28 @@ export interface ProductImageCreate_productImageCreate_product_productType {
taxType: ProductImageCreate_productImageCreate_product_productType_taxType | null;
}
-export interface ProductImageCreate_productImageCreate_product_pricing_priceRangeUndiscounted_start_gross {
+export interface ProductImageCreate_productImageCreate_product_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface ProductImageCreate_productImageCreate_product_channelListings_discountedPrice {
__typename: "Money";
amount: number;
currency: string;
}
-export interface ProductImageCreate_productImageCreate_product_pricing_priceRangeUndiscounted_start {
- __typename: "TaxedMoney";
- gross: ProductImageCreate_productImageCreate_product_pricing_priceRangeUndiscounted_start_gross;
-}
-
-export interface ProductImageCreate_productImageCreate_product_pricing_priceRangeUndiscounted_stop_gross {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
-export interface ProductImageCreate_productImageCreate_product_pricing_priceRangeUndiscounted_stop {
- __typename: "TaxedMoney";
- gross: ProductImageCreate_productImageCreate_product_pricing_priceRangeUndiscounted_stop_gross;
-}
-
-export interface ProductImageCreate_productImageCreate_product_pricing_priceRangeUndiscounted {
- __typename: "TaxedMoneyRange";
- start: ProductImageCreate_productImageCreate_product_pricing_priceRangeUndiscounted_start | null;
- stop: ProductImageCreate_productImageCreate_product_pricing_priceRangeUndiscounted_stop | null;
-}
-
-export interface ProductImageCreate_productImageCreate_product_pricing {
- __typename: "ProductPricingInfo";
- priceRangeUndiscounted: ProductImageCreate_productImageCreate_product_pricing_priceRangeUndiscounted | null;
+export interface ProductImageCreate_productImageCreate_product_channelListings {
+ __typename: "ProductChannelListing";
+ channel: ProductImageCreate_productImageCreate_product_channelListings_channel;
+ discountedPrice: ProductImageCreate_productImageCreate_product_channelListings_discountedPrice | null;
+ isPublished: boolean;
+ publicationDate: any | null;
+ isAvailableForPurchase: boolean | null;
+ availableForPurchase: any | null;
+ visibleInListings: boolean;
}
export interface ProductImageCreate_productImageCreate_product_metadata {
@@ -135,30 +126,6 @@ export interface ProductImageCreate_productImageCreate_product_collections {
name: string;
}
-export interface ProductImageCreate_productImageCreate_product_margin {
- __typename: "Margin";
- start: number | null;
- stop: number | null;
-}
-
-export interface ProductImageCreate_productImageCreate_product_purchaseCost_start {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
-export interface ProductImageCreate_productImageCreate_product_purchaseCost_stop {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
-export interface ProductImageCreate_productImageCreate_product_purchaseCost {
- __typename: "MoneyRange";
- start: ProductImageCreate_productImageCreate_product_purchaseCost_start | null;
- stop: ProductImageCreate_productImageCreate_product_purchaseCost_stop | null;
-}
-
export interface ProductImageCreate_productImageCreate_product_images {
__typename: "ProductImage";
id: string;
@@ -167,12 +134,6 @@ export interface ProductImageCreate_productImageCreate_product_images {
url: string;
}
-export interface ProductImageCreate_productImageCreate_product_variants_price {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
export interface ProductImageCreate_productImageCreate_product_variants_stocks_warehouse {
__typename: "Warehouse";
id: string;
@@ -187,15 +148,41 @@ export interface ProductImageCreate_productImageCreate_product_variants_stocks {
warehouse: ProductImageCreate_productImageCreate_product_variants_stocks_warehouse;
}
+export interface ProductImageCreate_productImageCreate_product_variants_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface ProductImageCreate_productImageCreate_product_variants_channelListings_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ProductImageCreate_productImageCreate_product_variants_channelListings_costPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ProductImageCreate_productImageCreate_product_variants_channelListings {
+ __typename: "ProductVariantChannelListing";
+ channel: ProductImageCreate_productImageCreate_product_variants_channelListings_channel;
+ price: ProductImageCreate_productImageCreate_product_variants_channelListings_price | null;
+ costPrice: ProductImageCreate_productImageCreate_product_variants_channelListings_costPrice | null;
+}
+
export interface ProductImageCreate_productImageCreate_product_variants {
__typename: "ProductVariant";
id: string;
sku: string;
name: string;
- price: ProductImageCreate_productImageCreate_product_variants_price | null;
margin: number | null;
stocks: (ProductImageCreate_productImageCreate_product_variants_stocks | null)[] | null;
trackInventory: boolean;
+ channelListings: ProductImageCreate_productImageCreate_product_variants_channelListings[] | null;
}
export interface ProductImageCreate_productImageCreate_product_weight {
@@ -215,7 +202,7 @@ export interface ProductImageCreate_productImageCreate_product {
id: string;
attributes: ProductImageCreate_productImageCreate_product_attributes[];
productType: ProductImageCreate_productImageCreate_product_productType;
- pricing: ProductImageCreate_productImageCreate_product_pricing | null;
+ channelListings: ProductImageCreate_productImageCreate_product_channelListings[] | null;
metadata: (ProductImageCreate_productImageCreate_product_metadata | null)[];
privateMetadata: (ProductImageCreate_productImageCreate_product_privateMetadata | null)[];
name: string;
@@ -226,19 +213,12 @@ export interface ProductImageCreate_productImageCreate_product {
defaultVariant: ProductImageCreate_productImageCreate_product_defaultVariant | null;
category: ProductImageCreate_productImageCreate_product_category | null;
collections: (ProductImageCreate_productImageCreate_product_collections | null)[] | null;
- margin: ProductImageCreate_productImageCreate_product_margin | null;
- purchaseCost: ProductImageCreate_productImageCreate_product_purchaseCost | null;
- isAvailableForPurchase: boolean | null;
- isAvailable: boolean | null;
- isPublished: boolean;
chargeTaxes: boolean;
- publicationDate: any | null;
images: (ProductImageCreate_productImageCreate_product_images | null)[] | null;
+ isAvailable: boolean | null;
variants: (ProductImageCreate_productImageCreate_product_variants | null)[] | null;
weight: ProductImageCreate_productImageCreate_product_weight | null;
taxType: ProductImageCreate_productImageCreate_product_taxType | null;
- availableForPurchase: any | null;
- visibleInListings: boolean;
}
export interface ProductImageCreate_productImageCreate {
diff --git a/src/products/types/ProductImageUpdate.ts b/src/products/types/ProductImageUpdate.ts
index 2df7a1953..b2e8a1c3d 100644
--- a/src/products/types/ProductImageUpdate.ts
+++ b/src/products/types/ProductImageUpdate.ts
@@ -73,37 +73,28 @@ export interface ProductImageUpdate_productImageUpdate_product_productType {
taxType: ProductImageUpdate_productImageUpdate_product_productType_taxType | null;
}
-export interface ProductImageUpdate_productImageUpdate_product_pricing_priceRangeUndiscounted_start_gross {
+export interface ProductImageUpdate_productImageUpdate_product_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface ProductImageUpdate_productImageUpdate_product_channelListings_discountedPrice {
__typename: "Money";
amount: number;
currency: string;
}
-export interface ProductImageUpdate_productImageUpdate_product_pricing_priceRangeUndiscounted_start {
- __typename: "TaxedMoney";
- gross: ProductImageUpdate_productImageUpdate_product_pricing_priceRangeUndiscounted_start_gross;
-}
-
-export interface ProductImageUpdate_productImageUpdate_product_pricing_priceRangeUndiscounted_stop_gross {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
-export interface ProductImageUpdate_productImageUpdate_product_pricing_priceRangeUndiscounted_stop {
- __typename: "TaxedMoney";
- gross: ProductImageUpdate_productImageUpdate_product_pricing_priceRangeUndiscounted_stop_gross;
-}
-
-export interface ProductImageUpdate_productImageUpdate_product_pricing_priceRangeUndiscounted {
- __typename: "TaxedMoneyRange";
- start: ProductImageUpdate_productImageUpdate_product_pricing_priceRangeUndiscounted_start | null;
- stop: ProductImageUpdate_productImageUpdate_product_pricing_priceRangeUndiscounted_stop | null;
-}
-
-export interface ProductImageUpdate_productImageUpdate_product_pricing {
- __typename: "ProductPricingInfo";
- priceRangeUndiscounted: ProductImageUpdate_productImageUpdate_product_pricing_priceRangeUndiscounted | null;
+export interface ProductImageUpdate_productImageUpdate_product_channelListings {
+ __typename: "ProductChannelListing";
+ channel: ProductImageUpdate_productImageUpdate_product_channelListings_channel;
+ discountedPrice: ProductImageUpdate_productImageUpdate_product_channelListings_discountedPrice | null;
+ isPublished: boolean;
+ publicationDate: any | null;
+ isAvailableForPurchase: boolean | null;
+ availableForPurchase: any | null;
+ visibleInListings: boolean;
}
export interface ProductImageUpdate_productImageUpdate_product_metadata {
@@ -135,30 +126,6 @@ export interface ProductImageUpdate_productImageUpdate_product_collections {
name: string;
}
-export interface ProductImageUpdate_productImageUpdate_product_margin {
- __typename: "Margin";
- start: number | null;
- stop: number | null;
-}
-
-export interface ProductImageUpdate_productImageUpdate_product_purchaseCost_start {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
-export interface ProductImageUpdate_productImageUpdate_product_purchaseCost_stop {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
-export interface ProductImageUpdate_productImageUpdate_product_purchaseCost {
- __typename: "MoneyRange";
- start: ProductImageUpdate_productImageUpdate_product_purchaseCost_start | null;
- stop: ProductImageUpdate_productImageUpdate_product_purchaseCost_stop | null;
-}
-
export interface ProductImageUpdate_productImageUpdate_product_images {
__typename: "ProductImage";
id: string;
@@ -167,12 +134,6 @@ export interface ProductImageUpdate_productImageUpdate_product_images {
url: string;
}
-export interface ProductImageUpdate_productImageUpdate_product_variants_price {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
export interface ProductImageUpdate_productImageUpdate_product_variants_stocks_warehouse {
__typename: "Warehouse";
id: string;
@@ -187,15 +148,41 @@ export interface ProductImageUpdate_productImageUpdate_product_variants_stocks {
warehouse: ProductImageUpdate_productImageUpdate_product_variants_stocks_warehouse;
}
+export interface ProductImageUpdate_productImageUpdate_product_variants_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface ProductImageUpdate_productImageUpdate_product_variants_channelListings_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ProductImageUpdate_productImageUpdate_product_variants_channelListings_costPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ProductImageUpdate_productImageUpdate_product_variants_channelListings {
+ __typename: "ProductVariantChannelListing";
+ channel: ProductImageUpdate_productImageUpdate_product_variants_channelListings_channel;
+ price: ProductImageUpdate_productImageUpdate_product_variants_channelListings_price | null;
+ costPrice: ProductImageUpdate_productImageUpdate_product_variants_channelListings_costPrice | null;
+}
+
export interface ProductImageUpdate_productImageUpdate_product_variants {
__typename: "ProductVariant";
id: string;
sku: string;
name: string;
- price: ProductImageUpdate_productImageUpdate_product_variants_price | null;
margin: number | null;
stocks: (ProductImageUpdate_productImageUpdate_product_variants_stocks | null)[] | null;
trackInventory: boolean;
+ channelListings: ProductImageUpdate_productImageUpdate_product_variants_channelListings[] | null;
}
export interface ProductImageUpdate_productImageUpdate_product_weight {
@@ -215,7 +202,7 @@ export interface ProductImageUpdate_productImageUpdate_product {
id: string;
attributes: ProductImageUpdate_productImageUpdate_product_attributes[];
productType: ProductImageUpdate_productImageUpdate_product_productType;
- pricing: ProductImageUpdate_productImageUpdate_product_pricing | null;
+ channelListings: ProductImageUpdate_productImageUpdate_product_channelListings[] | null;
metadata: (ProductImageUpdate_productImageUpdate_product_metadata | null)[];
privateMetadata: (ProductImageUpdate_productImageUpdate_product_privateMetadata | null)[];
name: string;
@@ -226,19 +213,12 @@ export interface ProductImageUpdate_productImageUpdate_product {
defaultVariant: ProductImageUpdate_productImageUpdate_product_defaultVariant | null;
category: ProductImageUpdate_productImageUpdate_product_category | null;
collections: (ProductImageUpdate_productImageUpdate_product_collections | null)[] | null;
- margin: ProductImageUpdate_productImageUpdate_product_margin | null;
- purchaseCost: ProductImageUpdate_productImageUpdate_product_purchaseCost | null;
- isAvailableForPurchase: boolean | null;
- isAvailable: boolean | null;
- isPublished: boolean;
chargeTaxes: boolean;
- publicationDate: any | null;
images: (ProductImageUpdate_productImageUpdate_product_images | null)[] | null;
+ isAvailable: boolean | null;
variants: (ProductImageUpdate_productImageUpdate_product_variants | null)[] | null;
weight: ProductImageUpdate_productImageUpdate_product_weight | null;
taxType: ProductImageUpdate_productImageUpdate_product_taxType | null;
- availableForPurchase: any | null;
- visibleInListings: boolean;
}
export interface ProductImageUpdate_productImageUpdate {
diff --git a/src/products/types/ProductList.ts b/src/products/types/ProductList.ts
index c96e1001a..7dd42074a 100644
--- a/src/products/types/ProductList.ts
+++ b/src/products/types/ProductList.ts
@@ -20,6 +20,30 @@ export interface ProductList_products_edges_node_productType {
hasVariants: boolean;
}
+export interface ProductList_products_edges_node_channelListings_discountedPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ProductList_products_edges_node_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface ProductList_products_edges_node_channelListings {
+ __typename: "ProductChannelListing";
+ isPublished: boolean;
+ publicationDate: any | null;
+ discountedPrice: ProductList_products_edges_node_channelListings_discountedPrice | null;
+ isAvailableForPurchase: boolean | null;
+ availableForPurchase: any | null;
+ visibleInListings: boolean;
+ channel: ProductList_products_edges_node_channelListings_channel;
+}
+
export interface ProductList_products_edges_node_attributes_attribute {
__typename: "Attribute";
id: string;
@@ -37,49 +61,14 @@ export interface ProductList_products_edges_node_attributes {
values: (ProductList_products_edges_node_attributes_values | null)[];
}
-export interface ProductList_products_edges_node_pricing_priceRangeUndiscounted_start_gross {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
-export interface ProductList_products_edges_node_pricing_priceRangeUndiscounted_start {
- __typename: "TaxedMoney";
- gross: ProductList_products_edges_node_pricing_priceRangeUndiscounted_start_gross;
-}
-
-export interface ProductList_products_edges_node_pricing_priceRangeUndiscounted_stop_gross {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
-export interface ProductList_products_edges_node_pricing_priceRangeUndiscounted_stop {
- __typename: "TaxedMoney";
- gross: ProductList_products_edges_node_pricing_priceRangeUndiscounted_stop_gross;
-}
-
-export interface ProductList_products_edges_node_pricing_priceRangeUndiscounted {
- __typename: "TaxedMoneyRange";
- start: ProductList_products_edges_node_pricing_priceRangeUndiscounted_start | null;
- stop: ProductList_products_edges_node_pricing_priceRangeUndiscounted_stop | null;
-}
-
-export interface ProductList_products_edges_node_pricing {
- __typename: "ProductPricingInfo";
- priceRangeUndiscounted: ProductList_products_edges_node_pricing_priceRangeUndiscounted | null;
-}
-
export interface ProductList_products_edges_node {
__typename: "Product";
id: string;
name: string;
thumbnail: ProductList_products_edges_node_thumbnail | null;
- isAvailable: boolean | null;
- isPublished: boolean;
productType: ProductList_products_edges_node_productType;
+ channelListings: ProductList_products_edges_node_channelListings[] | null;
attributes: ProductList_products_edges_node_attributes[];
- pricing: ProductList_products_edges_node_pricing | null;
}
export interface ProductList_products_edges {
diff --git a/src/products/types/ProductUpdate.ts b/src/products/types/ProductUpdate.ts
index db1c2a1d9..378008e24 100644
--- a/src/products/types/ProductUpdate.ts
+++ b/src/products/types/ProductUpdate.ts
@@ -74,37 +74,28 @@ export interface ProductUpdate_productUpdate_product_productType {
taxType: ProductUpdate_productUpdate_product_productType_taxType | null;
}
-export interface ProductUpdate_productUpdate_product_pricing_priceRangeUndiscounted_start_gross {
+export interface ProductUpdate_productUpdate_product_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface ProductUpdate_productUpdate_product_channelListings_discountedPrice {
__typename: "Money";
amount: number;
currency: string;
}
-export interface ProductUpdate_productUpdate_product_pricing_priceRangeUndiscounted_start {
- __typename: "TaxedMoney";
- gross: ProductUpdate_productUpdate_product_pricing_priceRangeUndiscounted_start_gross;
-}
-
-export interface ProductUpdate_productUpdate_product_pricing_priceRangeUndiscounted_stop_gross {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
-export interface ProductUpdate_productUpdate_product_pricing_priceRangeUndiscounted_stop {
- __typename: "TaxedMoney";
- gross: ProductUpdate_productUpdate_product_pricing_priceRangeUndiscounted_stop_gross;
-}
-
-export interface ProductUpdate_productUpdate_product_pricing_priceRangeUndiscounted {
- __typename: "TaxedMoneyRange";
- start: ProductUpdate_productUpdate_product_pricing_priceRangeUndiscounted_start | null;
- stop: ProductUpdate_productUpdate_product_pricing_priceRangeUndiscounted_stop | null;
-}
-
-export interface ProductUpdate_productUpdate_product_pricing {
- __typename: "ProductPricingInfo";
- priceRangeUndiscounted: ProductUpdate_productUpdate_product_pricing_priceRangeUndiscounted | null;
+export interface ProductUpdate_productUpdate_product_channelListings {
+ __typename: "ProductChannelListing";
+ channel: ProductUpdate_productUpdate_product_channelListings_channel;
+ discountedPrice: ProductUpdate_productUpdate_product_channelListings_discountedPrice | null;
+ isPublished: boolean;
+ publicationDate: any | null;
+ isAvailableForPurchase: boolean | null;
+ availableForPurchase: any | null;
+ visibleInListings: boolean;
}
export interface ProductUpdate_productUpdate_product_metadata {
@@ -136,30 +127,6 @@ export interface ProductUpdate_productUpdate_product_collections {
name: string;
}
-export interface ProductUpdate_productUpdate_product_margin {
- __typename: "Margin";
- start: number | null;
- stop: number | null;
-}
-
-export interface ProductUpdate_productUpdate_product_purchaseCost_start {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
-export interface ProductUpdate_productUpdate_product_purchaseCost_stop {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
-export interface ProductUpdate_productUpdate_product_purchaseCost {
- __typename: "MoneyRange";
- start: ProductUpdate_productUpdate_product_purchaseCost_start | null;
- stop: ProductUpdate_productUpdate_product_purchaseCost_stop | null;
-}
-
export interface ProductUpdate_productUpdate_product_images {
__typename: "ProductImage";
id: string;
@@ -168,12 +135,6 @@ export interface ProductUpdate_productUpdate_product_images {
url: string;
}
-export interface ProductUpdate_productUpdate_product_variants_price {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
export interface ProductUpdate_productUpdate_product_variants_stocks_warehouse {
__typename: "Warehouse";
id: string;
@@ -188,15 +149,41 @@ export interface ProductUpdate_productUpdate_product_variants_stocks {
warehouse: ProductUpdate_productUpdate_product_variants_stocks_warehouse;
}
+export interface ProductUpdate_productUpdate_product_variants_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface ProductUpdate_productUpdate_product_variants_channelListings_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ProductUpdate_productUpdate_product_variants_channelListings_costPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ProductUpdate_productUpdate_product_variants_channelListings {
+ __typename: "ProductVariantChannelListing";
+ channel: ProductUpdate_productUpdate_product_variants_channelListings_channel;
+ price: ProductUpdate_productUpdate_product_variants_channelListings_price | null;
+ costPrice: ProductUpdate_productUpdate_product_variants_channelListings_costPrice | null;
+}
+
export interface ProductUpdate_productUpdate_product_variants {
__typename: "ProductVariant";
id: string;
sku: string;
name: string;
- price: ProductUpdate_productUpdate_product_variants_price | null;
margin: number | null;
stocks: (ProductUpdate_productUpdate_product_variants_stocks | null)[] | null;
trackInventory: boolean;
+ channelListings: ProductUpdate_productUpdate_product_variants_channelListings[] | null;
}
export interface ProductUpdate_productUpdate_product_weight {
@@ -216,7 +203,7 @@ export interface ProductUpdate_productUpdate_product {
id: string;
attributes: ProductUpdate_productUpdate_product_attributes[];
productType: ProductUpdate_productUpdate_product_productType;
- pricing: ProductUpdate_productUpdate_product_pricing | null;
+ channelListings: ProductUpdate_productUpdate_product_channelListings[] | null;
metadata: (ProductUpdate_productUpdate_product_metadata | null)[];
privateMetadata: (ProductUpdate_productUpdate_product_privateMetadata | null)[];
name: string;
@@ -227,19 +214,12 @@ export interface ProductUpdate_productUpdate_product {
defaultVariant: ProductUpdate_productUpdate_product_defaultVariant | null;
category: ProductUpdate_productUpdate_product_category | null;
collections: (ProductUpdate_productUpdate_product_collections | null)[] | null;
- margin: ProductUpdate_productUpdate_product_margin | null;
- purchaseCost: ProductUpdate_productUpdate_product_purchaseCost | null;
- isAvailableForPurchase: boolean | null;
- isAvailable: boolean | null;
- isPublished: boolean;
chargeTaxes: boolean;
- publicationDate: any | null;
images: (ProductUpdate_productUpdate_product_images | null)[] | null;
+ isAvailable: boolean | null;
variants: (ProductUpdate_productUpdate_product_variants | null)[] | null;
weight: ProductUpdate_productUpdate_product_weight | null;
taxType: ProductUpdate_productUpdate_product_taxType | null;
- availableForPurchase: any | null;
- visibleInListings: boolean;
}
export interface ProductUpdate_productUpdate {
diff --git a/src/products/types/ProductVariantBulkCreate.ts b/src/products/types/ProductVariantBulkCreate.ts
index 2dc8867e6..ee3603eb8 100644
--- a/src/products/types/ProductVariantBulkCreate.ts
+++ b/src/products/types/ProductVariantBulkCreate.ts
@@ -13,6 +13,7 @@ export interface ProductVariantBulkCreate_productVariantBulkCreate_errors {
field: string | null;
code: ProductErrorCode;
index: number | null;
+ channels: string[] | null;
}
export interface ProductVariantBulkCreate_productVariantBulkCreate {
diff --git a/src/products/types/ProductVariantChannelListingUpdate.ts b/src/products/types/ProductVariantChannelListingUpdate.ts
new file mode 100644
index 000000000..5addf30e6
--- /dev/null
+++ b/src/products/types/ProductVariantChannelListingUpdate.ts
@@ -0,0 +1,203 @@
+/* tslint:disable */
+/* eslint-disable */
+// This file was automatically generated and should not be edited.
+
+import { ProductVariantChannelListingAddInput, WeightUnitsEnum, ProductErrorCode } from "./../../types/globalTypes";
+
+// ====================================================
+// GraphQL mutation operation: ProductVariantChannelListingUpdate
+// ====================================================
+
+export interface ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_metadata {
+ __typename: "MetadataItem";
+ key: string;
+ value: string;
+}
+
+export interface ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_privateMetadata {
+ __typename: "MetadataItem";
+ key: string;
+ value: string;
+}
+
+export interface ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_attributes_attribute_values {
+ __typename: "AttributeValue";
+ id: string;
+ name: string | null;
+ slug: string | null;
+}
+
+export interface ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_attributes_attribute {
+ __typename: "Attribute";
+ id: string;
+ name: string | null;
+ slug: string | null;
+ valueRequired: boolean;
+ values: (ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_attributes_attribute_values | null)[] | null;
+}
+
+export interface ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_attributes_values {
+ __typename: "AttributeValue";
+ id: string;
+ name: string | null;
+ slug: string | null;
+}
+
+export interface ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_attributes {
+ __typename: "SelectedAttribute";
+ attribute: ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_attributes_attribute;
+ values: (ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_attributes_values | null)[];
+}
+
+export interface ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_images {
+ __typename: "ProductImage";
+ id: string;
+ url: string;
+}
+
+export interface ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_product_defaultVariant {
+ __typename: "ProductVariant";
+ id: string;
+}
+
+export interface ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_product_images {
+ __typename: "ProductImage";
+ id: string;
+ alt: string;
+ sortOrder: number | null;
+ url: string;
+}
+
+export interface ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_product_thumbnail {
+ __typename: "Image";
+ url: string;
+}
+
+export interface ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_product_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_product_channelListings_discountedPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_product_channelListings {
+ __typename: "ProductChannelListing";
+ channel: ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_product_channelListings_channel;
+ discountedPrice: ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_product_channelListings_discountedPrice | null;
+}
+
+export interface ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_product_variants_images {
+ __typename: "ProductImage";
+ id: string;
+ url: string;
+}
+
+export interface ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_product_variants {
+ __typename: "ProductVariant";
+ id: string;
+ name: string;
+ sku: string;
+ images: (ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_product_variants_images | null)[] | null;
+}
+
+export interface ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_product {
+ __typename: "Product";
+ id: string;
+ defaultVariant: ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_product_defaultVariant | null;
+ images: (ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_product_images | null)[] | null;
+ name: string;
+ thumbnail: ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_product_thumbnail | null;
+ channelListings: ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_product_channelListings[] | null;
+ variants: (ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_product_variants | null)[] | null;
+}
+
+export interface ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_channelListings_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_channelListings_costPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_channelListings {
+ __typename: "ProductVariantChannelListing";
+ channel: ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_channelListings_channel;
+ price: ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_channelListings_price | null;
+ costPrice: ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_channelListings_costPrice | null;
+}
+
+export interface ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_stocks_warehouse {
+ __typename: "Warehouse";
+ id: string;
+ name: string;
+}
+
+export interface ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_stocks {
+ __typename: "Stock";
+ id: string;
+ quantity: number;
+ quantityAllocated: number;
+ warehouse: ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_stocks_warehouse;
+}
+
+export interface ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_weight {
+ __typename: "Weight";
+ unit: WeightUnitsEnum;
+ value: number;
+}
+
+export interface ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant {
+ __typename: "ProductVariant";
+ id: string;
+ metadata: (ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_metadata | null)[];
+ privateMetadata: (ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_privateMetadata | null)[];
+ attributes: ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_attributes[];
+ images: (ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_images | null)[] | null;
+ name: string;
+ product: ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_product;
+ channelListings: ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_channelListings[] | null;
+ sku: string;
+ stocks: (ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_stocks | null)[] | null;
+ trackInventory: boolean;
+ weight: ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant_weight | null;
+}
+
+export interface ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_errors {
+ __typename: "ProductChannelListingError";
+ code: ProductErrorCode;
+ field: string | null;
+ message: string | null;
+ channels: string[] | null;
+}
+
+export interface ProductVariantChannelListingUpdate_productVariantChannelListingUpdate {
+ __typename: "ProductVariantChannelListingUpdate";
+ variant: ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_variant | null;
+ errors: ProductVariantChannelListingUpdate_productVariantChannelListingUpdate_errors[];
+}
+
+export interface ProductVariantChannelListingUpdate {
+ productVariantChannelListingUpdate: ProductVariantChannelListingUpdate_productVariantChannelListingUpdate | null;
+}
+
+export interface ProductVariantChannelListingUpdateVariables {
+ id: string;
+ input: ProductVariantChannelListingAddInput[];
+}
diff --git a/src/products/types/ProductVariantCreateData.ts b/src/products/types/ProductVariantCreateData.ts
index 248ec0fe1..55a8638d1 100644
--- a/src/products/types/ProductVariantCreateData.ts
+++ b/src/products/types/ProductVariantCreateData.ts
@@ -13,6 +13,18 @@ export interface ProductVariantCreateData_product_images {
url: string;
}
+export interface ProductVariantCreateData_product_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface ProductVariantCreateData_product_channelListings {
+ __typename: "ProductChannelListing";
+ channel: ProductVariantCreateData_product_channelListings_channel;
+}
+
export interface ProductVariantCreateData_product_productType_variantAttributes_values {
__typename: "AttributeValue";
id: string;
@@ -58,6 +70,7 @@ export interface ProductVariantCreateData_product {
__typename: "Product";
id: string;
images: (ProductVariantCreateData_product_images | null)[] | null;
+ channelListings: ProductVariantCreateData_product_channelListings[] | null;
name: string;
productType: ProductVariantCreateData_product_productType;
thumbnail: ProductVariantCreateData_product_thumbnail | null;
diff --git a/src/products/types/ProductVariantDetails.ts b/src/products/types/ProductVariantDetails.ts
index 7227a7405..25e72981e 100644
--- a/src/products/types/ProductVariantDetails.ts
+++ b/src/products/types/ProductVariantDetails.ts
@@ -49,24 +49,12 @@ export interface ProductVariantDetails_productVariant_attributes {
values: (ProductVariantDetails_productVariant_attributes_values | null)[];
}
-export interface ProductVariantDetails_productVariant_costPrice {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
export interface ProductVariantDetails_productVariant_images {
__typename: "ProductImage";
id: string;
url: string;
}
-export interface ProductVariantDetails_productVariant_price {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
export interface ProductVariantDetails_productVariant_product_defaultVariant {
__typename: "ProductVariant";
id: string;
@@ -85,6 +73,25 @@ export interface ProductVariantDetails_productVariant_product_thumbnail {
url: string;
}
+export interface ProductVariantDetails_productVariant_product_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface ProductVariantDetails_productVariant_product_channelListings_discountedPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ProductVariantDetails_productVariant_product_channelListings {
+ __typename: "ProductChannelListing";
+ channel: ProductVariantDetails_productVariant_product_channelListings_channel;
+ discountedPrice: ProductVariantDetails_productVariant_product_channelListings_discountedPrice | null;
+}
+
export interface ProductVariantDetails_productVariant_product_variants_images {
__typename: "ProductImage";
id: string;
@@ -106,9 +113,36 @@ export interface ProductVariantDetails_productVariant_product {
images: (ProductVariantDetails_productVariant_product_images | null)[] | null;
name: string;
thumbnail: ProductVariantDetails_productVariant_product_thumbnail | null;
+ channelListings: ProductVariantDetails_productVariant_product_channelListings[] | null;
variants: (ProductVariantDetails_productVariant_product_variants | null)[] | null;
}
+export interface ProductVariantDetails_productVariant_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface ProductVariantDetails_productVariant_channelListings_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ProductVariantDetails_productVariant_channelListings_costPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ProductVariantDetails_productVariant_channelListings {
+ __typename: "ProductVariantChannelListing";
+ channel: ProductVariantDetails_productVariant_channelListings_channel;
+ price: ProductVariantDetails_productVariant_channelListings_price | null;
+ costPrice: ProductVariantDetails_productVariant_channelListings_costPrice | null;
+}
+
export interface ProductVariantDetails_productVariant_stocks_warehouse {
__typename: "Warehouse";
id: string;
@@ -135,11 +169,10 @@ export interface ProductVariantDetails_productVariant {
metadata: (ProductVariantDetails_productVariant_metadata | null)[];
privateMetadata: (ProductVariantDetails_productVariant_privateMetadata | null)[];
attributes: ProductVariantDetails_productVariant_attributes[];
- costPrice: ProductVariantDetails_productVariant_costPrice | null;
images: (ProductVariantDetails_productVariant_images | null)[] | null;
name: string;
- price: ProductVariantDetails_productVariant_price | null;
product: ProductVariantDetails_productVariant_product;
+ channelListings: ProductVariantDetails_productVariant_channelListings[] | null;
sku: string;
stocks: (ProductVariantDetails_productVariant_stocks | null)[] | null;
trackInventory: boolean;
diff --git a/src/products/types/ProductVariantReorder.ts b/src/products/types/ProductVariantReorder.ts
index 1870dd9c6..7fc8b77c2 100644
--- a/src/products/types/ProductVariantReorder.ts
+++ b/src/products/types/ProductVariantReorder.ts
@@ -73,37 +73,28 @@ export interface ProductVariantReorder_productVariantReorder_product_productType
taxType: ProductVariantReorder_productVariantReorder_product_productType_taxType | null;
}
-export interface ProductVariantReorder_productVariantReorder_product_pricing_priceRangeUndiscounted_start_gross {
+export interface ProductVariantReorder_productVariantReorder_product_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface ProductVariantReorder_productVariantReorder_product_channelListings_discountedPrice {
__typename: "Money";
amount: number;
currency: string;
}
-export interface ProductVariantReorder_productVariantReorder_product_pricing_priceRangeUndiscounted_start {
- __typename: "TaxedMoney";
- gross: ProductVariantReorder_productVariantReorder_product_pricing_priceRangeUndiscounted_start_gross;
-}
-
-export interface ProductVariantReorder_productVariantReorder_product_pricing_priceRangeUndiscounted_stop_gross {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
-export interface ProductVariantReorder_productVariantReorder_product_pricing_priceRangeUndiscounted_stop {
- __typename: "TaxedMoney";
- gross: ProductVariantReorder_productVariantReorder_product_pricing_priceRangeUndiscounted_stop_gross;
-}
-
-export interface ProductVariantReorder_productVariantReorder_product_pricing_priceRangeUndiscounted {
- __typename: "TaxedMoneyRange";
- start: ProductVariantReorder_productVariantReorder_product_pricing_priceRangeUndiscounted_start | null;
- stop: ProductVariantReorder_productVariantReorder_product_pricing_priceRangeUndiscounted_stop | null;
-}
-
-export interface ProductVariantReorder_productVariantReorder_product_pricing {
- __typename: "ProductPricingInfo";
- priceRangeUndiscounted: ProductVariantReorder_productVariantReorder_product_pricing_priceRangeUndiscounted | null;
+export interface ProductVariantReorder_productVariantReorder_product_channelListings {
+ __typename: "ProductChannelListing";
+ channel: ProductVariantReorder_productVariantReorder_product_channelListings_channel;
+ discountedPrice: ProductVariantReorder_productVariantReorder_product_channelListings_discountedPrice | null;
+ isPublished: boolean;
+ publicationDate: any | null;
+ isAvailableForPurchase: boolean | null;
+ availableForPurchase: any | null;
+ visibleInListings: boolean;
}
export interface ProductVariantReorder_productVariantReorder_product_metadata {
@@ -135,30 +126,6 @@ export interface ProductVariantReorder_productVariantReorder_product_collections
name: string;
}
-export interface ProductVariantReorder_productVariantReorder_product_margin {
- __typename: "Margin";
- start: number | null;
- stop: number | null;
-}
-
-export interface ProductVariantReorder_productVariantReorder_product_purchaseCost_start {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
-export interface ProductVariantReorder_productVariantReorder_product_purchaseCost_stop {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
-export interface ProductVariantReorder_productVariantReorder_product_purchaseCost {
- __typename: "MoneyRange";
- start: ProductVariantReorder_productVariantReorder_product_purchaseCost_start | null;
- stop: ProductVariantReorder_productVariantReorder_product_purchaseCost_stop | null;
-}
-
export interface ProductVariantReorder_productVariantReorder_product_images {
__typename: "ProductImage";
id: string;
@@ -167,12 +134,6 @@ export interface ProductVariantReorder_productVariantReorder_product_images {
url: string;
}
-export interface ProductVariantReorder_productVariantReorder_product_variants_price {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
export interface ProductVariantReorder_productVariantReorder_product_variants_stocks_warehouse {
__typename: "Warehouse";
id: string;
@@ -187,15 +148,41 @@ export interface ProductVariantReorder_productVariantReorder_product_variants_st
warehouse: ProductVariantReorder_productVariantReorder_product_variants_stocks_warehouse;
}
+export interface ProductVariantReorder_productVariantReorder_product_variants_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface ProductVariantReorder_productVariantReorder_product_variants_channelListings_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ProductVariantReorder_productVariantReorder_product_variants_channelListings_costPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ProductVariantReorder_productVariantReorder_product_variants_channelListings {
+ __typename: "ProductVariantChannelListing";
+ channel: ProductVariantReorder_productVariantReorder_product_variants_channelListings_channel;
+ price: ProductVariantReorder_productVariantReorder_product_variants_channelListings_price | null;
+ costPrice: ProductVariantReorder_productVariantReorder_product_variants_channelListings_costPrice | null;
+}
+
export interface ProductVariantReorder_productVariantReorder_product_variants {
__typename: "ProductVariant";
id: string;
sku: string;
name: string;
- price: ProductVariantReorder_productVariantReorder_product_variants_price | null;
margin: number | null;
stocks: (ProductVariantReorder_productVariantReorder_product_variants_stocks | null)[] | null;
trackInventory: boolean;
+ channelListings: ProductVariantReorder_productVariantReorder_product_variants_channelListings[] | null;
}
export interface ProductVariantReorder_productVariantReorder_product_weight {
@@ -215,7 +202,7 @@ export interface ProductVariantReorder_productVariantReorder_product {
id: string;
attributes: ProductVariantReorder_productVariantReorder_product_attributes[];
productType: ProductVariantReorder_productVariantReorder_product_productType;
- pricing: ProductVariantReorder_productVariantReorder_product_pricing | null;
+ channelListings: ProductVariantReorder_productVariantReorder_product_channelListings[] | null;
metadata: (ProductVariantReorder_productVariantReorder_product_metadata | null)[];
privateMetadata: (ProductVariantReorder_productVariantReorder_product_privateMetadata | null)[];
name: string;
@@ -226,19 +213,12 @@ export interface ProductVariantReorder_productVariantReorder_product {
defaultVariant: ProductVariantReorder_productVariantReorder_product_defaultVariant | null;
category: ProductVariantReorder_productVariantReorder_product_category | null;
collections: (ProductVariantReorder_productVariantReorder_product_collections | null)[] | null;
- margin: ProductVariantReorder_productVariantReorder_product_margin | null;
- purchaseCost: ProductVariantReorder_productVariantReorder_product_purchaseCost | null;
- isAvailableForPurchase: boolean | null;
- isAvailable: boolean | null;
- isPublished: boolean;
chargeTaxes: boolean;
- publicationDate: any | null;
images: (ProductVariantReorder_productVariantReorder_product_images | null)[] | null;
+ isAvailable: boolean | null;
variants: (ProductVariantReorder_productVariantReorder_product_variants | null)[] | null;
weight: ProductVariantReorder_productVariantReorder_product_weight | null;
taxType: ProductVariantReorder_productVariantReorder_product_taxType | null;
- availableForPurchase: any | null;
- visibleInListings: boolean;
}
export interface ProductVariantReorder_productVariantReorder {
diff --git a/src/products/types/ProductVariantSetDefault.ts b/src/products/types/ProductVariantSetDefault.ts
index 2448d3574..1b765a784 100644
--- a/src/products/types/ProductVariantSetDefault.ts
+++ b/src/products/types/ProductVariantSetDefault.ts
@@ -73,37 +73,28 @@ export interface ProductVariantSetDefault_productVariantSetDefault_product_produ
taxType: ProductVariantSetDefault_productVariantSetDefault_product_productType_taxType | null;
}
-export interface ProductVariantSetDefault_productVariantSetDefault_product_pricing_priceRangeUndiscounted_start_gross {
+export interface ProductVariantSetDefault_productVariantSetDefault_product_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface ProductVariantSetDefault_productVariantSetDefault_product_channelListings_discountedPrice {
__typename: "Money";
amount: number;
currency: string;
}
-export interface ProductVariantSetDefault_productVariantSetDefault_product_pricing_priceRangeUndiscounted_start {
- __typename: "TaxedMoney";
- gross: ProductVariantSetDefault_productVariantSetDefault_product_pricing_priceRangeUndiscounted_start_gross;
-}
-
-export interface ProductVariantSetDefault_productVariantSetDefault_product_pricing_priceRangeUndiscounted_stop_gross {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
-export interface ProductVariantSetDefault_productVariantSetDefault_product_pricing_priceRangeUndiscounted_stop {
- __typename: "TaxedMoney";
- gross: ProductVariantSetDefault_productVariantSetDefault_product_pricing_priceRangeUndiscounted_stop_gross;
-}
-
-export interface ProductVariantSetDefault_productVariantSetDefault_product_pricing_priceRangeUndiscounted {
- __typename: "TaxedMoneyRange";
- start: ProductVariantSetDefault_productVariantSetDefault_product_pricing_priceRangeUndiscounted_start | null;
- stop: ProductVariantSetDefault_productVariantSetDefault_product_pricing_priceRangeUndiscounted_stop | null;
-}
-
-export interface ProductVariantSetDefault_productVariantSetDefault_product_pricing {
- __typename: "ProductPricingInfo";
- priceRangeUndiscounted: ProductVariantSetDefault_productVariantSetDefault_product_pricing_priceRangeUndiscounted | null;
+export interface ProductVariantSetDefault_productVariantSetDefault_product_channelListings {
+ __typename: "ProductChannelListing";
+ channel: ProductVariantSetDefault_productVariantSetDefault_product_channelListings_channel;
+ discountedPrice: ProductVariantSetDefault_productVariantSetDefault_product_channelListings_discountedPrice | null;
+ isPublished: boolean;
+ publicationDate: any | null;
+ isAvailableForPurchase: boolean | null;
+ availableForPurchase: any | null;
+ visibleInListings: boolean;
}
export interface ProductVariantSetDefault_productVariantSetDefault_product_metadata {
@@ -135,30 +126,6 @@ export interface ProductVariantSetDefault_productVariantSetDefault_product_colle
name: string;
}
-export interface ProductVariantSetDefault_productVariantSetDefault_product_margin {
- __typename: "Margin";
- start: number | null;
- stop: number | null;
-}
-
-export interface ProductVariantSetDefault_productVariantSetDefault_product_purchaseCost_start {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
-export interface ProductVariantSetDefault_productVariantSetDefault_product_purchaseCost_stop {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
-export interface ProductVariantSetDefault_productVariantSetDefault_product_purchaseCost {
- __typename: "MoneyRange";
- start: ProductVariantSetDefault_productVariantSetDefault_product_purchaseCost_start | null;
- stop: ProductVariantSetDefault_productVariantSetDefault_product_purchaseCost_stop | null;
-}
-
export interface ProductVariantSetDefault_productVariantSetDefault_product_images {
__typename: "ProductImage";
id: string;
@@ -167,12 +134,6 @@ export interface ProductVariantSetDefault_productVariantSetDefault_product_image
url: string;
}
-export interface ProductVariantSetDefault_productVariantSetDefault_product_variants_price {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
export interface ProductVariantSetDefault_productVariantSetDefault_product_variants_stocks_warehouse {
__typename: "Warehouse";
id: string;
@@ -187,15 +148,41 @@ export interface ProductVariantSetDefault_productVariantSetDefault_product_varia
warehouse: ProductVariantSetDefault_productVariantSetDefault_product_variants_stocks_warehouse;
}
+export interface ProductVariantSetDefault_productVariantSetDefault_product_variants_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface ProductVariantSetDefault_productVariantSetDefault_product_variants_channelListings_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ProductVariantSetDefault_productVariantSetDefault_product_variants_channelListings_costPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ProductVariantSetDefault_productVariantSetDefault_product_variants_channelListings {
+ __typename: "ProductVariantChannelListing";
+ channel: ProductVariantSetDefault_productVariantSetDefault_product_variants_channelListings_channel;
+ price: ProductVariantSetDefault_productVariantSetDefault_product_variants_channelListings_price | null;
+ costPrice: ProductVariantSetDefault_productVariantSetDefault_product_variants_channelListings_costPrice | null;
+}
+
export interface ProductVariantSetDefault_productVariantSetDefault_product_variants {
__typename: "ProductVariant";
id: string;
sku: string;
name: string;
- price: ProductVariantSetDefault_productVariantSetDefault_product_variants_price | null;
margin: number | null;
stocks: (ProductVariantSetDefault_productVariantSetDefault_product_variants_stocks | null)[] | null;
trackInventory: boolean;
+ channelListings: ProductVariantSetDefault_productVariantSetDefault_product_variants_channelListings[] | null;
}
export interface ProductVariantSetDefault_productVariantSetDefault_product_weight {
@@ -215,7 +202,7 @@ export interface ProductVariantSetDefault_productVariantSetDefault_product {
id: string;
attributes: ProductVariantSetDefault_productVariantSetDefault_product_attributes[];
productType: ProductVariantSetDefault_productVariantSetDefault_product_productType;
- pricing: ProductVariantSetDefault_productVariantSetDefault_product_pricing | null;
+ channelListings: ProductVariantSetDefault_productVariantSetDefault_product_channelListings[] | null;
metadata: (ProductVariantSetDefault_productVariantSetDefault_product_metadata | null)[];
privateMetadata: (ProductVariantSetDefault_productVariantSetDefault_product_privateMetadata | null)[];
name: string;
@@ -226,19 +213,12 @@ export interface ProductVariantSetDefault_productVariantSetDefault_product {
defaultVariant: ProductVariantSetDefault_productVariantSetDefault_product_defaultVariant | null;
category: ProductVariantSetDefault_productVariantSetDefault_product_category | null;
collections: (ProductVariantSetDefault_productVariantSetDefault_product_collections | null)[] | null;
- margin: ProductVariantSetDefault_productVariantSetDefault_product_margin | null;
- purchaseCost: ProductVariantSetDefault_productVariantSetDefault_product_purchaseCost | null;
- isAvailableForPurchase: boolean | null;
- isAvailable: boolean | null;
- isPublished: boolean;
chargeTaxes: boolean;
- publicationDate: any | null;
images: (ProductVariantSetDefault_productVariantSetDefault_product_images | null)[] | null;
+ isAvailable: boolean | null;
variants: (ProductVariantSetDefault_productVariantSetDefault_product_variants | null)[] | null;
weight: ProductVariantSetDefault_productVariantSetDefault_product_weight | null;
taxType: ProductVariantSetDefault_productVariantSetDefault_product_taxType | null;
- availableForPurchase: any | null;
- visibleInListings: boolean;
}
export interface ProductVariantSetDefault_productVariantSetDefault {
diff --git a/src/products/types/SimpleProductUpdate.ts b/src/products/types/SimpleProductUpdate.ts
index b0c1a04d3..aebfc4f61 100644
--- a/src/products/types/SimpleProductUpdate.ts
+++ b/src/products/types/SimpleProductUpdate.ts
@@ -74,37 +74,28 @@ export interface SimpleProductUpdate_productUpdate_product_productType {
taxType: SimpleProductUpdate_productUpdate_product_productType_taxType | null;
}
-export interface SimpleProductUpdate_productUpdate_product_pricing_priceRangeUndiscounted_start_gross {
+export interface SimpleProductUpdate_productUpdate_product_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface SimpleProductUpdate_productUpdate_product_channelListings_discountedPrice {
__typename: "Money";
amount: number;
currency: string;
}
-export interface SimpleProductUpdate_productUpdate_product_pricing_priceRangeUndiscounted_start {
- __typename: "TaxedMoney";
- gross: SimpleProductUpdate_productUpdate_product_pricing_priceRangeUndiscounted_start_gross;
-}
-
-export interface SimpleProductUpdate_productUpdate_product_pricing_priceRangeUndiscounted_stop_gross {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
-export interface SimpleProductUpdate_productUpdate_product_pricing_priceRangeUndiscounted_stop {
- __typename: "TaxedMoney";
- gross: SimpleProductUpdate_productUpdate_product_pricing_priceRangeUndiscounted_stop_gross;
-}
-
-export interface SimpleProductUpdate_productUpdate_product_pricing_priceRangeUndiscounted {
- __typename: "TaxedMoneyRange";
- start: SimpleProductUpdate_productUpdate_product_pricing_priceRangeUndiscounted_start | null;
- stop: SimpleProductUpdate_productUpdate_product_pricing_priceRangeUndiscounted_stop | null;
-}
-
-export interface SimpleProductUpdate_productUpdate_product_pricing {
- __typename: "ProductPricingInfo";
- priceRangeUndiscounted: SimpleProductUpdate_productUpdate_product_pricing_priceRangeUndiscounted | null;
+export interface SimpleProductUpdate_productUpdate_product_channelListings {
+ __typename: "ProductChannelListing";
+ channel: SimpleProductUpdate_productUpdate_product_channelListings_channel;
+ discountedPrice: SimpleProductUpdate_productUpdate_product_channelListings_discountedPrice | null;
+ isPublished: boolean;
+ publicationDate: any | null;
+ isAvailableForPurchase: boolean | null;
+ availableForPurchase: any | null;
+ visibleInListings: boolean;
}
export interface SimpleProductUpdate_productUpdate_product_metadata {
@@ -136,30 +127,6 @@ export interface SimpleProductUpdate_productUpdate_product_collections {
name: string;
}
-export interface SimpleProductUpdate_productUpdate_product_margin {
- __typename: "Margin";
- start: number | null;
- stop: number | null;
-}
-
-export interface SimpleProductUpdate_productUpdate_product_purchaseCost_start {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
-export interface SimpleProductUpdate_productUpdate_product_purchaseCost_stop {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
-export interface SimpleProductUpdate_productUpdate_product_purchaseCost {
- __typename: "MoneyRange";
- start: SimpleProductUpdate_productUpdate_product_purchaseCost_start | null;
- stop: SimpleProductUpdate_productUpdate_product_purchaseCost_stop | null;
-}
-
export interface SimpleProductUpdate_productUpdate_product_images {
__typename: "ProductImage";
id: string;
@@ -168,12 +135,6 @@ export interface SimpleProductUpdate_productUpdate_product_images {
url: string;
}
-export interface SimpleProductUpdate_productUpdate_product_variants_price {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
export interface SimpleProductUpdate_productUpdate_product_variants_stocks_warehouse {
__typename: "Warehouse";
id: string;
@@ -188,15 +149,41 @@ export interface SimpleProductUpdate_productUpdate_product_variants_stocks {
warehouse: SimpleProductUpdate_productUpdate_product_variants_stocks_warehouse;
}
+export interface SimpleProductUpdate_productUpdate_product_variants_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface SimpleProductUpdate_productUpdate_product_variants_channelListings_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface SimpleProductUpdate_productUpdate_product_variants_channelListings_costPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface SimpleProductUpdate_productUpdate_product_variants_channelListings {
+ __typename: "ProductVariantChannelListing";
+ channel: SimpleProductUpdate_productUpdate_product_variants_channelListings_channel;
+ price: SimpleProductUpdate_productUpdate_product_variants_channelListings_price | null;
+ costPrice: SimpleProductUpdate_productUpdate_product_variants_channelListings_costPrice | null;
+}
+
export interface SimpleProductUpdate_productUpdate_product_variants {
__typename: "ProductVariant";
id: string;
sku: string;
name: string;
- price: SimpleProductUpdate_productUpdate_product_variants_price | null;
margin: number | null;
stocks: (SimpleProductUpdate_productUpdate_product_variants_stocks | null)[] | null;
trackInventory: boolean;
+ channelListings: SimpleProductUpdate_productUpdate_product_variants_channelListings[] | null;
}
export interface SimpleProductUpdate_productUpdate_product_weight {
@@ -216,7 +203,7 @@ export interface SimpleProductUpdate_productUpdate_product {
id: string;
attributes: SimpleProductUpdate_productUpdate_product_attributes[];
productType: SimpleProductUpdate_productUpdate_product_productType;
- pricing: SimpleProductUpdate_productUpdate_product_pricing | null;
+ channelListings: SimpleProductUpdate_productUpdate_product_channelListings[] | null;
metadata: (SimpleProductUpdate_productUpdate_product_metadata | null)[];
privateMetadata: (SimpleProductUpdate_productUpdate_product_privateMetadata | null)[];
name: string;
@@ -227,19 +214,12 @@ export interface SimpleProductUpdate_productUpdate_product {
defaultVariant: SimpleProductUpdate_productUpdate_product_defaultVariant | null;
category: SimpleProductUpdate_productUpdate_product_category | null;
collections: (SimpleProductUpdate_productUpdate_product_collections | null)[] | null;
- margin: SimpleProductUpdate_productUpdate_product_margin | null;
- purchaseCost: SimpleProductUpdate_productUpdate_product_purchaseCost | null;
- isAvailableForPurchase: boolean | null;
- isAvailable: boolean | null;
- isPublished: boolean;
chargeTaxes: boolean;
- publicationDate: any | null;
images: (SimpleProductUpdate_productUpdate_product_images | null)[] | null;
+ isAvailable: boolean | null;
variants: (SimpleProductUpdate_productUpdate_product_variants | null)[] | null;
weight: SimpleProductUpdate_productUpdate_product_weight | null;
taxType: SimpleProductUpdate_productUpdate_product_taxType | null;
- availableForPurchase: any | null;
- visibleInListings: boolean;
}
export interface SimpleProductUpdate_productUpdate {
@@ -296,24 +276,12 @@ export interface SimpleProductUpdate_productVariantUpdate_productVariant_attribu
values: (SimpleProductUpdate_productVariantUpdate_productVariant_attributes_values | null)[];
}
-export interface SimpleProductUpdate_productVariantUpdate_productVariant_costPrice {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
export interface SimpleProductUpdate_productVariantUpdate_productVariant_images {
__typename: "ProductImage";
id: string;
url: string;
}
-export interface SimpleProductUpdate_productVariantUpdate_productVariant_price {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
export interface SimpleProductUpdate_productVariantUpdate_productVariant_product_defaultVariant {
__typename: "ProductVariant";
id: string;
@@ -332,6 +300,25 @@ export interface SimpleProductUpdate_productVariantUpdate_productVariant_product
url: string;
}
+export interface SimpleProductUpdate_productVariantUpdate_productVariant_product_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface SimpleProductUpdate_productVariantUpdate_productVariant_product_channelListings_discountedPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface SimpleProductUpdate_productVariantUpdate_productVariant_product_channelListings {
+ __typename: "ProductChannelListing";
+ channel: SimpleProductUpdate_productVariantUpdate_productVariant_product_channelListings_channel;
+ discountedPrice: SimpleProductUpdate_productVariantUpdate_productVariant_product_channelListings_discountedPrice | null;
+}
+
export interface SimpleProductUpdate_productVariantUpdate_productVariant_product_variants_images {
__typename: "ProductImage";
id: string;
@@ -353,9 +340,36 @@ export interface SimpleProductUpdate_productVariantUpdate_productVariant_product
images: (SimpleProductUpdate_productVariantUpdate_productVariant_product_images | null)[] | null;
name: string;
thumbnail: SimpleProductUpdate_productVariantUpdate_productVariant_product_thumbnail | null;
+ channelListings: SimpleProductUpdate_productVariantUpdate_productVariant_product_channelListings[] | null;
variants: (SimpleProductUpdate_productVariantUpdate_productVariant_product_variants | null)[] | null;
}
+export interface SimpleProductUpdate_productVariantUpdate_productVariant_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface SimpleProductUpdate_productVariantUpdate_productVariant_channelListings_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface SimpleProductUpdate_productVariantUpdate_productVariant_channelListings_costPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface SimpleProductUpdate_productVariantUpdate_productVariant_channelListings {
+ __typename: "ProductVariantChannelListing";
+ channel: SimpleProductUpdate_productVariantUpdate_productVariant_channelListings_channel;
+ price: SimpleProductUpdate_productVariantUpdate_productVariant_channelListings_price | null;
+ costPrice: SimpleProductUpdate_productVariantUpdate_productVariant_channelListings_costPrice | null;
+}
+
export interface SimpleProductUpdate_productVariantUpdate_productVariant_stocks_warehouse {
__typename: "Warehouse";
id: string;
@@ -382,11 +396,10 @@ export interface SimpleProductUpdate_productVariantUpdate_productVariant {
metadata: (SimpleProductUpdate_productVariantUpdate_productVariant_metadata | null)[];
privateMetadata: (SimpleProductUpdate_productVariantUpdate_productVariant_privateMetadata | null)[];
attributes: SimpleProductUpdate_productVariantUpdate_productVariant_attributes[];
- costPrice: SimpleProductUpdate_productVariantUpdate_productVariant_costPrice | null;
images: (SimpleProductUpdate_productVariantUpdate_productVariant_images | null)[] | null;
name: string;
- price: SimpleProductUpdate_productVariantUpdate_productVariant_price | null;
product: SimpleProductUpdate_productVariantUpdate_productVariant_product;
+ channelListings: SimpleProductUpdate_productVariantUpdate_productVariant_channelListings[] | null;
sku: string;
stocks: (SimpleProductUpdate_productVariantUpdate_productVariant_stocks | null)[] | null;
trackInventory: boolean;
@@ -447,24 +460,12 @@ export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_a
values: (SimpleProductUpdate_productVariantStocksCreate_productVariant_attributes_values | null)[];
}
-export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_costPrice {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_images {
__typename: "ProductImage";
id: string;
url: string;
}
-export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_price {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_product_defaultVariant {
__typename: "ProductVariant";
id: string;
@@ -483,6 +484,25 @@ export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_p
url: string;
}
+export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_product_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_product_channelListings_discountedPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_product_channelListings {
+ __typename: "ProductChannelListing";
+ channel: SimpleProductUpdate_productVariantStocksCreate_productVariant_product_channelListings_channel;
+ discountedPrice: SimpleProductUpdate_productVariantStocksCreate_productVariant_product_channelListings_discountedPrice | null;
+}
+
export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_product_variants_images {
__typename: "ProductImage";
id: string;
@@ -504,9 +524,36 @@ export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_p
images: (SimpleProductUpdate_productVariantStocksCreate_productVariant_product_images | null)[] | null;
name: string;
thumbnail: SimpleProductUpdate_productVariantStocksCreate_productVariant_product_thumbnail | null;
+ channelListings: SimpleProductUpdate_productVariantStocksCreate_productVariant_product_channelListings[] | null;
variants: (SimpleProductUpdate_productVariantStocksCreate_productVariant_product_variants | null)[] | null;
}
+export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_channelListings_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_channelListings_costPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_channelListings {
+ __typename: "ProductVariantChannelListing";
+ channel: SimpleProductUpdate_productVariantStocksCreate_productVariant_channelListings_channel;
+ price: SimpleProductUpdate_productVariantStocksCreate_productVariant_channelListings_price | null;
+ costPrice: SimpleProductUpdate_productVariantStocksCreate_productVariant_channelListings_costPrice | null;
+}
+
export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_stocks_warehouse {
__typename: "Warehouse";
id: string;
@@ -533,11 +580,10 @@ export interface SimpleProductUpdate_productVariantStocksCreate_productVariant {
metadata: (SimpleProductUpdate_productVariantStocksCreate_productVariant_metadata | null)[];
privateMetadata: (SimpleProductUpdate_productVariantStocksCreate_productVariant_privateMetadata | null)[];
attributes: SimpleProductUpdate_productVariantStocksCreate_productVariant_attributes[];
- costPrice: SimpleProductUpdate_productVariantStocksCreate_productVariant_costPrice | null;
images: (SimpleProductUpdate_productVariantStocksCreate_productVariant_images | null)[] | null;
name: string;
- price: SimpleProductUpdate_productVariantStocksCreate_productVariant_price | null;
product: SimpleProductUpdate_productVariantStocksCreate_productVariant_product;
+ channelListings: SimpleProductUpdate_productVariantStocksCreate_productVariant_channelListings[] | null;
sku: string;
stocks: (SimpleProductUpdate_productVariantStocksCreate_productVariant_stocks | null)[] | null;
trackInventory: boolean;
@@ -597,24 +643,12 @@ export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_a
values: (SimpleProductUpdate_productVariantStocksDelete_productVariant_attributes_values | null)[];
}
-export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_costPrice {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_images {
__typename: "ProductImage";
id: string;
url: string;
}
-export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_price {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_product_defaultVariant {
__typename: "ProductVariant";
id: string;
@@ -633,6 +667,25 @@ export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_p
url: string;
}
+export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_product_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_product_channelListings_discountedPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_product_channelListings {
+ __typename: "ProductChannelListing";
+ channel: SimpleProductUpdate_productVariantStocksDelete_productVariant_product_channelListings_channel;
+ discountedPrice: SimpleProductUpdate_productVariantStocksDelete_productVariant_product_channelListings_discountedPrice | null;
+}
+
export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_product_variants_images {
__typename: "ProductImage";
id: string;
@@ -654,9 +707,36 @@ export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_p
images: (SimpleProductUpdate_productVariantStocksDelete_productVariant_product_images | null)[] | null;
name: string;
thumbnail: SimpleProductUpdate_productVariantStocksDelete_productVariant_product_thumbnail | null;
+ channelListings: SimpleProductUpdate_productVariantStocksDelete_productVariant_product_channelListings[] | null;
variants: (SimpleProductUpdate_productVariantStocksDelete_productVariant_product_variants | null)[] | null;
}
+export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_channelListings_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_channelListings_costPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_channelListings {
+ __typename: "ProductVariantChannelListing";
+ channel: SimpleProductUpdate_productVariantStocksDelete_productVariant_channelListings_channel;
+ price: SimpleProductUpdate_productVariantStocksDelete_productVariant_channelListings_price | null;
+ costPrice: SimpleProductUpdate_productVariantStocksDelete_productVariant_channelListings_costPrice | null;
+}
+
export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_stocks_warehouse {
__typename: "Warehouse";
id: string;
@@ -683,11 +763,10 @@ export interface SimpleProductUpdate_productVariantStocksDelete_productVariant {
metadata: (SimpleProductUpdate_productVariantStocksDelete_productVariant_metadata | null)[];
privateMetadata: (SimpleProductUpdate_productVariantStocksDelete_productVariant_privateMetadata | null)[];
attributes: SimpleProductUpdate_productVariantStocksDelete_productVariant_attributes[];
- costPrice: SimpleProductUpdate_productVariantStocksDelete_productVariant_costPrice | null;
images: (SimpleProductUpdate_productVariantStocksDelete_productVariant_images | null)[] | null;
name: string;
- price: SimpleProductUpdate_productVariantStocksDelete_productVariant_price | null;
product: SimpleProductUpdate_productVariantStocksDelete_productVariant_product;
+ channelListings: SimpleProductUpdate_productVariantStocksDelete_productVariant_channelListings[] | null;
sku: string;
stocks: (SimpleProductUpdate_productVariantStocksDelete_productVariant_stocks | null)[] | null;
trackInventory: boolean;
@@ -748,24 +827,12 @@ export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_a
values: (SimpleProductUpdate_productVariantStocksUpdate_productVariant_attributes_values | null)[];
}
-export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_costPrice {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_images {
__typename: "ProductImage";
id: string;
url: string;
}
-export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_price {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_product_defaultVariant {
__typename: "ProductVariant";
id: string;
@@ -784,6 +851,25 @@ export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_p
url: string;
}
+export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_product_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_product_channelListings_discountedPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_product_channelListings {
+ __typename: "ProductChannelListing";
+ channel: SimpleProductUpdate_productVariantStocksUpdate_productVariant_product_channelListings_channel;
+ discountedPrice: SimpleProductUpdate_productVariantStocksUpdate_productVariant_product_channelListings_discountedPrice | null;
+}
+
export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_product_variants_images {
__typename: "ProductImage";
id: string;
@@ -805,9 +891,36 @@ export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_p
images: (SimpleProductUpdate_productVariantStocksUpdate_productVariant_product_images | null)[] | null;
name: string;
thumbnail: SimpleProductUpdate_productVariantStocksUpdate_productVariant_product_thumbnail | null;
+ channelListings: SimpleProductUpdate_productVariantStocksUpdate_productVariant_product_channelListings[] | null;
variants: (SimpleProductUpdate_productVariantStocksUpdate_productVariant_product_variants | null)[] | null;
}
+export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_channelListings_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_channelListings_costPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_channelListings {
+ __typename: "ProductVariantChannelListing";
+ channel: SimpleProductUpdate_productVariantStocksUpdate_productVariant_channelListings_channel;
+ price: SimpleProductUpdate_productVariantStocksUpdate_productVariant_channelListings_price | null;
+ costPrice: SimpleProductUpdate_productVariantStocksUpdate_productVariant_channelListings_costPrice | null;
+}
+
export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_stocks_warehouse {
__typename: "Warehouse";
id: string;
@@ -834,11 +947,10 @@ export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant {
metadata: (SimpleProductUpdate_productVariantStocksUpdate_productVariant_metadata | null)[];
privateMetadata: (SimpleProductUpdate_productVariantStocksUpdate_productVariant_privateMetadata | null)[];
attributes: SimpleProductUpdate_productVariantStocksUpdate_productVariant_attributes[];
- costPrice: SimpleProductUpdate_productVariantStocksUpdate_productVariant_costPrice | null;
images: (SimpleProductUpdate_productVariantStocksUpdate_productVariant_images | null)[] | null;
name: string;
- price: SimpleProductUpdate_productVariantStocksUpdate_productVariant_price | null;
product: SimpleProductUpdate_productVariantStocksUpdate_productVariant_product;
+ channelListings: SimpleProductUpdate_productVariantStocksUpdate_productVariant_channelListings[] | null;
sku: string;
stocks: (SimpleProductUpdate_productVariantStocksUpdate_productVariant_stocks | null)[] | null;
trackInventory: boolean;
diff --git a/src/products/types/VariantCreate.ts b/src/products/types/VariantCreate.ts
index be28216f6..a0b50a9d5 100644
--- a/src/products/types/VariantCreate.ts
+++ b/src/products/types/VariantCreate.ts
@@ -56,24 +56,12 @@ export interface VariantCreate_productVariantCreate_productVariant_attributes {
values: (VariantCreate_productVariantCreate_productVariant_attributes_values | null)[];
}
-export interface VariantCreate_productVariantCreate_productVariant_costPrice {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
export interface VariantCreate_productVariantCreate_productVariant_images {
__typename: "ProductImage";
id: string;
url: string;
}
-export interface VariantCreate_productVariantCreate_productVariant_price {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
export interface VariantCreate_productVariantCreate_productVariant_product_defaultVariant {
__typename: "ProductVariant";
id: string;
@@ -92,6 +80,25 @@ export interface VariantCreate_productVariantCreate_productVariant_product_thumb
url: string;
}
+export interface VariantCreate_productVariantCreate_productVariant_product_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface VariantCreate_productVariantCreate_productVariant_product_channelListings_discountedPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface VariantCreate_productVariantCreate_productVariant_product_channelListings {
+ __typename: "ProductChannelListing";
+ channel: VariantCreate_productVariantCreate_productVariant_product_channelListings_channel;
+ discountedPrice: VariantCreate_productVariantCreate_productVariant_product_channelListings_discountedPrice | null;
+}
+
export interface VariantCreate_productVariantCreate_productVariant_product_variants_images {
__typename: "ProductImage";
id: string;
@@ -113,9 +120,36 @@ export interface VariantCreate_productVariantCreate_productVariant_product {
images: (VariantCreate_productVariantCreate_productVariant_product_images | null)[] | null;
name: string;
thumbnail: VariantCreate_productVariantCreate_productVariant_product_thumbnail | null;
+ channelListings: VariantCreate_productVariantCreate_productVariant_product_channelListings[] | null;
variants: (VariantCreate_productVariantCreate_productVariant_product_variants | null)[] | null;
}
+export interface VariantCreate_productVariantCreate_productVariant_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface VariantCreate_productVariantCreate_productVariant_channelListings_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface VariantCreate_productVariantCreate_productVariant_channelListings_costPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface VariantCreate_productVariantCreate_productVariant_channelListings {
+ __typename: "ProductVariantChannelListing";
+ channel: VariantCreate_productVariantCreate_productVariant_channelListings_channel;
+ price: VariantCreate_productVariantCreate_productVariant_channelListings_price | null;
+ costPrice: VariantCreate_productVariantCreate_productVariant_channelListings_costPrice | null;
+}
+
export interface VariantCreate_productVariantCreate_productVariant_stocks_warehouse {
__typename: "Warehouse";
id: string;
@@ -142,11 +176,10 @@ export interface VariantCreate_productVariantCreate_productVariant {
metadata: (VariantCreate_productVariantCreate_productVariant_metadata | null)[];
privateMetadata: (VariantCreate_productVariantCreate_productVariant_privateMetadata | null)[];
attributes: VariantCreate_productVariantCreate_productVariant_attributes[];
- costPrice: VariantCreate_productVariantCreate_productVariant_costPrice | null;
images: (VariantCreate_productVariantCreate_productVariant_images | null)[] | null;
name: string;
- price: VariantCreate_productVariantCreate_productVariant_price | null;
product: VariantCreate_productVariantCreate_productVariant_product;
+ channelListings: VariantCreate_productVariantCreate_productVariant_channelListings[] | null;
sku: string;
stocks: (VariantCreate_productVariantCreate_productVariant_stocks | null)[] | null;
trackInventory: boolean;
diff --git a/src/products/types/VariantImageAssign.ts b/src/products/types/VariantImageAssign.ts
index 5dcf48722..baf4917ca 100644
--- a/src/products/types/VariantImageAssign.ts
+++ b/src/products/types/VariantImageAssign.ts
@@ -55,24 +55,12 @@ export interface VariantImageAssign_variantImageAssign_productVariant_attributes
values: (VariantImageAssign_variantImageAssign_productVariant_attributes_values | null)[];
}
-export interface VariantImageAssign_variantImageAssign_productVariant_costPrice {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
export interface VariantImageAssign_variantImageAssign_productVariant_images {
__typename: "ProductImage";
id: string;
url: string;
}
-export interface VariantImageAssign_variantImageAssign_productVariant_price {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
export interface VariantImageAssign_variantImageAssign_productVariant_product_defaultVariant {
__typename: "ProductVariant";
id: string;
@@ -91,6 +79,25 @@ export interface VariantImageAssign_variantImageAssign_productVariant_product_th
url: string;
}
+export interface VariantImageAssign_variantImageAssign_productVariant_product_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface VariantImageAssign_variantImageAssign_productVariant_product_channelListings_discountedPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface VariantImageAssign_variantImageAssign_productVariant_product_channelListings {
+ __typename: "ProductChannelListing";
+ channel: VariantImageAssign_variantImageAssign_productVariant_product_channelListings_channel;
+ discountedPrice: VariantImageAssign_variantImageAssign_productVariant_product_channelListings_discountedPrice | null;
+}
+
export interface VariantImageAssign_variantImageAssign_productVariant_product_variants_images {
__typename: "ProductImage";
id: string;
@@ -112,9 +119,36 @@ export interface VariantImageAssign_variantImageAssign_productVariant_product {
images: (VariantImageAssign_variantImageAssign_productVariant_product_images | null)[] | null;
name: string;
thumbnail: VariantImageAssign_variantImageAssign_productVariant_product_thumbnail | null;
+ channelListings: VariantImageAssign_variantImageAssign_productVariant_product_channelListings[] | null;
variants: (VariantImageAssign_variantImageAssign_productVariant_product_variants | null)[] | null;
}
+export interface VariantImageAssign_variantImageAssign_productVariant_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface VariantImageAssign_variantImageAssign_productVariant_channelListings_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface VariantImageAssign_variantImageAssign_productVariant_channelListings_costPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface VariantImageAssign_variantImageAssign_productVariant_channelListings {
+ __typename: "ProductVariantChannelListing";
+ channel: VariantImageAssign_variantImageAssign_productVariant_channelListings_channel;
+ price: VariantImageAssign_variantImageAssign_productVariant_channelListings_price | null;
+ costPrice: VariantImageAssign_variantImageAssign_productVariant_channelListings_costPrice | null;
+}
+
export interface VariantImageAssign_variantImageAssign_productVariant_stocks_warehouse {
__typename: "Warehouse";
id: string;
@@ -141,11 +175,10 @@ export interface VariantImageAssign_variantImageAssign_productVariant {
metadata: (VariantImageAssign_variantImageAssign_productVariant_metadata | null)[];
privateMetadata: (VariantImageAssign_variantImageAssign_productVariant_privateMetadata | null)[];
attributes: VariantImageAssign_variantImageAssign_productVariant_attributes[];
- costPrice: VariantImageAssign_variantImageAssign_productVariant_costPrice | null;
images: (VariantImageAssign_variantImageAssign_productVariant_images | null)[] | null;
name: string;
- price: VariantImageAssign_variantImageAssign_productVariant_price | null;
product: VariantImageAssign_variantImageAssign_productVariant_product;
+ channelListings: VariantImageAssign_variantImageAssign_productVariant_channelListings[] | null;
sku: string;
stocks: (VariantImageAssign_variantImageAssign_productVariant_stocks | null)[] | null;
trackInventory: boolean;
diff --git a/src/products/types/VariantImageUnassign.ts b/src/products/types/VariantImageUnassign.ts
index 347b3f992..c55630f1f 100644
--- a/src/products/types/VariantImageUnassign.ts
+++ b/src/products/types/VariantImageUnassign.ts
@@ -55,24 +55,12 @@ export interface VariantImageUnassign_variantImageUnassign_productVariant_attrib
values: (VariantImageUnassign_variantImageUnassign_productVariant_attributes_values | null)[];
}
-export interface VariantImageUnassign_variantImageUnassign_productVariant_costPrice {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
export interface VariantImageUnassign_variantImageUnassign_productVariant_images {
__typename: "ProductImage";
id: string;
url: string;
}
-export interface VariantImageUnassign_variantImageUnassign_productVariant_price {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
export interface VariantImageUnassign_variantImageUnassign_productVariant_product_defaultVariant {
__typename: "ProductVariant";
id: string;
@@ -91,6 +79,25 @@ export interface VariantImageUnassign_variantImageUnassign_productVariant_produc
url: string;
}
+export interface VariantImageUnassign_variantImageUnassign_productVariant_product_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface VariantImageUnassign_variantImageUnassign_productVariant_product_channelListings_discountedPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface VariantImageUnassign_variantImageUnassign_productVariant_product_channelListings {
+ __typename: "ProductChannelListing";
+ channel: VariantImageUnassign_variantImageUnassign_productVariant_product_channelListings_channel;
+ discountedPrice: VariantImageUnassign_variantImageUnassign_productVariant_product_channelListings_discountedPrice | null;
+}
+
export interface VariantImageUnassign_variantImageUnassign_productVariant_product_variants_images {
__typename: "ProductImage";
id: string;
@@ -112,9 +119,36 @@ export interface VariantImageUnassign_variantImageUnassign_productVariant_produc
images: (VariantImageUnassign_variantImageUnassign_productVariant_product_images | null)[] | null;
name: string;
thumbnail: VariantImageUnassign_variantImageUnassign_productVariant_product_thumbnail | null;
+ channelListings: VariantImageUnassign_variantImageUnassign_productVariant_product_channelListings[] | null;
variants: (VariantImageUnassign_variantImageUnassign_productVariant_product_variants | null)[] | null;
}
+export interface VariantImageUnassign_variantImageUnassign_productVariant_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface VariantImageUnassign_variantImageUnassign_productVariant_channelListings_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface VariantImageUnassign_variantImageUnassign_productVariant_channelListings_costPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface VariantImageUnassign_variantImageUnassign_productVariant_channelListings {
+ __typename: "ProductVariantChannelListing";
+ channel: VariantImageUnassign_variantImageUnassign_productVariant_channelListings_channel;
+ price: VariantImageUnassign_variantImageUnassign_productVariant_channelListings_price | null;
+ costPrice: VariantImageUnassign_variantImageUnassign_productVariant_channelListings_costPrice | null;
+}
+
export interface VariantImageUnassign_variantImageUnassign_productVariant_stocks_warehouse {
__typename: "Warehouse";
id: string;
@@ -141,11 +175,10 @@ export interface VariantImageUnassign_variantImageUnassign_productVariant {
metadata: (VariantImageUnassign_variantImageUnassign_productVariant_metadata | null)[];
privateMetadata: (VariantImageUnassign_variantImageUnassign_productVariant_privateMetadata | null)[];
attributes: VariantImageUnassign_variantImageUnassign_productVariant_attributes[];
- costPrice: VariantImageUnassign_variantImageUnassign_productVariant_costPrice | null;
images: (VariantImageUnassign_variantImageUnassign_productVariant_images | null)[] | null;
name: string;
- price: VariantImageUnassign_variantImageUnassign_productVariant_price | null;
product: VariantImageUnassign_variantImageUnassign_productVariant_product;
+ channelListings: VariantImageUnassign_variantImageUnassign_productVariant_channelListings[] | null;
sku: string;
stocks: (VariantImageUnassign_variantImageUnassign_productVariant_stocks | null)[] | null;
trackInventory: boolean;
diff --git a/src/products/types/VariantUpdate.ts b/src/products/types/VariantUpdate.ts
index 7bb411da3..3c18b6acc 100644
--- a/src/products/types/VariantUpdate.ts
+++ b/src/products/types/VariantUpdate.ts
@@ -56,24 +56,12 @@ export interface VariantUpdate_productVariantUpdate_productVariant_attributes {
values: (VariantUpdate_productVariantUpdate_productVariant_attributes_values | null)[];
}
-export interface VariantUpdate_productVariantUpdate_productVariant_costPrice {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
export interface VariantUpdate_productVariantUpdate_productVariant_images {
__typename: "ProductImage";
id: string;
url: string;
}
-export interface VariantUpdate_productVariantUpdate_productVariant_price {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
export interface VariantUpdate_productVariantUpdate_productVariant_product_defaultVariant {
__typename: "ProductVariant";
id: string;
@@ -92,6 +80,25 @@ export interface VariantUpdate_productVariantUpdate_productVariant_product_thumb
url: string;
}
+export interface VariantUpdate_productVariantUpdate_productVariant_product_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface VariantUpdate_productVariantUpdate_productVariant_product_channelListings_discountedPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface VariantUpdate_productVariantUpdate_productVariant_product_channelListings {
+ __typename: "ProductChannelListing";
+ channel: VariantUpdate_productVariantUpdate_productVariant_product_channelListings_channel;
+ discountedPrice: VariantUpdate_productVariantUpdate_productVariant_product_channelListings_discountedPrice | null;
+}
+
export interface VariantUpdate_productVariantUpdate_productVariant_product_variants_images {
__typename: "ProductImage";
id: string;
@@ -113,9 +120,36 @@ export interface VariantUpdate_productVariantUpdate_productVariant_product {
images: (VariantUpdate_productVariantUpdate_productVariant_product_images | null)[] | null;
name: string;
thumbnail: VariantUpdate_productVariantUpdate_productVariant_product_thumbnail | null;
+ channelListings: VariantUpdate_productVariantUpdate_productVariant_product_channelListings[] | null;
variants: (VariantUpdate_productVariantUpdate_productVariant_product_variants | null)[] | null;
}
+export interface VariantUpdate_productVariantUpdate_productVariant_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface VariantUpdate_productVariantUpdate_productVariant_channelListings_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface VariantUpdate_productVariantUpdate_productVariant_channelListings_costPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface VariantUpdate_productVariantUpdate_productVariant_channelListings {
+ __typename: "ProductVariantChannelListing";
+ channel: VariantUpdate_productVariantUpdate_productVariant_channelListings_channel;
+ price: VariantUpdate_productVariantUpdate_productVariant_channelListings_price | null;
+ costPrice: VariantUpdate_productVariantUpdate_productVariant_channelListings_costPrice | null;
+}
+
export interface VariantUpdate_productVariantUpdate_productVariant_stocks_warehouse {
__typename: "Warehouse";
id: string;
@@ -142,11 +176,10 @@ export interface VariantUpdate_productVariantUpdate_productVariant {
metadata: (VariantUpdate_productVariantUpdate_productVariant_metadata | null)[];
privateMetadata: (VariantUpdate_productVariantUpdate_productVariant_privateMetadata | null)[];
attributes: VariantUpdate_productVariantUpdate_productVariant_attributes[];
- costPrice: VariantUpdate_productVariantUpdate_productVariant_costPrice | null;
images: (VariantUpdate_productVariantUpdate_productVariant_images | null)[] | null;
name: string;
- price: VariantUpdate_productVariantUpdate_productVariant_price | null;
product: VariantUpdate_productVariantUpdate_productVariant_product;
+ channelListings: VariantUpdate_productVariantUpdate_productVariant_channelListings[] | null;
sku: string;
stocks: (VariantUpdate_productVariantUpdate_productVariant_stocks | null)[] | null;
trackInventory: boolean;
@@ -207,24 +240,12 @@ export interface VariantUpdate_productVariantStocksUpdate_productVariant_attribu
values: (VariantUpdate_productVariantStocksUpdate_productVariant_attributes_values | null)[];
}
-export interface VariantUpdate_productVariantStocksUpdate_productVariant_costPrice {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
export interface VariantUpdate_productVariantStocksUpdate_productVariant_images {
__typename: "ProductImage";
id: string;
url: string;
}
-export interface VariantUpdate_productVariantStocksUpdate_productVariant_price {
- __typename: "Money";
- amount: number;
- currency: string;
-}
-
export interface VariantUpdate_productVariantStocksUpdate_productVariant_product_defaultVariant {
__typename: "ProductVariant";
id: string;
@@ -243,6 +264,25 @@ export interface VariantUpdate_productVariantStocksUpdate_productVariant_product
url: string;
}
+export interface VariantUpdate_productVariantStocksUpdate_productVariant_product_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface VariantUpdate_productVariantStocksUpdate_productVariant_product_channelListings_discountedPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface VariantUpdate_productVariantStocksUpdate_productVariant_product_channelListings {
+ __typename: "ProductChannelListing";
+ channel: VariantUpdate_productVariantStocksUpdate_productVariant_product_channelListings_channel;
+ discountedPrice: VariantUpdate_productVariantStocksUpdate_productVariant_product_channelListings_discountedPrice | null;
+}
+
export interface VariantUpdate_productVariantStocksUpdate_productVariant_product_variants_images {
__typename: "ProductImage";
id: string;
@@ -264,9 +304,36 @@ export interface VariantUpdate_productVariantStocksUpdate_productVariant_product
images: (VariantUpdate_productVariantStocksUpdate_productVariant_product_images | null)[] | null;
name: string;
thumbnail: VariantUpdate_productVariantStocksUpdate_productVariant_product_thumbnail | null;
+ channelListings: VariantUpdate_productVariantStocksUpdate_productVariant_product_channelListings[] | null;
variants: (VariantUpdate_productVariantStocksUpdate_productVariant_product_variants | null)[] | null;
}
+export interface VariantUpdate_productVariantStocksUpdate_productVariant_channelListings_channel {
+ __typename: "Channel";
+ id: string;
+ name: string;
+ currencyCode: string;
+}
+
+export interface VariantUpdate_productVariantStocksUpdate_productVariant_channelListings_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface VariantUpdate_productVariantStocksUpdate_productVariant_channelListings_costPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface VariantUpdate_productVariantStocksUpdate_productVariant_channelListings {
+ __typename: "ProductVariantChannelListing";
+ channel: VariantUpdate_productVariantStocksUpdate_productVariant_channelListings_channel;
+ price: VariantUpdate_productVariantStocksUpdate_productVariant_channelListings_price | null;
+ costPrice: VariantUpdate_productVariantStocksUpdate_productVariant_channelListings_costPrice | null;
+}
+
export interface VariantUpdate_productVariantStocksUpdate_productVariant_stocks_warehouse {
__typename: "Warehouse";
id: string;
@@ -293,11 +360,10 @@ export interface VariantUpdate_productVariantStocksUpdate_productVariant {
metadata: (VariantUpdate_productVariantStocksUpdate_productVariant_metadata | null)[];
privateMetadata: (VariantUpdate_productVariantStocksUpdate_productVariant_privateMetadata | null)[];
attributes: VariantUpdate_productVariantStocksUpdate_productVariant_attributes[];
- costPrice: VariantUpdate_productVariantStocksUpdate_productVariant_costPrice | null;
images: (VariantUpdate_productVariantStocksUpdate_productVariant_images | null)[] | null;
name: string;
- price: VariantUpdate_productVariantStocksUpdate_productVariant_price | null;
product: VariantUpdate_productVariantStocksUpdate_productVariant_product;
+ channelListings: VariantUpdate_productVariantStocksUpdate_productVariant_channelListings[] | null;
sku: string;
stocks: (VariantUpdate_productVariantStocksUpdate_productVariant_stocks | null)[] | null;
trackInventory: boolean;
@@ -387,8 +453,6 @@ export interface VariantUpdateVariables {
removeStocks: string[];
id: string;
attributes?: (AttributeValueInput | null)[] | null;
- costPrice?: any | null;
- price?: any | null;
sku?: string | null;
trackInventory: boolean;
stocks: StockInput[];
diff --git a/src/products/types/productBulkPublish.ts b/src/products/types/productBulkPublish.ts
index f429764a4..f34853adc 100644
--- a/src/products/types/productBulkPublish.ts
+++ b/src/products/types/productBulkPublish.ts
@@ -25,5 +25,4 @@ export interface productBulkPublish {
export interface productBulkPublishVariables {
ids: string[];
- isPublished: boolean;
}
diff --git a/src/products/urls.ts b/src/products/urls.ts
index 859229d35..0040f887f 100644
--- a/src/products/urls.ts
+++ b/src/products/urls.ts
@@ -20,8 +20,7 @@ export const productAddUrl = productAddPath;
export const productListPath = productSection;
export type ProductListUrlDialog =
- | "publish"
- | "unpublish"
+ | "settings"
| "delete"
| "export"
| TabActionDialog;
diff --git a/src/products/utils/data.ts b/src/products/utils/data.ts
index 6bc8bc719..5b32e2fdb 100644
--- a/src/products/utils/data.ts
+++ b/src/products/utils/data.ts
@@ -1,3 +1,4 @@
+import { ChannelData } from "@saleor/channels/utils";
import { MetadataFormData } from "@saleor/components/Metadata/types";
import { MultiAutocompleteChoiceType } from "@saleor/components/MultiAutocompleteSelectField";
import { SingleAutocompleteChoiceType } from "@saleor/components/SingleAutocompleteSelectField";
@@ -168,48 +169,45 @@ export function getChoices(nodes: Node[]): SingleAutocompleteChoiceType[] {
}
export interface ProductUpdatePageFormData extends MetadataFormData {
- availableForPurchase: string;
basePrice: number;
category: string | null;
changeTaxCode: boolean;
+ channelListings: ChannelData[];
chargeTaxes: boolean;
collections: string[];
isAvailable: boolean;
- isAvailableForPurchase: boolean;
- isPublished: boolean;
name: string;
slug: string;
- publicationDate: string;
seoDescription: string;
seoTitle: string;
sku: string;
taxCode: string;
trackInventory: boolean;
- visibleInListings: boolean;
weight: string;
}
export function getProductUpdatePageFormData(
product: ProductDetails_product,
- variants: ProductDetails_product_variants[]
+ variants: ProductDetails_product_variants[],
+ currentChannels: ChannelData[]
): ProductUpdatePageFormData {
return {
- availableForPurchase: product?.availableForPurchase,
- basePrice: maybe(() => product.variants[0].price.amount, 0),
+ basePrice: maybe(
+ () => product.channelListings[0].discountedPrice.amount,
+ 0
+ ),
category: maybe(() => product.category.id, ""),
changeTaxCode: !!product?.taxType.taxCode,
+ channelListings: currentChannels,
chargeTaxes: maybe(() => product.chargeTaxes, false),
collections: maybe(
() => product.collections.map(collection => collection.id),
[]
),
isAvailable: !!product?.isAvailable,
- isAvailableForPurchase: !!product?.isAvailableForPurchase,
- isPublished: maybe(() => product.isPublished, false),
metadata: product?.metadata?.map(mapMetadataItemToInput),
name: maybe(() => product.name, ""),
privateMetadata: product?.privateMetadata?.map(mapMetadataItemToInput),
- publicationDate: maybe(() => product.publicationDate, ""),
seoDescription: maybe(() => product.seoDescription, ""),
seoTitle: maybe(() => product.seoTitle, ""),
sku: maybe(
@@ -224,7 +222,6 @@ export function getProductUpdatePageFormData(
slug: product?.slug || "",
taxCode: product?.taxType.taxCode,
trackInventory: !!product?.variants[0]?.trackInventory,
- visibleInListings: !!product?.visibleInListings,
weight: product?.weight?.value.toString() || ""
};
}
diff --git a/src/products/utils/handlers.ts b/src/products/utils/handlers.ts
index 9c7021d43..866e5813e 100644
--- a/src/products/utils/handlers.ts
+++ b/src/products/utils/handlers.ts
@@ -1,3 +1,8 @@
+import {
+ ChannelData,
+ ChannelPriceArgs,
+ ChannelPriceData
+} from "@saleor/channels/utils";
import { FormChange } from "@saleor/hooks/useForm";
import { FormsetChange, FormsetData } from "@saleor/hooks/useFormset";
import { toggle } from "@saleor/utils/lists";
@@ -15,6 +20,85 @@ export function createAttributeChangeHandler(
};
}
+export function createChannelsPriceChangeHandler(
+ channelListings: ChannelPriceData[],
+ updateChannels: (data: ChannelPriceData[]) => void,
+ triggerChange: () => void
+) {
+ return (id: string, priceData: ChannelPriceArgs) => {
+ const { costPrice, price } = priceData;
+ const channelIndex = channelListings.findIndex(
+ channel => channel.id === id
+ );
+ const channel = channelListings[channelIndex];
+
+ const updatedChannels = [
+ ...channelListings.slice(0, channelIndex),
+ {
+ ...channel,
+ costPrice,
+ price
+ },
+ ...channelListings.slice(channelIndex + 1)
+ ];
+ updateChannels(updatedChannels);
+ triggerChange();
+ };
+}
+
+export function createChannelsChangeHandler(
+ channelListings: ChannelData[],
+ updateChannels: (data: ChannelData[]) => void,
+ triggerChange: () => void
+) {
+ return (
+ id: string,
+ data: Omit
+ ) => {
+ const channelIndex = channelListings.findIndex(
+ channel => channel.id === id
+ );
+ const channel = channelListings[channelIndex];
+
+ const updatedChannels = [
+ ...channelListings.slice(0, channelIndex),
+ {
+ ...channel,
+ ...data
+ },
+ ...channelListings.slice(channelIndex + 1)
+ ];
+ updateChannels(updatedChannels);
+ triggerChange();
+ };
+}
+
+export function createVariantChannelsChangeHandler(
+ channelListings: ChannelPriceData[],
+ setData: (data: ChannelPriceData[]) => void,
+ triggerChange: () => void
+) {
+ return (id: string, priceData: ChannelPriceArgs) => {
+ const { costPrice, price } = priceData;
+ const channelIndex = channelListings.findIndex(
+ channel => channel.id === id
+ );
+ const channel = channelListings[channelIndex];
+
+ const updatedChannels = [
+ ...channelListings.slice(0, channelIndex),
+ {
+ ...channel,
+ costPrice,
+ price
+ },
+ ...channelListings.slice(channelIndex + 1)
+ ];
+ setData(updatedChannels);
+ triggerChange();
+ };
+}
+
export function createAttributeMultiChangeHandler(
changeAttributeData: FormsetChange,
attributes: FormsetData,
@@ -53,18 +137,34 @@ export function createProductTypeSelectHandler(
};
}
-interface ProductAvailabilityArgs {
- availableForPurchase: string | null;
- isAvailableForPurchase: boolean;
- productId: string;
-}
+export const getChannelsInput = (channels: ChannelPriceData[]) =>
+ channels?.map(channel => ({
+ data: channel,
+ id: channel.id,
+ label: channel.name,
+ value: {
+ costPrice: channel.costPrice || "",
+ price: channel.price || ""
+ }
+ }));
-export const getProductAvailabilityVariables = ({
- isAvailableForPurchase,
- availableForPurchase,
- productId
-}: ProductAvailabilityArgs) => ({
- isAvailable: isAvailableForPurchase,
- productId,
- startDate: availableForPurchase || null
-});
+export const getAvailabilityVariables = (channels: ChannelData[]) =>
+ channels.map(channel => {
+ const { isAvailableForPurchase, availableForPurchase } = channel;
+ const isAvailable =
+ availableForPurchase && !isAvailableForPurchase
+ ? true
+ : isAvailableForPurchase;
+
+ return {
+ availableForPurchaseDate:
+ isAvailableForPurchase || availableForPurchase === ""
+ ? null
+ : availableForPurchase,
+ channelId: channel.id,
+ isAvailableForPurchase: isAvailable,
+ isPublished: channel.isPublished,
+ publicationDate: channel.publicationDate,
+ visibleInListings: channel.visibleInListings
+ };
+ });
diff --git a/src/products/utils/validation.ts b/src/products/utils/validation.ts
new file mode 100644
index 000000000..ebaa9dd15
--- /dev/null
+++ b/src/products/utils/validation.ts
@@ -0,0 +1,5 @@
+export const validatePrice = (price: string) =>
+ price === "" || parseInt(price, 10) < 0;
+
+export const validateCostPrice = (price: string) =>
+ price !== "" && parseInt(price, 10) < 0;
diff --git a/src/products/views/ProductCreate.tsx b/src/products/views/ProductCreate/ProductCreate.tsx
similarity index 50%
rename from src/products/views/ProductCreate.tsx
rename to src/products/views/ProductCreate/ProductCreate.tsx
index ed3918d8c..a2474630c 100644
--- a/src/products/views/ProductCreate.tsx
+++ b/src/products/views/ProductCreate/ProductCreate.tsx
@@ -1,13 +1,25 @@
+import { useChannelsList } from "@saleor/channels/queries";
+import { ChannelData, createSortedChannelsData } from "@saleor/channels/utils";
+import ChannelsAvailabilityDialog from "@saleor/components/ChannelsAvailabilityDialog";
import { WindowTitle } from "@saleor/components/WindowTitle";
import { DEFAULT_INITIAL_SEARCH_DATA } from "@saleor/config";
+import useChannels from "@saleor/hooks/useChannels";
import useNavigator from "@saleor/hooks/useNavigator";
import useNotifier from "@saleor/hooks/useNotifier";
import useShop from "@saleor/hooks/useShop";
-import { getProductAvailabilityVariables } from "@saleor/products/utils/handlers";
+import ProductCreatePage from "@saleor/products/components/ProductCreatePage";
+import {
+ useProductChannelListingUpdate,
+ useProductVariantChannelListingUpdate,
+ useVariantCreateMutation
+} from "@saleor/products/mutations";
+import { useProductCreateMutation } from "@saleor/products/mutations";
+import { productListUrl, productUrl } from "@saleor/products/urls";
import useCategorySearch from "@saleor/searches/useCategorySearch";
import useCollectionSearch from "@saleor/searches/useCollectionSearch";
import useProductTypeSearch from "@saleor/searches/useProductTypeSearch";
import { useTaxTypeList } from "@saleor/taxes/queries";
+import { getProductErrorMessage } from "@saleor/utils/errors";
import createMetadataCreateHandler from "@saleor/utils/handlers/metadataCreateHandler";
import {
useMetadataUpdate,
@@ -18,14 +30,7 @@ import { warehouseAddPath } from "@saleor/warehouses/urls";
import React from "react";
import { useIntl } from "react-intl";
-import { decimal, weight } from "../../misc";
-import ProductCreatePage from "../components/ProductCreatePage";
-import { ProductCreateData } from "../components/ProductCreatePage/form";
-import {
- useProductCreateMutation,
- useProductSetAvailabilityForPurchase
-} from "../mutations";
-import { productListUrl, productUrl } from "../urls";
+import { createHandler } from "./handlers";
export const ProductCreateView: React.FC = () => {
const navigate = useNavigator();
@@ -63,89 +68,79 @@ export const ProductCreateView: React.FC = () => {
const [updatePrivateMetadata] = usePrivateMetadataUpdate({});
const taxTypes = useTaxTypeList({});
+ const productTypes = searchProductTypesOpts?.data?.search?.edges?.map(
+ edge => edge.node
+ );
+
+ const { data: channelsData } = useChannelsList({});
+ const allChannels: ChannelData[] = createSortedChannelsData(
+ channelsData?.channels
+ );
+
+ const {
+ channelListElements,
+ channelsToggle,
+ currentChannels,
+ handleChannelsConfirm,
+ handleChannelsModalClose,
+ handleChannelsModalOpen,
+ isChannelSelected,
+ isChannelsModalOpen,
+ setCurrentChannels,
+ toggleAllChannels
+ } = useChannels(allChannels);
+
+ const handleSuccess = (productId: string) => {
+ notify({
+ status: "success",
+ text: intl.formatMessage({
+ defaultMessage: "Product created"
+ })
+ });
+ navigate(productUrl(productId));
+ };
+
+ const [updateChannels, updateChannelsOpts] = useProductChannelListingUpdate({
+ onCompleted: data => {
+ const productId = data.productChannelListingUpdate.product.id;
+ if (productId) {
+ handleSuccess(productId);
+ }
+ }
+ });
+ const [
+ updateVariantChannels,
+ updateVariantChannelsOpts
+ ] = useProductVariantChannelListingUpdate({});
+
const handleBack = () => navigate(productListUrl());
+ const [productCreate, productCreateOpts] = useProductCreateMutation({});
const [
- setProductAvailability,
- productAvailabilityOpts
- ] = useProductSetAvailabilityForPurchase({
+ productVariantCreate,
+ productVariantCreateOpts
+ ] = useVariantCreateMutation({
onCompleted: data => {
- const errors = data?.productSetAvailabilityForPurchase?.errors;
- if (errors?.length === 0) {
- navigate(productUrl(data.productSetAvailabilityForPurchase.product.id));
- }
- }
- });
-
- const [productCreate, productCreateOpts] = useProductCreateMutation({
- onCompleted: data => {
- if (data.productCreate.errors.length === 0) {
- notify({
- status: "success",
- text: intl.formatMessage({
- defaultMessage: "Product created"
+ const errors = data.productVariantCreate.errors;
+ if (errors.length) {
+ errors.map(error =>
+ notify({
+ status: "error",
+ text: getProductErrorMessage(error, intl)
})
- });
+ );
}
}
});
- const handleCreate = async (formData: ProductCreateData) => {
- const result = await productCreate({
- variables: {
- input: {
- attributes: formData.attributes.map(attribute => ({
- id: attribute.id,
- values: attribute.value
- })),
- basePrice: decimal(formData.basePrice),
- category: formData.category,
- chargeTaxes: formData.chargeTaxes,
- collections: formData.collections,
- descriptionJson: JSON.stringify(formData.description),
- isPublished: formData.isPublished,
- name: formData.name,
- productType: formData.productType?.id,
- publicationDate:
- formData.publicationDate !== "" ? formData.publicationDate : null,
- seo: {
- description: formData.seoDescription,
- title: formData.seoTitle
- },
- sku: formData.sku,
- slug: formData.slug,
- stocks: formData.stocks.map(stock => ({
- quantity: parseInt(stock.value, 0),
- warehouse: stock.id
- })),
- taxCode: formData.changeTaxCode ? formData.taxCode : undefined,
- trackInventory: formData.trackInventory,
- visibleInListings: formData.visibleInListings,
- weight: weight(formData.weight)
- }
- }
- });
-
- const productId = result.data.productCreate?.product?.id;
-
- if (productId) {
- const { isAvailableForPurchase, availableForPurchase } = formData;
-
- const variables = getProductAvailabilityVariables({
- availableForPurchase,
- isAvailableForPurchase,
- productId
- });
-
- setProductAvailability({
- variables
- });
- }
-
- return productId || null;
- };
const handleSubmit = createMetadataCreateHandler(
- handleCreate,
+ createHandler(
+ productTypes,
+ variables => productCreate({ variables }),
+ variables => productVariantCreate({ variables }),
+ updateChannels,
+ updateVariantChannels
+ ),
updateMetadata,
updatePrivateMetadata
);
@@ -158,16 +153,46 @@ export const ProductCreateView: React.FC = () => {
description: "window title"
})}
/>
+ {!!allChannels?.length && (
+
+ )}
edge.node
)}
- collections={(searchCollectionOpts.data?.search.edges || []).map(
+ collections={(searchCollectionOpts?.data?.search?.edges || []).map(
edge => edge.node
)}
- disabled={productCreateOpts.loading || productAvailabilityOpts.loading}
- errors={productCreateOpts.data?.productCreate.errors || []}
+ disabled={
+ productCreateOpts.loading ||
+ productVariantCreateOpts.loading ||
+ updateChannelsOpts.loading ||
+ updateVariantChannelsOpts.loading
+ }
+ channelsErrors={
+ updateVariantChannelsOpts.data?.productVariantChannelListingUpdate
+ ?.errors
+ }
+ errors={[
+ ...(productCreateOpts.data?.productCreate.errors || []),
+ ...(productVariantCreateOpts.data?.productVariantCreate.errors || [])
+ ]}
fetchCategories={searchCategory}
fetchCollections={searchCollection}
fetchProductTypes={searchProductTypes}
@@ -175,9 +200,7 @@ export const ProductCreateView: React.FC = () => {
defaultMessage: "New Product",
description: "page header"
})}
- productTypes={searchProductTypesOpts.data?.search.edges.map(
- edge => edge.node
- )}
+ productTypes={productTypes}
onBack={handleBack}
onSubmit={handleSubmit}
onWarehouseConfigure={() => navigate(warehouseAddPath)}
@@ -202,6 +225,8 @@ export const ProductCreateView: React.FC = () => {
}
taxTypes={taxTypes.data?.taxTypes || []}
weightUnit={shop?.defaultWeightUnit}
+ openChannelsModal={handleChannelsModalOpen}
+ onChannelsChange={setCurrentChannels}
/>
>
);
diff --git a/src/products/views/ProductCreate/handlers.ts b/src/products/views/ProductCreate/handlers.ts
new file mode 100644
index 000000000..024033cb4
--- /dev/null
+++ b/src/products/views/ProductCreate/handlers.ts
@@ -0,0 +1,120 @@
+import { ChannelData } from "@saleor/channels/utils";
+import { weight } from "@saleor/misc";
+import { ProductCreateData } from "@saleor/products/components/ProductCreatePage/form";
+import {
+ ProductChannelListingUpdate,
+ ProductChannelListingUpdateVariables
+} from "@saleor/products/types/ProductChannelListingUpdate";
+import {
+ ProductCreate,
+ ProductCreateVariables
+} from "@saleor/products/types/ProductCreate";
+import {
+ ProductVariantChannelListingUpdate,
+ ProductVariantChannelListingUpdateVariables
+} from "@saleor/products/types/ProductVariantChannelListingUpdate";
+import {
+ VariantCreate,
+ VariantCreateVariables
+} from "@saleor/products/types/VariantCreate";
+import { getAvailabilityVariables } from "@saleor/products/utils/handlers";
+import { SearchProductTypes_search_edges_node } from "@saleor/searches/types/SearchProductTypes";
+import { MutationFetchResult } from "react-apollo";
+
+const getChannelsVariables = (productId: string, channels: ChannelData[]) => ({
+ variables: {
+ id: productId,
+ input: {
+ addChannels: getAvailabilityVariables(channels)
+ }
+ }
+});
+
+const getSimpleProductVariables = (
+ formData: ProductCreateData,
+ productId: string
+) => ({
+ input: {
+ attributes: [],
+ product: productId,
+ sku: formData.sku,
+ stocks: formData.stocks?.map(stock => ({
+ quantity: parseInt(stock.value, 10),
+ warehouse: stock.id
+ })),
+ trackInventory: formData.trackInventory
+ }
+});
+
+export function createHandler(
+ productTypes: SearchProductTypes_search_edges_node[],
+ productCreate: (
+ variables: ProductCreateVariables
+ ) => Promise>,
+ productVariantCreate: (
+ variables: VariantCreateVariables
+ ) => Promise>,
+ updateChannels: (options: {
+ variables: ProductChannelListingUpdateVariables;
+ }) => Promise>,
+ updateVariantChannels: (options: {
+ variables: ProductVariantChannelListingUpdateVariables;
+ }) => Promise>
+) {
+ return async (formData: ProductCreateData) => {
+ const productVariables: ProductCreateVariables = {
+ input: {
+ attributes: formData.attributes.map(attribute => ({
+ id: attribute.id,
+ values: attribute.value
+ })),
+ category: formData.category,
+ chargeTaxes: formData.chargeTaxes,
+ collections: formData.collections,
+ descriptionJson: JSON.stringify(formData.description),
+ name: formData.name,
+ productType: formData.productType?.id,
+ seo: {
+ description: formData.seoDescription,
+ title: formData.seoTitle
+ },
+ slug: formData.slug,
+ taxCode: formData.changeTaxCode ? formData.taxCode : undefined,
+ weight: weight(formData.weight)
+ }
+ };
+
+ const result = await productCreate(productVariables);
+
+ const hasVariants = productTypes.find(
+ product => product.id === formData.productType.id
+ ).hasVariants;
+ const productId = result.data.productCreate.product.id;
+
+ if (!hasVariants) {
+ const result = await Promise.all([
+ updateChannels(
+ getChannelsVariables(productId, formData.channelListings)
+ ),
+ productVariantCreate(getSimpleProductVariables(formData, productId))
+ ]);
+ const variantErrors = result[1].data.productVariantCreate.errors;
+ const variantId = result[1].data.productVariantCreate.productVariant?.id;
+ if (variantErrors.length === 0 && variantId) {
+ updateVariantChannels({
+ variables: {
+ id: variantId,
+ input: formData.channelListings.map(listing => ({
+ channelId: listing.id,
+ costPrice: listing.costPrice || null,
+ price: listing.price
+ }))
+ }
+ });
+ }
+ } else {
+ updateChannels(getChannelsVariables(productId, formData.channelListings));
+ }
+ return productId || null;
+ };
+}
diff --git a/src/products/views/ProductCreate/index.ts b/src/products/views/ProductCreate/index.ts
new file mode 100644
index 000000000..7764d5051
--- /dev/null
+++ b/src/products/views/ProductCreate/index.ts
@@ -0,0 +1,2 @@
+export * from "./ProductCreate";
+export { default } from "./ProductCreate";
diff --git a/src/products/views/ProductList/ProductList.tsx b/src/products/views/ProductList/ProductList.tsx
index e25ca42eb..836998057 100644
--- a/src/products/views/ProductList/ProductList.tsx
+++ b/src/products/views/ProductList/ProductList.tsx
@@ -1,7 +1,7 @@
-import Button from "@material-ui/core/Button";
import DialogContentText from "@material-ui/core/DialogContentText";
import IconButton from "@material-ui/core/IconButton";
import DeleteIcon from "@material-ui/icons/Delete";
+import ChannelSettingsDialog from "@saleor/channels/components/ChannelSettingsDialog";
import ActionDialog from "@saleor/components/ActionDialog";
import DeleteFilterTabDialog from "@saleor/components/DeleteFilterTabDialog";
import SaveFilterTabDialog, {
@@ -16,13 +16,13 @@ import {
import { Task } from "@saleor/containers/BackgroundTasks/types";
import useBackgroundTask from "@saleor/hooks/useBackgroundTask";
import useBulkActions from "@saleor/hooks/useBulkActions";
+import useChannelsSettings from "@saleor/hooks/useChannelsSettings";
import useListSettings from "@saleor/hooks/useListSettings";
import useNavigator from "@saleor/hooks/useNavigator";
import useNotifier from "@saleor/hooks/useNotifier";
import usePaginator, {
createPaginationState
} from "@saleor/hooks/usePaginator";
-import useShop from "@saleor/hooks/useShop";
import { commonMessages } from "@saleor/intl";
import { maybe } from "@saleor/misc";
import ProductExportDialog from "@saleor/products/components/ProductExportDialog";
@@ -30,7 +30,21 @@ import {
getAttributeIdFromColumnValue,
isAttributeColumnValue
} from "@saleor/products/components/ProductListPage/utils";
+import {
+ useAvailableInGridAttributesQuery,
+ useCountAllProducts,
+ useInitialProductFilterDataQuery,
+ useProductListQuery
+} from "@saleor/products/queries";
import { ProductListVariables } from "@saleor/products/types/ProductList";
+import {
+ productAddUrl,
+ productListUrl,
+ ProductListUrlDialog,
+ ProductListUrlQueryParams,
+ ProductListUrlSortField,
+ productUrl
+} from "@saleor/products/urls";
import useAttributeSearch from "@saleor/searches/useAttributeSearch";
import useCategorySearch from "@saleor/searches/useCategorySearch";
import useCollectionSearch from "@saleor/searches/useCollectionSearch";
@@ -46,23 +60,8 @@ import { FormattedMessage, useIntl } from "react-intl";
import ProductListPage from "../../components/ProductListPage";
import {
useProductBulkDeleteMutation,
- useProductBulkPublishMutation,
useProductExport
} from "../../mutations";
-import {
- useAvailableInGridAttributesQuery,
- useCountAllProducts,
- useInitialProductFilterDataQuery,
- useProductListQuery
-} from "../../queries";
-import {
- productAddUrl,
- productListUrl,
- ProductListUrlDialog,
- ProductListUrlQueryParams,
- ProductListUrlSortField,
- productUrl
-} from "../../urls";
import {
areFiltersApplied,
deleteFilterTab,
@@ -84,7 +83,6 @@ export const ProductList: React.FC = ({ params }) => {
const notify = useNotifier();
const paginate = usePaginator();
const { queue } = useBackgroundTask();
- const shop = useShop();
const { isSelected, listElements, reset, toggle, toggleAll } = useBulkActions(
params.ids
);
@@ -129,17 +127,32 @@ export const ProductList: React.FC = ({ params }) => {
}
});
- React.useEffect(
- () =>
- navigate(
- productListUrl({
- ...params,
- ...DEFAULT_INITIAL_PAGINATION_DATA
- }),
- true
- ),
- [settings.rowNumber]
- );
+ const [openModal, closeModal] = createDialogActionHandlers<
+ ProductListUrlDialog,
+ ProductListUrlQueryParams
+ >(navigate, productListUrl, params);
+
+ const {
+ channel,
+ channels,
+ channelChoices,
+ handleChannelSelectConfirm,
+ selectedChannel,
+ slug
+ } = useChannelsSettings("productsListChannel", { closeModal, openModal });
+
+ React.useEffect(() => {
+ const action = selectedChannel
+ ? {}
+ : { action: "settings" as ProductListUrlDialog };
+ navigate(
+ productListUrl({
+ ...{ ...params, ...action },
+ ...DEFAULT_INITIAL_PAGINATION_DATA
+ }),
+ true
+ );
+ }, [settings.rowNumber]);
const tabs = getFilterTabs();
@@ -150,10 +163,6 @@ export const ProductList: React.FC = ({ params }) => {
: 0
: parseInt(params.activeTab, 0);
- const [openModal, closeModal] = createDialogActionHandlers<
- ProductListUrlDialog,
- ProductListUrlQueryParams
- >(navigate, productListUrl, params);
const countAllProducts = useCountAllProducts({});
const [exportProducts, exportProductsOpts] = useProductExport({
@@ -222,14 +231,13 @@ export const ProductList: React.FC = ({ params }) => {
);
const paginationState = createPaginationState(settings.rowNumber, params);
- const currencySymbol = maybe(() => shop.defaultCurrency, "USD");
- const filter = getFilterVariables(params);
- const sort = getSortQueryVariables(params);
+ const filter = getFilterVariables(params, slug);
+ const sort = getSortQueryVariables(params, slug);
const queryVariables = React.useMemo(
() => ({
...paginationState,
filter,
- sort
+ ...(slug ? { sort } : {})
}),
[params, settings.rowNumber]
);
@@ -264,51 +272,28 @@ export const ProductList: React.FC = ({ params }) => {
}
});
- const [
- productBulkPublish,
- productBulkPublishOpts
- ] = useProductBulkPublishMutation({
- onCompleted: data => {
- if (data.productBulkPublish.errors.length === 0) {
- closeModal();
- notify({
- status: "success",
- text: intl.formatMessage(commonMessages.savedChanges)
- });
- reset();
- refetch();
- }
- }
- });
-
const filterOpts = getFilterOpts(
params,
- maybe(() => initialFilterData.attributes.edges.map(edge => edge.node), []),
+ initialFilterData?.attributes?.edges?.map(edge => edge.node) || [],
{
- initial: maybe(
- () => initialFilterData.categories.edges.map(edge => edge.node),
- []
- ),
+ initial:
+ initialFilterData?.categories?.edges?.map(edge => edge.node) || [],
search: searchCategories
},
{
- initial: maybe(
- () => initialFilterData.collections.edges.map(edge => edge.node),
- []
- ),
+ initial:
+ initialFilterData?.collections?.edges?.map(edge => edge.node) || [],
search: searchCollections
},
{
- initial: maybe(
- () => initialFilterData.productTypes.edges.map(edge => edge.node),
- []
- ),
+ initial:
+ initialFilterData?.productTypes?.edges?.map(edge => edge.node) || [],
search: searchProductTypes
}
);
const { loadNextPage, loadPreviousPage, pageInfo } = paginate(
- maybe(() => data.products.pageInfo),
+ data?.products?.pageInfo,
paginationState,
params
);
@@ -326,7 +311,7 @@ export const ProductList: React.FC = ({ params }) => {
() => attributes.data.availableInGrid.edges.map(edge => edge.node),
[]
)}
- currencySymbol={currencySymbol}
+ currencySymbol={channel?.currencyCode}
currentTab={currentTab}
defaultSettings={defaultListSettings[ListViews.PRODUCT_LIST]}
filterOpts={filterOpts}
@@ -380,44 +365,16 @@ export const ProductList: React.FC = ({ params }) => {
onRowClick={id => () => navigate(productUrl(id))}
onAll={resetFilters}
toolbar={
- <>
-
-
-
- openModal("delete", {
- ids: listElements
- })
- }
- >
-
-
- >
+
+ openModal("delete", {
+ ids: listElements
+ })
+ }
+ >
+
+
}
isChecked={isSelected}
selected={listElements.length}
@@ -431,7 +388,22 @@ export const ProductList: React.FC = ({ params }) => {
initialSearch={params.query || ""}
tabs={getFilterTabs().map(tab => tab.name)}
onExport={() => openModal("export")}
+ channelsCount={channelChoices?.length}
+ selectedChannel={selectedChannel}
+ onSettingsOpen={
+ !!channelChoices?.length ? () => openModal("settings") : undefined
+ }
/>
+ {!!channelChoices?.length && (
+
+ )}
= ({ params }) => {
defaultMessage="{counter,plural,one{Are you sure you want to delete this product?} other{Are you sure you want to delete {displayQuantity} products?}}"
description="dialog content"
values={{
- counter: maybe(() => params.ids.length),
- displayQuantity: {maybe(() => params.ids.length)}
- }}
- />
-
-
-
- productBulkPublish({
- variables: {
- ids: params.ids,
- isPublished: true
- }
- })
- }
- title={intl.formatMessage({
- defaultMessage: "Publish Products",
- description: "dialog header"
- })}
- >
-
- params.ids.length),
- displayQuantity: {maybe(() => params.ids.length)}
- }}
- />
-
-
-
- productBulkPublish({
- variables: {
- ids: params.ids,
- isPublished: false
- }
- })
- }
- title={intl.formatMessage({
- defaultMessage: "Unpublish Products",
- description: "dialog header"
- })}
- >
-
- params.ids.length),
- displayQuantity: {maybe(() => params.ids.length)}
+ counter: params?.ids?.length,
+ displayQuantity: {params?.ids?.length}
}}
/>
@@ -533,6 +449,7 @@ export const ProductList: React.FC = ({ params }) => {
warehouses={
warehouses.data?.warehouses.edges.map(edge => edge.node) || []
}
+ channels={channels}
onClose={closeModal}
onSubmit={data =>
exportProducts({
diff --git a/src/products/views/ProductList/__snapshots__/filters.test.ts.snap b/src/products/views/ProductList/__snapshots__/filters.test.ts.snap
index 7b7084a87..6a24a8073 100644
--- a/src/products/views/ProductList/__snapshots__/filters.test.ts.snap
+++ b/src/products/views/ProductList/__snapshots__/filters.test.ts.snap
@@ -63,9 +63,8 @@ Object {
"productTypes": Array [
"UHJvZHVjdFR5cGU6MQ==",
],
- "status": "published",
"stockStatus": "IN_STOCK",
}
`;
-exports[`Filtering URL params should not be empty if active filters are present 2`] = `"status=published&stockStatus=IN_STOCK&priceFrom=10&priceTo=20&categories%5B0%5D=878752&collections%5B0%5D=Q29sbGVjdGlvbjoc&productTypes%5B0%5D=UHJvZHVjdFR5cGU6MQ%3D%3D&attributes%5Bauthor%5D%5B0%5D=john-doe&attributes%5Bauthor%5D%5B1%5D=false&attributes%5Bbox-size%5D%5B0%5D=100g&attributes%5Bbox-size%5D%5B1%5D=500g&attributes%5Bbrand%5D%5B0%5D=saleor&attributes%5Bbrand%5D%5B1%5D=false&attributes%5Bcandy-box-size%5D%5B0%5D=100g&attributes%5Bcandy-box-size%5D%5B1%5D=500g&attributes%5Bcoffee-genre%5D%5B0%5D=arabica&attributes%5Bcoffee-genre%5D%5B1%5D=false&attributes%5Bcollar%5D%5B0%5D=round&attributes%5Bcollar%5D%5B1%5D=polo&attributes%5Bcolor%5D%5B0%5D=blue&attributes%5Bcolor%5D%5B1%5D=false&attributes%5Bcover%5D%5B0%5D=soft&attributes%5Bcover%5D%5B1%5D=middle-soft&attributes%5Bflavor%5D%5B0%5D=sour&attributes%5Bflavor%5D%5B1%5D=false&attributes%5Blanguage%5D%5B0%5D=english&attributes%5Blanguage%5D%5B1%5D=false&attributes%5Bpublisher%5D%5B0%5D=mirumee-press&attributes%5Bpublisher%5D%5B1%5D=false&attributes%5Bsize%5D%5B0%5D=xs&attributes%5Bsize%5D%5B1%5D=m"`;
+exports[`Filtering URL params should not be empty if active filters are present 2`] = `"stockStatus=IN_STOCK&priceFrom=10&priceTo=20&categories%5B0%5D=878752&collections%5B0%5D=Q29sbGVjdGlvbjoc&productTypes%5B0%5D=UHJvZHVjdFR5cGU6MQ%3D%3D&attributes%5Bauthor%5D%5B0%5D=john-doe&attributes%5Bauthor%5D%5B1%5D=false&attributes%5Bbox-size%5D%5B0%5D=100g&attributes%5Bbox-size%5D%5B1%5D=500g&attributes%5Bbrand%5D%5B0%5D=saleor&attributes%5Bbrand%5D%5B1%5D=false&attributes%5Bcandy-box-size%5D%5B0%5D=100g&attributes%5Bcandy-box-size%5D%5B1%5D=500g&attributes%5Bcoffee-genre%5D%5B0%5D=arabica&attributes%5Bcoffee-genre%5D%5B1%5D=false&attributes%5Bcollar%5D%5B0%5D=round&attributes%5Bcollar%5D%5B1%5D=polo&attributes%5Bcolor%5D%5B0%5D=blue&attributes%5Bcolor%5D%5B1%5D=false&attributes%5Bcover%5D%5B0%5D=soft&attributes%5Bcover%5D%5B1%5D=middle-soft&attributes%5Bflavor%5D%5B0%5D=sour&attributes%5Bflavor%5D%5B1%5D=false&attributes%5Blanguage%5D%5B0%5D=english&attributes%5Blanguage%5D%5B1%5D=false&attributes%5Bpublisher%5D%5B0%5D=mirumee-press&attributes%5Bpublisher%5D%5B1%5D=false&attributes%5Bsize%5D%5B0%5D=xs&attributes%5Bsize%5D%5B1%5D=m"`;
diff --git a/src/products/views/ProductList/filters.test.ts b/src/products/views/ProductList/filters.test.ts
index 4a55b212a..8da8539cc 100644
--- a/src/products/views/ProductList/filters.test.ts
+++ b/src/products/views/ProductList/filters.test.ts
@@ -13,7 +13,7 @@ import { productListFilterOpts } from "./fixtures";
describe("Filtering query params", () => {
it("should be empty object if no params given", () => {
const params: ProductListUrlFilters = {};
- const filterVariables = getFilterVariables(params);
+ const filterVariables = getFilterVariables(params, undefined);
expect(getExistingKeys(filterVariables)).toHaveLength(0);
});
@@ -25,7 +25,7 @@ describe("Filtering query params", () => {
status: true.toString(),
stockStatus: StockAvailability.IN_STOCK
};
- const filterVariables = getFilterVariables(params);
+ const filterVariables = getFilterVariables(params, "default-channel");
expect(getExistingKeys(filterVariables)).toHaveLength(3);
});
diff --git a/src/products/views/ProductList/filters.ts b/src/products/views/ProductList/filters.ts
index 44f6701d6..32c5891f8 100644
--- a/src/products/views/ProductList/filters.ts
+++ b/src/products/views/ProductList/filters.ts
@@ -2,8 +2,7 @@ import { UseSearchResult } from "@saleor/hooks/makeSearch";
import { findValueInEnum, maybe } from "@saleor/misc";
import {
ProductFilterKeys,
- ProductListFilterOpts,
- ProductStatus
+ ProductListFilterOpts
} from "@saleor/products/components/ProductListPage";
import {
InitialProductFilterData_attributes_edges_node,
@@ -182,10 +181,6 @@ export function getFilterOpts(
onSearchChange: productTypes.search.search,
value: maybe(() => dedupeFilter(params.productTypes), [])
},
- status: {
- active: maybe(() => params.status !== undefined, false),
- value: maybe(() => findValueInEnum(params.status, ProductStatus))
- },
stockStatus: {
active: maybe(() => params.stockStatus !== undefined, false),
value: maybe(() => findValueInEnum(params.stockStatus, StockAvailability))
@@ -194,7 +189,8 @@ export function getFilterOpts(
}
export function getFilterVariables(
- params: ProductListUrlFilters
+ params: ProductListUrlFilters,
+ channel: string | undefined
): ProductFilterInput {
return {
attributes: !!params.attributes
@@ -207,15 +203,14 @@ export function getFilterVariables(
}))
: null,
categories: params.categories !== undefined ? params.categories : null,
+ channel: channel || null,
collections: params.collections !== undefined ? params.collections : null,
- isPublished:
- params.status !== undefined
- ? params.status === ProductStatus.PUBLISHED
- : null,
- price: getGteLteVariables({
- gte: parseFloat(params.priceFrom),
- lte: parseFloat(params.priceTo)
- }),
+ price: channel
+ ? getGteLteVariables({
+ gte: parseFloat(params.priceFrom),
+ lte: parseFloat(params.priceTo)
+ })
+ : null,
productTypes:
params.productTypes !== undefined ? params.productTypes : null,
search: params.query,
@@ -271,13 +266,6 @@ export function getFilterQueryParam(
ProductListUrlFiltersWithMultipleValues.productTypes
);
- case ProductFilterKeys.status:
- return getSingleEnumValueQueryParam(
- filter,
- ProductListUrlFiltersEnum.status,
- ProductStatus
- );
-
case ProductFilterKeys.stock:
return getSingleEnumValueQueryParam(
filter,
diff --git a/src/products/views/ProductList/fixtures.ts b/src/products/views/ProductList/fixtures.ts
index ad31a116c..3e72e83a1 100644
--- a/src/products/views/ProductList/fixtures.ts
+++ b/src/products/views/ProductList/fixtures.ts
@@ -2,10 +2,7 @@ import { attributes } from "@saleor/attributes/fixtures";
import { categories } from "@saleor/categories/fixtures";
import { collections } from "@saleor/collections/fixtures";
import { fetchMoreProps, searchPageProps } from "@saleor/fixtures";
-import {
- ProductListFilterOpts,
- ProductStatus
-} from "@saleor/products/components/ProductListPage";
+import { ProductListFilterOpts } from "@saleor/products/components/ProductListPage";
import { productTypes } from "@saleor/productTypes/fixtures";
import { StockAvailability } from "@saleor/types/globalTypes";
@@ -75,10 +72,6 @@ export const productListFilterOpts: ProductListFilterOpts = {
],
value: [productTypes[4].id]
},
- status: {
- active: false,
- value: ProductStatus.PUBLISHED
- },
stockStatus: {
active: false,
value: StockAvailability.IN_STOCK
diff --git a/src/products/views/ProductList/sort.ts b/src/products/views/ProductList/sort.ts
index 893190925..b3e431228 100644
--- a/src/products/views/ProductList/sort.ts
+++ b/src/products/views/ProductList/sort.ts
@@ -23,7 +23,8 @@ export function getSortQueryField(
}
export function getSortQueryVariables(
- params: ProductListUrlQueryParams
+ params: ProductListUrlQueryParams,
+ channel: string
): ProductOrder {
if (params.sort === ProductListUrlSortField.attribute) {
return {
@@ -32,6 +33,7 @@ export function getSortQueryVariables(
};
}
return {
+ channel,
direction: getOrderDirection(params.asc),
field: getSortQueryField(params.sort)
};
diff --git a/src/products/views/ProductUpdate/ProductUpdate.tsx b/src/products/views/ProductUpdate/ProductUpdate.tsx
index 294db7989..d25d5febc 100644
--- a/src/products/views/ProductUpdate/ProductUpdate.tsx
+++ b/src/products/views/ProductUpdate/ProductUpdate.tsx
@@ -2,27 +2,36 @@ import placeholderImg from "@assets/images/placeholder255x255.png";
import DialogContentText from "@material-ui/core/DialogContentText";
import IconButton from "@material-ui/core/IconButton";
import DeleteIcon from "@material-ui/icons/Delete";
+import { useChannelsList } from "@saleor/channels/queries";
+import {
+ ChannelData,
+ createChannelsDataWithPrice,
+ createSortedChannelsDataFromProduct
+} from "@saleor/channels/utils";
import ActionDialog from "@saleor/components/ActionDialog";
+import ChannelsAvailabilityDialog from "@saleor/components/ChannelsAvailabilityDialog";
import NotFoundPage from "@saleor/components/NotFoundPage";
import { WindowTitle } from "@saleor/components/WindowTitle";
import { DEFAULT_INITIAL_SEARCH_DATA } from "@saleor/config";
import useBulkActions from "@saleor/hooks/useBulkActions";
+import useChannels from "@saleor/hooks/useChannels";
import useNavigator from "@saleor/hooks/useNavigator";
import useNotifier from "@saleor/hooks/useNotifier";
import useOnSetDefaultVariant from "@saleor/hooks/useOnSetDefaultVariant";
import useShop from "@saleor/hooks/useShop";
-import useStateFromProps from "@saleor/hooks/useStateFromProps";
import { commonMessages } from "@saleor/intl";
import {
+ useProductChannelListingUpdate,
useProductDeleteMutation,
useProductImageCreateMutation,
useProductImageDeleteMutation,
useProductImagesReorder,
- useProductSetAvailabilityForPurchase,
useProductUpdateMutation,
useProductVariantBulkDeleteMutation,
+ useProductVariantChannelListingUpdate,
useProductVariantReorderMutation,
- useSimpleProductUpdateMutation
+ useSimpleProductUpdateMutation,
+ useVariantCreateMutation
} from "@saleor/products/mutations";
import useCategorySearch from "@saleor/searches/useCategorySearch";
import useCollectionSearch from "@saleor/searches/useCollectionSearch";
@@ -37,7 +46,7 @@ import { warehouseAddPath } from "@saleor/warehouses/urls";
import React from "react";
import { FormattedMessage, useIntl } from "react-intl";
-import { getMutationState, maybe } from "../../../misc";
+import { getMutationState } from "../../../misc";
import ProductUpdatePage from "../../components/ProductUpdatePage";
import { useProductDetails } from "../../queries";
import { ProductImageCreateVariables } from "../../types/ProductImageCreate";
@@ -94,12 +103,16 @@ export const ProductUpdate: React.FC = ({ id, params }) => {
const shop = useShop();
const [updateMetadata] = useMetadataUpdate({});
const [updatePrivateMetadata] = usePrivateMetadataUpdate({});
+ const [
+ productVariantCreate,
+ productVariantCreateOpts
+ ] = useVariantCreateMutation({});
+
+ const { data: channelsData } = useChannelsList({});
const { data, loading, refetch } = useProductDetails({
displayLoader: true,
- variables: {
- id
- }
+ variables: { id }
});
const handleUpdate = (data: ProductUpdateMutationResult) => {
@@ -175,29 +188,50 @@ export const ProductUpdate: React.FC = ({ id, params }) => {
}
});
- const [
- setProductAvailability,
- productAvailabilityOpts
- ] = useProductSetAvailabilityForPurchase({
+ const product = data?.product;
+
+ const allChannels: ChannelData[] = createChannelsDataWithPrice(
+ product,
+ channelsData?.channels
+ ).sort((channel, nextChannel) =>
+ channel.name.localeCompare(nextChannel.name)
+ );
+
+ const productChannelsChoices: ChannelData[] = createSortedChannelsDataFromProduct(
+ product
+ );
+ const {
+ channelListElements,
+ channelsToggle,
+ currentChannels,
+ handleChannelsConfirm,
+ handleChannelsModalClose,
+ handleChannelsModalOpen,
+ isChannelSelected,
+ isChannelsModalOpen,
+ setCurrentChannels,
+ toggleAllChannels
+ } = useChannels(productChannelsChoices);
+
+ const [updateChannels, updateChannelsOpts] = useProductChannelListingUpdate({
onCompleted: data => {
- const errors = data?.productSetAvailabilityForPurchase?.errors;
- if (errors?.length === 0) {
- const updatedProduct = data?.productSetAvailabilityForPurchase?.product;
- setProduct(product => ({
- ...product,
- availableForPurchase: updatedProduct.availableForPurchase,
- isAvailableForPurchase: updatedProduct.isAvailableForPurchase
- }));
- notify({
- status: "success",
- text: intl.formatMessage({
- defaultMessage: "Product availability updated",
- description: "snackbar text"
- })
- });
+ if (data.productChannelListingUpdate.errors.length === 0) {
+ const updatedProductChannelsChoices: ChannelData[] = createSortedChannelsDataFromProduct(
+ data.productChannelListingUpdate.product
+ );
+ setCurrentChannels(updatedProductChannelsChoices);
}
}
});
+ const [
+ updateVariantChannels,
+ updateVariantChannelsOpts
+ ] = useProductVariantChannelListingUpdate({});
+
+ const channelChoices = product?.channelListings.map(listing => ({
+ label: listing.channel.name,
+ value: listing.channel.id
+ }));
const [openModal, closeModal] = createDialogActionHandlers<
ProductUrlDialog,
@@ -206,12 +240,9 @@ export const ProductUpdate: React.FC = ({ id, params }) => {
const handleBack = () => navigate(productListUrl());
- const [product, setProduct] = useStateFromProps(data?.product);
-
if (product === null) {
return ;
}
-
const handleVariantAdd = () => navigate(productVariantAddUrl(id));
const handleImageDelete = (id: string) => () =>
@@ -224,11 +255,14 @@ export const ProductUpdate: React.FC = ({ id, params }) => {
product,
variables => updateProduct({ variables }),
variables => updateSimpleProduct({ variables }),
- variables => setProductAvailability({ variables })
+ updateChannels,
+ updateVariantChannels,
+ productVariantCreate
),
variables => updateMetadata({ variables }),
variables => updatePrivateMetadata({ variables })
);
+
const handleImageUpload = createImageUploadHandler(id, variables =>
createProductImage({ variables })
);
@@ -250,57 +284,87 @@ export const ProductUpdate: React.FC = ({ id, params }) => {
deleteProductOpts.loading ||
reorderProductImagesOpts.loading ||
updateProductOpts.loading ||
- productAvailabilityOpts.loading ||
reorderProductVariantsOpts.loading ||
+ updateChannelsOpts.loading ||
+ updateVariantChannelsOpts.loading ||
+ productVariantCreateOpts.loading ||
loading;
const formTransitionState = getMutationState(
updateProductOpts.called || updateSimpleProductOpts.called,
updateProductOpts.loading || updateSimpleProductOpts.loading,
- maybe(() => updateProductOpts.data.productUpdate.errors),
- maybe(() => updateSimpleProductOpts.data.productUpdate.errors),
- maybe(() => updateSimpleProductOpts.data.productVariantUpdate.errors)
+ updateProductOpts.data?.productUpdate.errors,
+ updateSimpleProductOpts.data?.productUpdate.errors,
+ updateSimpleProductOpts.data?.productVariantUpdate.errors
);
- const categories = maybe(
- () => searchCategoriesOpts.data.search.edges,
- []
- ).map(edge => edge.node);
- const collections = maybe(
- () => searchCollectionsOpts.data.search.edges,
- []
- ).map(edge => edge.node);
+ const categories = (searchCategoriesOpts?.data?.search?.edges || []).map(
+ edge => edge.node
+ );
+ const collections = (searchCollectionsOpts?.data?.search?.edges || []).map(
+ edge => edge.node
+ );
const errors = [
- ...maybe(() => updateProductOpts.data.productUpdate.errors, []),
- ...maybe(() => updateSimpleProductOpts.data.productUpdate.errors, [])
+ ...(updateProductOpts.data?.productUpdate.errors || []),
+ ...(updateSimpleProductOpts.data?.productUpdate.errors || []),
+ ...(productVariantCreateOpts.data?.productVariantCreate.errors || [])
];
const onSetDefaultVariant = useOnSetDefaultVariant(
product ? product.id : null,
null
);
+ const channelsErrors = [
+ ...(updateChannelsOpts?.data?.productChannelListingUpdate?.errors || []),
+ ...(updateVariantChannelsOpts?.data?.productVariantChannelListingUpdate
+ ?.errors || [])
+ ];
return (
<>
- data.product.name)} />
+
+ {!!allChannels?.length && (
+
+ )}
data.product.images)}
- header={maybe(() => product.name)}
+ images={data?.product?.images}
+ header={product?.name}
placeholderImage={placeholderImg}
product={product}
warehouses={
warehouses.data?.warehouses.edges.map(edge => edge.node) || []
}
taxTypes={data?.taxTypes}
- variants={maybe(() => product.variants)}
+ variants={product?.variants}
onBack={handleBack}
onDelete={() => openModal("remove")}
onImageReorder={handleImageReorder}
@@ -331,19 +395,17 @@ export const ProductUpdate: React.FC = ({ id, params }) => {
toggle={toggle}
toggleAll={toggleAll}
fetchMoreCategories={{
- hasMore: maybe(
- () => searchCategoriesOpts.data.search.pageInfo.hasNextPage
- ),
+ hasMore: searchCategoriesOpts?.data?.search?.pageInfo?.hasNextPage,
loading: searchCategoriesOpts.loading,
onFetchMore: loadMoreCategories
}}
fetchMoreCollections={{
- hasMore: maybe(
- () => searchCollectionsOpts.data.search.pageInfo.hasNextPage
- ),
+ hasMore: searchCollectionsOpts?.data?.search?.pageInfo?.hasNextPage,
loading: searchCollectionsOpts.loading,
onFetchMore: loadMoreCollections
}}
+ openChannelsModal={handleChannelsModalOpen}
+ onChannelsChange={setCurrentChannels}
/>
= ({ id, params }) => {
defaultMessage="{counter,plural,one{Are you sure you want to delete this variant?} other{Are you sure you want to delete {displayQuantity} variants?}}"
description="dialog content"
values={{
- counter: maybe(() => params.ids.length),
- displayQuantity: {maybe(() => params.ids.length)}
+ counter: params?.ids?.length,
+ displayQuantity: {params?.ids?.length}
}}
/>
diff --git a/src/products/views/ProductUpdate/handlers.ts b/src/products/views/ProductUpdate/handlers.ts
index c68e32bf5..79d439494 100644
--- a/src/products/views/ProductUpdate/handlers.ts
+++ b/src/products/views/ProductUpdate/handlers.ts
@@ -1,19 +1,25 @@
+import { createSortedChannelsDataFromProduct } from "@saleor/channels/utils";
import { BulkStockErrorFragment } from "@saleor/fragments/types/BulkStockErrorFragment";
+import { ProductChannelListingErrorFragment } from "@saleor/fragments/types/ProductChannelListingErrorFragment";
import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment";
import { StockErrorFragment } from "@saleor/fragments/types/StockErrorFragment";
-import { decimal, weight } from "@saleor/misc";
+import { weight } from "@saleor/misc";
import { ProductUpdatePageSubmitData } from "@saleor/products/components/ProductUpdatePage";
+import {
+ ProductChannelListingUpdate,
+ ProductChannelListingUpdateVariables
+} from "@saleor/products/types/ProductChannelListingUpdate";
import { ProductDetails_product } from "@saleor/products/types/ProductDetails";
import { ProductImageCreateVariables } from "@saleor/products/types/ProductImageCreate";
import { ProductImageReorderVariables } from "@saleor/products/types/ProductImageReorder";
-import {
- ProductSetAvailabilityForPurchase,
- ProductSetAvailabilityForPurchaseVariables
-} from "@saleor/products/types/ProductSetAvailabilityForPurchase";
import {
ProductUpdate,
ProductUpdateVariables
} from "@saleor/products/types/ProductUpdate";
+import {
+ ProductVariantChannelListingUpdate,
+ ProductVariantChannelListingUpdateVariables
+} from "@saleor/products/types/ProductVariantChannelListingUpdate";
import { ProductVariantCreateData_product } from "@saleor/products/types/ProductVariantCreateData";
import { ProductVariantDetails_productVariant_product } from "@saleor/products/types/ProductVariantDetails";
import { ProductVariantReorderVariables } from "@saleor/products/types/ProductVariantReorder";
@@ -21,12 +27,73 @@ import {
SimpleProductUpdate,
SimpleProductUpdateVariables
} from "@saleor/products/types/SimpleProductUpdate";
+import {
+ VariantCreate,
+ VariantCreateVariables
+} from "@saleor/products/types/VariantCreate";
import { mapFormsetStockToStockInput } from "@saleor/products/utils/data";
-import { getProductAvailabilityVariables } from "@saleor/products/utils/handlers";
+import { getAvailabilityVariables } from "@saleor/products/utils/handlers";
import { ReorderEvent } from "@saleor/types";
+import { diff } from "fast-array-diff";
import { MutationFetchResult } from "react-apollo";
import { arrayMove } from "react-sortable-hoc";
+const getSimpleProductVariables = (
+ productVariables: ProductUpdateVariables,
+ data: ProductUpdatePageSubmitData,
+ productId: string
+) => ({
+ ...productVariables,
+ addStocks: data.addStocks.map(mapFormsetStockToStockInput),
+ deleteStocks: data.removeStocks,
+ input: {
+ ...productVariables.input,
+ weight: weight(data.weight)
+ },
+ productVariantId: productId,
+ productVariantInput: {
+ sku: data.sku,
+ trackInventory: data.trackInventory
+ },
+ updateStocks: data.updateStocks.map(mapFormsetStockToStockInput)
+});
+
+const getSimpleProductErrors = (data: SimpleProductUpdate) => [
+ ...data.productUpdate.errors,
+ ...data.productVariantStocksCreate.errors,
+ ...data.productVariantStocksDelete.errors,
+ ...data.productVariantStocksUpdate.errors
+];
+
+const getChannelsVariables = (
+ data: ProductUpdatePageSubmitData,
+ product: ProductDetails_product
+) => {
+ const productChannels = createSortedChannelsDataFromProduct(product);
+ const diffChannels = diff(
+ productChannels,
+ data.channelListings,
+ (a, b) => a.id === b.id
+ );
+
+ return {
+ id: product.id,
+ input: {
+ addChannels: getAvailabilityVariables(data.channelListings),
+ removeChannels: diffChannels.removed?.map(
+ removedChannel => removedChannel.id
+ )
+ }
+ };
+};
+
+const getVariantChannelsInput = (data: ProductUpdatePageSubmitData) =>
+ data.channelListings.map(listing => ({
+ channelId: listing.id,
+ costPrice: listing.costPrice || null,
+ price: listing.price
+ }));
+
export function createUpdateHandler(
product: ProductDetails_product,
updateProduct: (
@@ -35,9 +102,15 @@ export function createUpdateHandler(
updateSimpleProduct: (
variables: SimpleProductUpdateVariables
) => Promise>,
- setProductAvailability: (
- variables: ProductSetAvailabilityForPurchaseVariables
- ) => Promise>
+ updateChannels: (options: {
+ variables: ProductChannelListingUpdateVariables;
+ }) => Promise>,
+ updateVariantChannels: (options: {
+ variables: ProductVariantChannelListingUpdateVariables;
+ }) => Promise>,
+ productVariantCreate: (options: {
+ variables: VariantCreateVariables;
+ }) => Promise>
) {
return async (data: ProductUpdatePageSubmitData) => {
const productVariables: ProductUpdateVariables = {
@@ -47,72 +120,89 @@ export function createUpdateHandler(
id: attribute.id,
values: attribute.value[0] === "" ? [] : attribute.value
})),
- basePrice: decimal(data.basePrice),
category: data.category,
chargeTaxes: data.chargeTaxes,
collections: data.collections,
descriptionJson: JSON.stringify(data.description),
- isPublished: data.isPublished,
name: data.name,
- publicationDate:
- data.publicationDate !== "" ? data.publicationDate : null,
seo: {
description: data.seoDescription,
title: data.seoTitle
},
slug: data.slug,
- taxCode: data.changeTaxCode ? data.taxCode : null,
- visibleInListings: data.visibleInListings
+ taxCode: data.changeTaxCode ? data.taxCode : null
}
};
let errors: Array<
- ProductErrorFragment | StockErrorFragment | BulkStockErrorFragment
+ | ProductErrorFragment
+ | StockErrorFragment
+ | BulkStockErrorFragment
+ | ProductChannelListingErrorFragment
>;
if (product.productType.hasVariants) {
const result = await updateProduct(productVariables);
errors = result.data.productUpdate.errors;
- } else {
- const result = await updateSimpleProduct({
- ...productVariables,
- addStocks: data.addStocks.map(mapFormsetStockToStockInput),
- deleteStocks: data.removeStocks,
- input: {
- ...productVariables.input,
- weight: weight(data.weight)
- },
- productVariantId: product.variants[0].id,
- productVariantInput: {
- sku: data.sku,
- trackInventory: data.trackInventory
- },
- updateStocks: data.updateStocks.map(mapFormsetStockToStockInput)
- });
- errors = [
- ...result.data.productUpdate.errors,
- ...result.data.productVariantStocksCreate.errors,
- ...result.data.productVariantStocksDelete.errors,
- ...result.data.productVariantStocksUpdate.errors,
- ...result.data.productVariantUpdate.errors
- ];
- }
- const { isAvailableForPurchase, availableForPurchase } = data;
- if (
- isAvailableForPurchase !== product.isAvailableForPurchase ||
- availableForPurchase !== product.availableForPurchase
- ) {
- const variables = getProductAvailabilityVariables({
- availableForPurchase,
- isAvailableForPurchase,
- productId: product.id
- });
- const availabilityResult = await setProductAvailability(variables);
- errors = [
- ...errors,
- ...availabilityResult.data.productSetAvailabilityForPurchase.errors
- ];
+ updateChannels({
+ variables: getChannelsVariables(data, product)
+ });
+ } else {
+ if (!product.variants.length) {
+ const productVariantResult = await productVariantCreate({
+ variables: {
+ input: {
+ attributes:
+ product.productType.variantAttributes?.map(attribute => ({
+ id: attribute.id,
+ values: attribute.values.map(value => value.slug)
+ })) || [],
+ product: product.id,
+ sku: data.sku,
+ stocks: data.updateStocks.map(mapFormsetStockToStockInput)
+ }
+ }
+ });
+ errors = productVariantResult.data.productVariantCreate.errors;
+
+ const variantId =
+ productVariantResult.data.productVariantCreate?.productVariant?.id;
+ if (variantId) {
+ updateVariantChannels({
+ variables: {
+ id: variantId,
+ input: getVariantChannelsInput(data)
+ }
+ });
+ updateChannels({
+ variables: getChannelsVariables(data, product)
+ });
+ const result = await updateSimpleProduct(
+ getSimpleProductVariables(productVariables, data, variantId)
+ );
+ errors = [...errors, ...getSimpleProductErrors(result.data)];
+ }
+ } else {
+ const result = await updateSimpleProduct(
+ getSimpleProductVariables(
+ productVariables,
+ data,
+ product.variants[0].id
+ )
+ );
+ errors = getSimpleProductErrors(result.data);
+
+ await updateChannels({
+ variables: getChannelsVariables(data, product)
+ });
+ updateVariantChannels({
+ variables: {
+ id: product.variants[0].id,
+ input: getVariantChannelsInput(data)
+ }
+ });
+ }
}
return errors;
diff --git a/src/products/views/ProductVariant.tsx b/src/products/views/ProductVariant.tsx
index 7b99e3ba3..f383700ae 100644
--- a/src/products/views/ProductVariant.tsx
+++ b/src/products/views/ProductVariant.tsx
@@ -1,4 +1,5 @@
import placeholderImg from "@assets/images/placeholder255x255.png";
+import { createVariantChannels } from "@saleor/channels/utils";
import NotFoundPage from "@saleor/components/NotFoundPage";
import { WindowTitle } from "@saleor/components/WindowTitle";
import useNavigator from "@saleor/hooks/useNavigator";
@@ -6,6 +7,8 @@ import useNotifier from "@saleor/hooks/useNotifier";
import useOnSetDefaultVariant from "@saleor/hooks/useOnSetDefaultVariant";
import useShop from "@saleor/hooks/useShop";
import { commonMessages } from "@saleor/intl";
+import { useProductVariantChannelListingUpdate } from "@saleor/products/mutations";
+import { ProductVariantDetails_productVariant } from "@saleor/products/types/ProductVariantDetails";
import createDialogActionHandlers from "@saleor/utils/handlers/dialogActionHandlers";
import createMetadataUpdateHandler from "@saleor/utils/handlers/metadataUpdateHandler";
import {
@@ -17,11 +20,10 @@ import { warehouseAddPath } from "@saleor/warehouses/urls";
import React, { useEffect, useState } from "react";
import { useIntl } from "react-intl";
-import { decimal, weight } from "../../misc";
+import { weight } from "../../misc";
import ProductVariantDeleteDialog from "../components/ProductVariantDeleteDialog";
-import ProductVariantPage, {
- ProductVariantPageSubmitData
-} from "../components/ProductVariantPage";
+import ProductVariantPage from "../components/ProductVariantPage";
+import { ProductVariantUpdateSubmitData } from "../components/ProductVariantPage/form";
import {
useProductVariantReorderMutation,
useVariantDeleteMutation,
@@ -79,6 +81,11 @@ export const ProductVariant: React.FC = ({
const [updateMetadata] = useMetadataUpdate({});
const [updatePrivateMetadata] = usePrivateMetadataUpdate({});
+ const [
+ updateChannels,
+ updateChannelsOpts
+ ] = useProductVariantChannelListingUpdate({});
+
const [openModal] = createDialogActionHandlers<
ProductVariantEditUrlDialog,
ProductVariantEditUrlQueryParams
@@ -117,7 +124,35 @@ export const ProductVariant: React.FC |