diff --git a/introspection.json b/introspection.json index ad209ac50..47ae24fae 100644 --- a/introspection.json +++ b/introspection.json @@ -2478,6 +2478,29 @@ "enumValues": null, "possibleTypes": null }, + { + "kind": "ENUM", + "name": "AllocationStrategyEnum", + "description": "Determine the allocation strategy for the channel.\n\n PRIORITIZE_SORTING_ORDER - the allocation is prioritized by the warehouses' sort\n order within the channel\n\n PRIORITIZE_HIGH_STOCK - the allocation is prioritized by the highest available\n quantity in stocks\n ", + "fields": null, + "inputFields": null, + "interfaces": null, + "enumValues": [ + { + "name": "PRIORITIZE_SORTING_ORDER", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "PRIORITIZE_HIGH_STOCK", + "description": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "possibleTypes": null + }, { "kind": "OBJECT", "name": "App", @@ -12182,6 +12205,22 @@ }, "isDeprecated": false, "deprecationReason": null + }, + { + "name": "stockSettings", + "description": "Define the stock setting for this channel.\n\nAdded in Saleor 3.7.\n\nNote: this API is currently in Feature Preview and can be subject to changes at later point.\n\nRequires one of the following permissions: AUTHENTICATED_APP, AUTHENTICATED_STAFF_USER.", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "StockSettings", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null } ], "inputFields": null, @@ -12355,6 +12394,18 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "stockSettings", + "description": "The channel stock settings.\n\nAdded in Saleor 3.7.\n\nNote: this API is currently in Feature Preview and can be subject to changes at later point.", + "type": { + "kind": "INPUT_OBJECT", + "name": "StockSettingsInput", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "addShippingZones", "description": "List of shipping zones to assign to the channel.", @@ -12943,6 +12994,53 @@ ], "possibleTypes": null }, + { + "kind": "OBJECT", + "name": "ChannelReorderWarehouses", + "description": "Reorder the warehouses of a channel.\n\nAdded in Saleor 3.7.\n\nNote: this API is currently in Feature Preview and can be subject to changes at later point. \n\nRequires one of the following permissions: MANAGE_CHANNELS.", + "fields": [ + { + "name": "channel", + "description": "Channel within the warehouses are reordered.", + "args": [], + "type": { + "kind": "OBJECT", + "name": "Channel", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "errors", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "ChannelError", + "ofType": null + } + } + } + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, { "kind": "OBJECT", "name": "ChannelStatusChanged", @@ -13109,6 +13207,18 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "stockSettings", + "description": "The channel stock settings.\n\nAdded in Saleor 3.7.\n\nNote: this API is currently in Feature Preview and can be subject to changes at later point.", + "type": { + "kind": "INPUT_OBJECT", + "name": "StockSettingsInput", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "addShippingZones", "description": "List of shipping zones to assign to the channel.", @@ -51670,6 +51780,59 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "channelReorderWarehouses", + "description": "Reorder the warehouses of a channel.\n\nAdded in Saleor 3.7.\n\nNote: this API is currently in Feature Preview and can be subject to changes at later point. \n\nRequires one of the following permissions: MANAGE_CHANNELS.", + "args": [ + { + "name": "channelId", + "description": "ID of a channel.", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "moves", + "description": "The list of reordering operations for given channel warehouses.", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "LIST", + "name": null, + "ofType": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "INPUT_OBJECT", + "name": "ReorderInput", + "ofType": null + } + } + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "type": { + "kind": "OBJECT", + "name": "ChannelReorderWarehouses", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "attributeCreate", "description": "Creates an attribute.", @@ -59493,6 +59656,18 @@ "defaultValue": "false", "isDeprecated": false, "deprecationReason": null + }, + { + "name": "trackingNumber", + "description": "Fulfillment tracking number.\n\nAdded in Saleor 3.6.", + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null } ], "interfaces": null, @@ -76932,6 +77107,18 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "name", + "description": "Variant name.", + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "trackInventory", "description": "Determines if the inventory of this variant should be tracked. If false, the quantity won't change when customers buy this item.", @@ -77554,6 +77741,18 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "name", + "description": "Variant name.", + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "trackInventory", "description": "Determines if the inventory of this variant should be tracked. If false, the quantity won't change when customers buy this item.", @@ -78019,6 +78218,18 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "name", + "description": "Variant name.", + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "trackInventory", "description": "Determines if the inventory of this variant should be tracked. If false, the quantity won't change when customers buy this item.", @@ -93712,6 +93923,60 @@ "enumValues": null, "possibleTypes": null }, + { + "kind": "OBJECT", + "name": "StockSettings", + "description": "Represents the channel stock settings.\n\nAdded in Saleor 3.7.\n\nNote: this API is currently in Feature Preview and can be subject to changes at later point.", + "fields": [ + { + "name": "allocationStrategy", + "description": "Allocation strategy options. Strategy defines the preference of warehouses for allocations and reservations.", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "ENUM", + "name": "AllocationStrategyEnum", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "INPUT_OBJECT", + "name": "StockSettingsInput", + "description": null, + "fields": null, + "inputFields": [ + { + "name": "allocationStrategy", + "description": "Allocation strategy options. Strategy defines the preference of warehouses for allocations and reservations.", + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "ENUM", + "name": "AllocationStrategyEnum", + "ofType": null + } + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, { "kind": "ENUM", "name": "StorePaymentMethodEnum", @@ -96905,15 +97170,19 @@ "description": "List of all user's addresses.", "args": [], "type": { - "kind": "LIST", + "kind": "NON_NULL", "name": null, "ofType": { - "kind": "NON_NULL", + "kind": "LIST", "name": null, "ofType": { - "kind": "OBJECT", - "name": "Address", - "ofType": null + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "Address", + "ofType": null + } } } }, @@ -102864,15 +103133,15 @@ }, { "name": "secretKey", - "description": "Used to create a hash signature with each payload.\n\nIf not set, since Saleor 3.5, your payload will be signed using private key used also to sign JWT tokens.", + "description": "Used to create a hash signature for each payload.", "args": [], "type": { "kind": "SCALAR", "name": "String", "ofType": null }, - "isDeprecated": false, - "deprecationReason": null + "isDeprecated": true, + "deprecationReason": "This field will be removed in Saleor 4.0. As of Saleor 3.5, webhook payloads default to signing using a verifiable JWS." }, { "name": "subscriptionQuery", @@ -103085,7 +103354,7 @@ }, { "name": "secretKey", - "description": "The secret key used to create a hash signature with each payload.", + "description": "The secret key used to create a hash signature with each payload.\n\nDEPRECATED: this field will be removed in Saleor 4.0. As of Saleor 3.5, webhook payloads default to signing using a verifiable JWS.", "type": { "kind": "SCALAR", "name": "String", @@ -105465,7 +105734,7 @@ }, { "name": "secretKey", - "description": "Use to create a hash signature with each payload.", + "description": "Use to create a hash signature with each payload.\n\nDEPRECATED: this field will be removed in Saleor 4.0. As of Saleor 3.5, webhook payloads default to signing using a verifiable JWS.", "type": { "kind": "SCALAR", "name": "String", diff --git a/locale/defaultMessages.json b/locale/defaultMessages.json index 43b01f924..d6c7fa689 100644 --- a/locale/defaultMessages.json +++ b/locale/defaultMessages.json @@ -166,6 +166,10 @@ "context": "header, allocated product quantity", "string": "Allocated" }, + "/DzBc6": { + "context": "section description", + "string": "Strategy defines the preference of warehouses for stock allocations and reservations." + }, "/JENWS": { "string": "Reduced Tax Rates" }, @@ -735,6 +739,10 @@ "context": "notification", "string": "Removed pages" }, + "423QsF": { + "context": "option title", + "string": "Prioritize warehouses with highest stock" + }, "43AOvZ": { "context": "alert group message", "string": "You will not be able to finalize this draft because:" @@ -2104,6 +2112,10 @@ "context": "selected customer gift card is sent to subtitle", "string": "Selected customer will be sent the generated gift card code. Someone else can redeem the gift card code. Gift card will be assigned to account which redeemed the code." }, + "FSOOH7": { + "context": "option title", + "string": "Prioritize warehouses by sorting order" + }, "FSinkL": { "context": "variant stock status", "string": "Available inventory at:" @@ -2112,6 +2124,10 @@ "context": "ExitFormPrompt title", "string": "You have unsaved changes" }, + "FYfoiF": { + "context": "section name", + "string": "Allocation strategy" + }, "Fbr4Vp": { "context": "dialog header", "string": "Permissions" @@ -2207,6 +2223,10 @@ "context": "tab name", "string": "All Collections" }, + "G5NKx6": { + "context": "tooltip", + "string": "Checkout reservation time threshold is enabled in settings." + }, "G7mu0y": { "string": "The GraphQL API is beta quality. It is not fully optimized and some mutations or queries may be missing." }, @@ -2388,6 +2408,10 @@ "HMD+ib": { "string": "Last order" }, + "HN1Gvw": { + "context": "option description", + "string": "Allocate order-line to a warehouse with the most stock. If not enough stock is available in a single warehouse, the remaining quantity is allocated in the next warehouse with the most stock and repeated if necessary." + }, "HP6m+q": { "string": "Attributes and Product Types" }, @@ -2576,10 +2600,6 @@ "context": "change warehouse dialog description", "string": "Choose warehouse from which you want to fulfill {productName}" }, - "ImTelT": { - "context": "card subtitle", - "string": "Select warehouses that will be used in this channel. You can assign warehouses to multiple channels." - }, "IoCMjg": { "context": "no collections", "string": "No collections found" @@ -4679,6 +4699,10 @@ "context": "imperial unit system", "string": "Imperial" }, + "YiC3cn": { + "context": "option description", + "string": "Allocate stock in the first warehouse in the list assigned to this channel. If stock is insufficient, the remaining quantity is allocated in the next warehouse on the list and repeated if necessary." + }, "YicEbK": { "string": "Search Atrtibuttes" }, @@ -5750,6 +5774,10 @@ "context": "voucher country range", "string": "Countries" }, + "icb1fc": { + "context": "tooltip", + "string": "Stock allocations occur when:" + }, "icz/jb": { "context": "customer", "string": "Join Date" @@ -6616,6 +6644,10 @@ "context": "key-value field input", "string": "Key" }, + "q5Lfp4": { + "context": "tooltip", + "string": "Order contains products that have \"Track inventory\" enabled." + }, "q8ep2I": { "context": "dialog header", "string": "Delete Customers" @@ -7253,6 +7285,10 @@ "v1pNHW": { "string": "Attribute Class" }, + "v2+u4c": { + "context": "card subtitle", + "string": "Assign and sort warehouses that will be used in this channel (warehouses can be assigned in multiple channels)." + }, "v3WWK+": { "string": "Status is invalid" }, diff --git a/schema.graphql b/schema.graphql index 374e03ab9..16a4da550 100644 --- a/schema.graphql +++ b/schema.graphql @@ -411,6 +411,21 @@ type Allocation implements Node { warehouse: Warehouse! } +""" +Determine the allocation strategy for the channel. + + PRIORITIZE_SORTING_ORDER - the allocation is prioritized by the warehouses' sort + order within the channel + + PRIORITIZE_HIGH_STOCK - the allocation is prioritized by the highest available + quantity in stocks + +""" +enum AllocationStrategyEnum { + PRIORITIZE_SORTING_ORDER + PRIORITIZE_HIGH_STOCK +} + """Represents app data.""" type App implements Node & ObjectWithMetadata { id: ID! @@ -2540,6 +2555,17 @@ type Channel implements Node { Note: this API is currently in Feature Preview and can be subject to changes at later point. """ availableShippingMethodsPerCountry(countries: [CountryCode!]): [ShippingMethodsPerCountry!] + + """ + Define the stock setting for this channel. + + Added in Saleor 3.7. + + Note: this API is currently in Feature Preview and can be subject to changes at later point. + + Requires one of the following permissions: AUTHENTICATED_APP, AUTHENTICATED_STAFF_USER. + """ + stockSettings: StockSettings! } """ @@ -2569,6 +2595,15 @@ input ChannelCreateInput { """isActive flag.""" isActive: Boolean + """ + The channel stock settings. + + Added in Saleor 3.7. + + Note: this API is currently in Feature Preview and can be subject to changes at later point. + """ + stockSettings: StockSettingsInput + """List of shipping zones to assign to the channel.""" addShippingZones: [ID!] @@ -2708,6 +2743,21 @@ enum ChannelErrorCode { DUPLICATED_INPUT_ITEM } +""" +Reorder the warehouses of a channel. + +Added in Saleor 3.7. + +Note: this API is currently in Feature Preview and can be subject to changes at later point. + +Requires one of the following permissions: MANAGE_CHANNELS. +""" +type ChannelReorderWarehouses { + """Channel within the warehouses are reordered.""" + channel: Channel + errors: [ChannelError!]! +} + """ Event sent when channel status has changed. @@ -2747,6 +2797,15 @@ input ChannelUpdateInput { """isActive flag.""" isActive: Boolean + """ + The channel stock settings. + + Added in Saleor 3.7. + + Note: this API is currently in Feature Preview and can be subject to changes at later point. + """ + stockSettings: StockSettingsInput + """List of shipping zones to assign to the channel.""" addShippingZones: [ID!] @@ -11485,6 +11544,23 @@ type Mutation { id: ID! ): ChannelDeactivate + """ + Reorder the warehouses of a channel. + + Added in Saleor 3.7. + + Note: this API is currently in Feature Preview and can be subject to changes at later point. + + Requires one of the following permissions: MANAGE_CHANNELS. + """ + channelReorderWarehouses( + """ID of a channel.""" + channelId: ID! + + """The list of reordering operations for given channel warehouses.""" + moves: [ReorderInput!]! + ): ChannelReorderWarehouses + """Creates an attribute.""" attributeCreate( """Fields required to create an attribute.""" @@ -13182,6 +13258,13 @@ input OrderFulfillInput { """If true, then allow proceed fulfillment when stock is exceeded.""" allowStockToBeExceeded: Boolean = false + + """ + Fulfillment tracking number. + + Added in Saleor 3.6. + """ + trackingNumber: String } input OrderFulfillLineInput { @@ -17016,6 +17099,9 @@ input ProductVariantBulkCreateInput { """Stock keeping unit.""" sku: String + """Variant name.""" + name: String + """ Determines if the inventory of this variant should be tracked. If false, the quantity won't change when customers buy this item. """ @@ -17154,6 +17240,9 @@ input ProductVariantCreateInput { """Stock keeping unit.""" sku: String + """Variant name.""" + name: String + """ Determines if the inventory of this variant should be tracked. If false, the quantity won't change when customers buy this item. """ @@ -17267,6 +17356,9 @@ input ProductVariantInput { """Stock keeping unit.""" sku: String + """Variant name.""" + name: String + """ Determines if the inventory of this variant should be tracked. If false, the quantity won't change when customers buy this item. """ @@ -21050,6 +21142,27 @@ input StockInput { quantity: Int! } +""" +Represents the channel stock settings. + +Added in Saleor 3.7. + +Note: this API is currently in Feature Preview and can be subject to changes at later point. +""" +type StockSettings { + """ + Allocation strategy options. Strategy defines the preference of warehouses for allocations and reservations. + """ + allocationStrategy: AllocationStrategyEnum! +} + +input StockSettingsInput { + """ + Allocation strategy options. Strategy defines the preference of warehouses for allocations and reservations. + """ + allocationStrategy: AllocationStrategyEnum! +} + """Enum representing the type of a payment storage in a gateway.""" enum StorePaymentMethodEnum { """ @@ -21753,7 +21866,7 @@ type User implements Node & ObjectWithMetadata { isActive: Boolean! """List of all user's addresses.""" - addresses: [Address!] + addresses: [Address!]! """Returns the last open checkout of this user.""" checkout: Checkout @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `checkoutTokens` field to fetch the user checkouts.") @@ -22981,12 +23094,8 @@ type Webhook implements Node { """Informs if webhook is activated.""" isActive: Boolean! - """ - Used to create a hash signature with each payload. - - If not set, since Saleor 3.5, your payload will be signed using private key used also to sign JWT tokens. - """ - secretKey: String + """Used to create a hash signature for each payload.""" + secretKey: String @deprecated(reason: "This field will be removed in Saleor 4.0. As of Saleor 3.5, webhook payloads default to signing using a verifiable JWS.") """Used to define payloads for specific events.""" subscriptionQuery: String @@ -23029,7 +23138,11 @@ input WebhookCreateInput { """Determine if webhook will be set active or not.""" isActive: Boolean - """The secret key used to create a hash signature with each payload.""" + """ + The secret key used to create a hash signature with each payload. + + DEPRECATED: this field will be removed in Saleor 4.0. As of Saleor 3.5, webhook payloads default to signing using a verifiable JWS. + """ secretKey: String """ @@ -23917,7 +24030,11 @@ input WebhookUpdateInput { """Determine if webhook will be set active or not.""" isActive: Boolean - """Use to create a hash signature with each payload.""" + """ + Use to create a hash signature with each payload. + + DEPRECATED: this field will be removed in Saleor 4.0. As of Saleor 3.5, webhook payloads default to signing using a verifiable JWS. + """ secretKey: String """ diff --git a/src/channels/components/AssignmentList/AssignmentList.tsx b/src/channels/components/AssignmentList/AssignmentList.tsx index 765313f4f..be6bbbf4f 100644 --- a/src/channels/components/AssignmentList/AssignmentList.tsx +++ b/src/channels/components/AssignmentList/AssignmentList.tsx @@ -1,10 +1,13 @@ import { Accordion, Divider, Typography } from "@material-ui/core"; +import Skeleton from "@saleor/components/Skeleton"; +import { ReorderEvent } from "@saleor/types"; import React from "react"; import { defineMessages, useIntl } from "react-intl"; import AssignmentListFooter from "./AssignmentListFooter"; import AssignmentListHeader from "./AssignmentListHeader"; import Item from "./Item"; +import SortableContainer from "./SortableContainer"; import { useExpanderStyles, useStyles } from "./styles"; import { AssignmentListProps } from "./types"; @@ -17,33 +20,75 @@ const messages = defineMessages({ }); const AssignmentList: React.FC = props => { - const { items, itemsName, totalCount = 0, removeItem } = props; + const { + items, + itemsName, + totalCount = 0, + loading, + removeItem, + reorderItem, + } = props; const intl = useIntl(); const classes = useStyles(); const expanderClasses = useExpanderStyles(); + const handleSortStart = () => { + document.body.classList.add(classes.grabbing); + }; + + const handleSortEnd = (event: ReorderEvent) => { + document.body.classList.remove(classes.grabbing); + reorderItem(event); + }; + const hasMoreItemsToBeSelected = totalCount !== items.length; return ( - + - {items.map(item => ( - - ))} - {hasMoreItemsToBeSelected ? ( - + {loading ? ( + ) : ( - - {intl.formatMessage(messages.allSelectedMessage, { - itemsName: itemsName.toLowerCase(), - })} - + <> + +
+ {items.map((item, itemIndex) => ( + + ))} +
+
+ {hasMoreItemsToBeSelected ? ( + + ) : ( + + {intl.formatMessage(messages.allSelectedMessage, { + itemsName: itemsName.toLowerCase(), + })} + + )} + )}
); diff --git a/src/channels/components/AssignmentList/AssignmentListHeader.tsx b/src/channels/components/AssignmentList/AssignmentListHeader.tsx index 6139821ed..203fdf534 100644 --- a/src/channels/components/AssignmentList/AssignmentListHeader.tsx +++ b/src/channels/components/AssignmentList/AssignmentListHeader.tsx @@ -1,5 +1,6 @@ import { AccordionSummary, Typography } from "@material-ui/core"; import HorizontalSpacer from "@saleor/apps/components/HorizontalSpacer"; +import Skeleton from "@saleor/components/Skeleton"; import IconChevronDown from "@saleor/icons/ChevronDown"; import React from "react"; @@ -8,20 +9,26 @@ import { useHeaderStyles } from "./styles"; interface AssignmentListHeaderProps { assignCount: number; itemsName: string; + loading: boolean; } const AssignmentListHeader: React.FC = ({ assignCount, itemsName, + loading, }) => { const classes = useHeaderStyles(); return (
} classes={classes}> - - {`${assignCount} ${itemsName.toLowerCase()}`} - + {loading ? ( + + ) : ( + + {`${assignCount} ${itemsName.toLowerCase()}`} + + )}
diff --git a/src/channels/components/AssignmentList/Item.tsx b/src/channels/components/AssignmentList/Item.tsx index f70732e69..2564921a3 100644 --- a/src/channels/components/AssignmentList/Item.tsx +++ b/src/channels/components/AssignmentList/Item.tsx @@ -1,28 +1,41 @@ import { Divider, Typography } from "@material-ui/core"; import DeletableItem from "@saleor/components/DeletableItem"; import React from "react"; +import { SortableElement, SortableElementProps } from "react-sortable-hoc"; +import SortableHandle from "./SortableHandle"; import { useStyles } from "./styles"; import { AssignItem } from "./types"; -interface ItemProps { +interface ItemProps extends SortableElementProps { item: AssignItem; + sortable?: boolean; onDelete: (id: string) => void; } -const Item: React.FC = ({ item, onDelete }) => { - const { id, name } = item; - const classes = useStyles(); +const Item = SortableElement( + ({ item, sortable = false, onDelete }: ItemProps) => { + const { id, name } = item; + const classes = useStyles(); - return ( - <> -
- {name} - -
- - - ); -}; + return ( + <> +
+
+ {sortable && ( + + )} + {name} +
+ +
+ + + ); + }, +); export default Item; diff --git a/src/channels/components/AssignmentList/SortableContainer.tsx b/src/channels/components/AssignmentList/SortableContainer.tsx new file mode 100644 index 000000000..c6bf81dbf --- /dev/null +++ b/src/channels/components/AssignmentList/SortableContainer.tsx @@ -0,0 +1,14 @@ +import { + SortableContainer as SortableContainerHoc, + SortableContainerProps as SortableContainerHocProps, +} from "react-sortable-hoc"; + +interface SortableContainerProps extends SortableContainerHocProps { + children: React.ReactElement; +} + +const SortableContainer = SortableContainerHoc( + ({ children }: SortableContainerProps) => children, +); + +export default SortableContainer; diff --git a/src/channels/components/AssignmentList/SortableHandle.tsx b/src/channels/components/AssignmentList/SortableHandle.tsx new file mode 100644 index 000000000..b3efa5fd0 --- /dev/null +++ b/src/channels/components/AssignmentList/SortableHandle.tsx @@ -0,0 +1,32 @@ +import { DragIcon, makeStyles } from "@saleor/macaw-ui"; +import classNames from "classnames"; +import React from "react"; +import { SortableHandle as SortableHandleHoc } from "react-sortable-hoc"; + +const useStyles = makeStyles( + { + drag: { + cursor: "grab", + }, + }, + { name: "SortableHandle" }, +); + +interface SortableHandleProps { + className?: string; +} + +const SortableHandle = SortableHandleHoc((props: SortableHandleProps) => { + const { className, ...restProps } = props; + const classes = useStyles(props); + + return ( + + ); +}); + +export default SortableHandle; diff --git a/src/channels/components/AssignmentList/styles.ts b/src/channels/components/AssignmentList/styles.ts index 3115c1056..ac3f71c55 100644 --- a/src/channels/components/AssignmentList/styles.ts +++ b/src/channels/components/AssignmentList/styles.ts @@ -28,6 +28,10 @@ export const useHeaderStyles = makeStyles( flexDirection: "row", alignItems: "center", }, + skeleton: { + width: "100%", + marginRight: theme.spacing(4), + }, // empty expanded needed for mui to use root styles expanded: {}, root: { @@ -61,6 +65,17 @@ export const useStyles = makeStyles( flexDirection: "row", justifyContent: "space-between", alignItems: "center", + background: theme.palette.background.paper, + }, + containerContent: { + display: "flex", + overflow: "auto", + }, + sortableHandle: { + marginRight: theme.spacing(1), + }, + grabbing: { + cursor: "grabbing", }, root: { paddingRight: theme.spacing(1), @@ -68,6 +83,9 @@ export const useStyles = makeStyles( infoMessage: { padding: theme.spacing(3), }, + skeleton: { + margin: theme.spacing(4, 0), + }, }), { name: "AssignmentList" }, ); diff --git a/src/channels/components/AssignmentList/types.ts b/src/channels/components/AssignmentList/types.ts index a9b76a204..567849ab3 100644 --- a/src/channels/components/AssignmentList/types.ts +++ b/src/channels/components/AssignmentList/types.ts @@ -1,4 +1,4 @@ -import { FetchMoreProps } from "@saleor/types"; +import { FetchMoreProps, ReorderAction } from "@saleor/types"; export interface AssignItem { id: string; @@ -13,7 +13,9 @@ export interface AssignmentListProps { totalCount: number; inputName: string; dataTestId: string; + loading: boolean; addItem: (id: string) => void; removeItem: (id: string) => void; + reorderItem?: ReorderAction; searchItems: (searchPhrase: string) => void; } diff --git a/src/channels/components/ChannelAllocationStrategy/ChannelAllocationStrategy.tsx b/src/channels/components/ChannelAllocationStrategy/ChannelAllocationStrategy.tsx new file mode 100644 index 000000000..0c3ee6f9d --- /dev/null +++ b/src/channels/components/ChannelAllocationStrategy/ChannelAllocationStrategy.tsx @@ -0,0 +1,106 @@ +import { Card, CardContent, Typography } from "@material-ui/core"; +import HelpOutline from "@material-ui/icons/HelpOutline"; +import CardTitle from "@saleor/components/CardTitle"; +import PreviewPill from "@saleor/components/PreviewPill"; +import RadioGroupField from "@saleor/components/RadioGroupField"; +import { AllocationStrategyEnum, StockSettingsInput } from "@saleor/graphql"; +import { Tooltip } from "@saleor/macaw-ui"; +import React from "react"; +import { FormattedMessage } from "react-intl"; + +import { messages } from "./messages"; +import { useStyles } from "./styles"; + +const strategyOptions = [ + { + title: messages.prioritizeBySortOrder, + subtitle: messages.prioritizeBySortOrderDescription, + type: AllocationStrategyEnum.PRIORITIZE_SORTING_ORDER, + }, + { + title: messages.prioritizeByHighestStock, + subtitle: messages.prioritizeByHighestStockDescription, + type: AllocationStrategyEnum.PRIORITIZE_HIGH_STOCK, + }, +]; + +interface ChannelAllocationStrategyProps { + data?: StockSettingsInput; + disabled: boolean; + onChange: (event: React.ChangeEvent) => void; +} + +const ChannelAllocationStrategy: React.FC = ({ + data, + disabled, + onChange, +}) => { + const classes = useStyles(); + + return ( + + + + + + } + /> + + + + + +
    +
  • + +
  • +
  • + +
  • +
+ + } + > + +
+ + } + choices={strategyOptions.map(option => ({ + label: ( +
+ + + + {option.subtitle && ( + + + + )} +
+ ), + value: option.type, + }))} + disabled={disabled} + name="allocationStrategy" + value={data?.allocationStrategy} + onChange={onChange} + /> +
+
+ ); +}; +ChannelAllocationStrategy.displayName = "ChannelAllocationStrategy"; +export default ChannelAllocationStrategy; diff --git a/src/channels/components/ChannelAllocationStrategy/index.ts b/src/channels/components/ChannelAllocationStrategy/index.ts new file mode 100644 index 000000000..eceb2b073 --- /dev/null +++ b/src/channels/components/ChannelAllocationStrategy/index.ts @@ -0,0 +1,2 @@ +export * from "./ChannelAllocationStrategy"; +export { default } from "./ChannelAllocationStrategy"; diff --git a/src/channels/components/ChannelAllocationStrategy/messages.ts b/src/channels/components/ChannelAllocationStrategy/messages.ts new file mode 100644 index 000000000..2955a02cc --- /dev/null +++ b/src/channels/components/ChannelAllocationStrategy/messages.ts @@ -0,0 +1,54 @@ +import { defineMessages } from "react-intl"; + +export const messages = defineMessages({ + allocationStrategy: { + defaultMessage: "Allocation strategy", + id: "FYfoiF", + description: "section name", + }, + allocationStrategyDescription: { + defaultMessage: + "Strategy defines the preference of warehouses for stock allocations and reservations.", + id: "/DzBc6", + description: "section description", + }, + prioritizeBySortOrder: { + defaultMessage: "Prioritize warehouses by sorting order", + id: "FSOOH7", + description: "option title", + }, + prioritizeBySortOrderDescription: { + defaultMessage: + "Allocate stock in the first warehouse in the list assigned to this channel. If stock is insufficient, the remaining quantity is allocated in the next warehouse on the list and repeated if necessary.", + id: "YiC3cn", + description: "option description", + }, + prioritizeByHighestStock: { + defaultMessage: "Prioritize warehouses with highest stock", + id: "423QsF", + description: "option title", + }, + prioritizeByHighestStockDescription: { + defaultMessage: + "Allocate order-line to a warehouse with the most stock. If not enough stock is available in a single warehouse, the remaining quantity is allocated in the next warehouse with the most stock and repeated if necessary.", + id: "HN1Gvw", + description: "option description", + }, + allocaationMayOccur: { + defaultMessage: "Stock allocations occur when:", + description: "tooltip", + id: "icb1fc", + }, + allocaationMayOccurWithTrackInventory: { + defaultMessage: + 'Order contains products that have "Track inventory" enabled.', + description: "tooltip", + id: "q5Lfp4", + }, + allocaationMayOccurWithReservationTime: { + defaultMessage: + "Checkout reservation time threshold is enabled in settings.", + description: "tooltip", + id: "G5NKx6", + }, +}); diff --git a/src/channels/components/ChannelAllocationStrategy/styles.ts b/src/channels/components/ChannelAllocationStrategy/styles.ts new file mode 100644 index 000000000..700ed885c --- /dev/null +++ b/src/channels/components/ChannelAllocationStrategy/styles.ts @@ -0,0 +1,26 @@ +import { makeStyles } from "@saleor/macaw-ui"; + +export const useStyles = makeStyles( + theme => ({ + option: { + marginTop: theme.spacing(-0.25), + marginBottom: theme.spacing(), + }, + tooltipIcon: { + fill: "#28234A", + fillOpacity: 0.6, + "&:hover": { + fillOpacity: 1, + }, + position: "absolute", + padding: theme.spacing(0.25), + }, + preview: { + display: "flex", + gap: theme.spacing(1), + flexWrap: "wrap", + alignItems: "center", + }, + }), + { name: "ChannelAllocationStrategy" }, +); diff --git a/src/channels/components/ChannelForm/ChannelForm.stories.tsx b/src/channels/components/ChannelForm/ChannelForm.stories.tsx index f6cbf5e9c..83c11a60d 100644 --- a/src/channels/components/ChannelForm/ChannelForm.stories.tsx +++ b/src/channels/components/ChannelForm/ChannelForm.stories.tsx @@ -1,5 +1,5 @@ import { countries } from "@saleor/fixtures"; -import { CountryCode } from "@saleor/graphql"; +import { AllocationStrategyEnum, CountryCode } from "@saleor/graphql"; import Decorator from "@saleor/storybook/Decorator"; import { storiesOf } from "@storybook/react"; import React from "react"; @@ -17,6 +17,31 @@ const props: ChannelFormProps = { name: "Test", slug: "test", defaultCountry: CountryCode.PL, + allocationStrategy: AllocationStrategyEnum.PRIORITIZE_HIGH_STOCK, + warehousesToDisplay: [ + { + __typename: "Warehouse", + id: "1", + name: "Warehouse 1", + }, + { + __typename: "Warehouse", + id: "2", + name: "Warehouse 2", + }, + ], + shippingZonesToDisplay: [ + { + __typename: "ShippingZone", + id: "1", + name: "Shipping Zone 1", + }, + { + __typename: "ShippingZone", + id: "2", + name: "Shipping Zone 2", + }, + ], }, disabled: false, errors: [], diff --git a/src/channels/components/ChannelForm/ChannelForm.tsx b/src/channels/components/ChannelForm/ChannelForm.tsx index 0df3b42ca..a1f9d5ccf 100644 --- a/src/channels/components/ChannelForm/ChannelForm.tsx +++ b/src/channels/components/ChannelForm/ChannelForm.tsx @@ -5,13 +5,21 @@ import { TextField, Typography, } from "@material-ui/core"; +import { + ChannelShippingZones, + ChannelWarehouses, +} from "@saleor/channels/pages/ChannelDetailsPage/types"; import CardSpacer from "@saleor/components/CardSpacer"; import CardTitle from "@saleor/components/CardTitle"; import FormSpacer from "@saleor/components/FormSpacer"; import SingleAutocompleteSelectField, { SingleAutocompleteChoiceType, } from "@saleor/components/SingleAutocompleteSelectField"; -import { ChannelErrorFragment, CountryCode } from "@saleor/graphql"; +import { + ChannelErrorFragment, + CountryCode, + StockSettingsInput, +} from "@saleor/graphql"; import useClipboard from "@saleor/hooks/useClipboard"; import { ChangeEvent, FormChange } from "@saleor/hooks/useForm"; import { commonMessages } from "@saleor/intl"; @@ -23,7 +31,7 @@ import { FormattedMessage, useIntl } from "react-intl"; import { useStyles } from "../styles"; import { ExtendedFormHelperTextProps } from "./types"; -export interface FormData { +export interface FormData extends StockSettingsInput { name: string; currencyCode: string; slug: string; @@ -31,6 +39,8 @@ export interface FormData { shippingZonesIdsToRemove: string[]; warehousesIdsToAdd: string[]; warehousesIdsToRemove: string[]; + shippingZonesToDisplay: ChannelShippingZones; + warehousesToDisplay: ChannelWarehouses; defaultCountry: CountryCode; } diff --git a/src/channels/components/ShippingZones/ShippingZones.stories.tsx b/src/channels/components/ShippingZones/ShippingZones.stories.tsx index b086b28ad..c11946203 100644 --- a/src/channels/components/ShippingZones/ShippingZones.stories.tsx +++ b/src/channels/components/ShippingZones/ShippingZones.stories.tsx @@ -31,6 +31,7 @@ const baseProps: ShippingZonesProps = { shippingZones: [], shippingZonesChoices: shippingZones as ChannelShippingZones, totalCount: 10, + loading: false, }; storiesOf("Shipping zones", module) @@ -41,4 +42,5 @@ storiesOf("Shipping zones", module) {...baseProps} shippingZones={shippingZones as ChannelShippingZones} /> - )); + )) + .add("loading", () => ); diff --git a/src/channels/components/ShippingZones/ShippingZones.tsx b/src/channels/components/ShippingZones/ShippingZones.tsx index f1f2f4127..6d8502ac5 100644 --- a/src/channels/components/ShippingZones/ShippingZones.tsx +++ b/src/channels/components/ShippingZones/ShippingZones.tsx @@ -5,23 +5,16 @@ import { SearchShippingZonesQuery } from "@saleor/graphql"; import { sectionNames } from "@saleor/intl"; import { FetchMoreProps, RelayToFlat } from "@saleor/types"; import React from "react"; -import { defineMessages, useIntl } from "react-intl"; +import { useIntl } from "react-intl"; import AssignmentList from "../AssignmentList"; - -const messages = defineMessages({ - subtitle: { - id: "Ic7Wln", - defaultMessage: - "Select shipping zones that will be supplied via this channel. You can assign shipping zones to multiple channels.", - description: "card subtitle", - }, -}); +import { messages } from "./messages"; export interface ShippingZonesProps { addShippingZone: (id: string) => void; removeShippingZone: (id: string) => void; searchShippingZones: (searchPhrase: string) => void; + loading: boolean; totalCount: number; fetchMoreShippingZones: FetchMoreProps; shippingZones: ChannelShippingZones; @@ -33,6 +26,7 @@ const ShippingZones: React.FC = props => { addShippingZone, removeShippingZone, searchShippingZones, + loading, totalCount, fetchMoreShippingZones, shippingZones, @@ -48,6 +42,7 @@ const ShippingZones: React.FC = props => { {intl.formatMessage(messages.subtitle)} ({ - container: { - padding: theme.spacing(1, 0), - display: "flex", - flexDirection: "row", - justifyContent: "space-between", - alignItems: "center", - }, - root: { - paddingRight: theme.spacing(1), - }, - }), - { name: "ShippingZones" }, -); - -export default useStyles; diff --git a/src/channels/components/Warehouses/Warehouses.stories.tsx b/src/channels/components/Warehouses/Warehouses.stories.tsx index 2c637afd9..b9dca3da2 100644 --- a/src/channels/components/Warehouses/Warehouses.stories.tsx +++ b/src/channels/components/Warehouses/Warehouses.stories.tsx @@ -28,9 +28,11 @@ const baseProps: WarehousesProps = { onFetchMore: () => undefined, totalCount: 0, }, + reorderWarehouses: () => undefined, warehouses: [], warehousesChoices: warehouses as ChannelWarehouses, totalCount: 10, + loading: false, }; storiesOf("Warehouses", module) @@ -38,4 +40,5 @@ storiesOf("Warehouses", module) .add("with no options selected", () => ) .add("with options selected", () => ( - )); + )) + .add("loading", () => ); diff --git a/src/channels/components/Warehouses/Warehouses.tsx b/src/channels/components/Warehouses/Warehouses.tsx index d41e2aae5..76b8e9ffa 100644 --- a/src/channels/components/Warehouses/Warehouses.tsx +++ b/src/channels/components/Warehouses/Warehouses.tsx @@ -3,25 +3,19 @@ import { ChannelWarehouses } from "@saleor/channels/pages/ChannelDetailsPage/typ import CardTitle from "@saleor/components/CardTitle"; import { SearchWarehousesQuery } from "@saleor/graphql"; import { sectionNames } from "@saleor/intl"; -import { FetchMoreProps, RelayToFlat } from "@saleor/types"; +import { FetchMoreProps, RelayToFlat, ReorderAction } from "@saleor/types"; import React from "react"; -import { defineMessages, useIntl } from "react-intl"; +import { useIntl } from "react-intl"; import AssignmentList from "../AssignmentList"; - -const messages = defineMessages({ - subtitle: { - id: "ImTelT", - defaultMessage: - "Select warehouses that will be used in this channel. You can assign warehouses to multiple channels.", - description: "card subtitle", - }, -}); +import { messages } from "./messages"; export interface WarehousesProps { addWarehouse: (id: string) => void; removeWarehouse: (id: string) => void; searchWarehouses: (searchPhrase: string) => void; + reorderWarehouses: ReorderAction; + loading: boolean; totalCount: number; fetchMoreWarehouses: FetchMoreProps; warehouses: ChannelWarehouses; @@ -33,6 +27,8 @@ const Warehouses: React.FC = props => { addWarehouse, removeWarehouse, searchWarehouses, + reorderWarehouses, + loading, totalCount, fetchMoreWarehouses, warehouses, @@ -48,11 +44,13 @@ const Warehouses: React.FC = props => { {intl.formatMessage(messages.subtitle)} ({ - container: { - padding: theme.spacing(1, 0), - display: "flex", - flexDirection: "row", - justifyContent: "space-between", - alignItems: "center", - }, - root: { - paddingRight: theme.spacing(1), - }, - }), - { name: "Warehouses" }, -); - -export default useStyles; diff --git a/src/channels/fixtures.ts b/src/channels/fixtures.ts index 8b879f270..693d0e6dd 100644 --- a/src/channels/fixtures.ts +++ b/src/channels/fixtures.ts @@ -1,4 +1,5 @@ import { + AllocationStrategyEnum, ChannelDetailsFragment, ChannelErrorCode, ChannelErrorFragment, @@ -29,6 +30,22 @@ export const channelsList: ChannelDetailsFragment[] = [ country: "Poland", __typename: "CountryDisplay", }, + stockSettings: { + __typename: "StockSettings", + allocationStrategy: AllocationStrategyEnum.PRIORITIZE_HIGH_STOCK, + }, + warehouses: [ + { + __typename: "Warehouse", + id: "WH1", + name: "Warehouse 1", + }, + { + __typename: "Warehouse", + id: "WH2", + name: "Warehouse 2", + }, + ], }, { __typename: "Channel", @@ -43,6 +60,22 @@ export const channelsList: ChannelDetailsFragment[] = [ country: "Poland", __typename: "CountryDisplay", }, + stockSettings: { + __typename: "StockSettings", + allocationStrategy: AllocationStrategyEnum.PRIORITIZE_HIGH_STOCK, + }, + warehouses: [ + { + __typename: "Warehouse", + id: "WH1", + name: "Warehouse 1", + }, + { + __typename: "Warehouse", + id: "WH2", + name: "Warehouse 2", + }, + ], }, { __typename: "Channel", @@ -57,6 +90,22 @@ export const channelsList: ChannelDetailsFragment[] = [ country: "Poland", __typename: "CountryDisplay", }, + stockSettings: { + __typename: "StockSettings", + allocationStrategy: AllocationStrategyEnum.PRIORITIZE_HIGH_STOCK, + }, + warehouses: [ + { + __typename: "Warehouse", + id: "WH1", + name: "Warehouse 1", + }, + { + __typename: "Warehouse", + id: "WH2", + name: "Warehouse 2", + }, + ], }, { __typename: "Channel", @@ -71,6 +120,22 @@ export const channelsList: ChannelDetailsFragment[] = [ country: "Poland", __typename: "CountryDisplay", }, + stockSettings: { + __typename: "StockSettings", + allocationStrategy: AllocationStrategyEnum.PRIORITIZE_HIGH_STOCK, + }, + warehouses: [ + { + __typename: "Warehouse", + id: "WH1", + name: "Warehouse 1", + }, + { + __typename: "Warehouse", + id: "WH2", + name: "Warehouse 2", + }, + ], }, { __typename: "Channel", @@ -85,6 +150,22 @@ export const channelsList: ChannelDetailsFragment[] = [ country: "Poland", __typename: "CountryDisplay", }, + stockSettings: { + __typename: "StockSettings", + allocationStrategy: AllocationStrategyEnum.PRIORITIZE_HIGH_STOCK, + }, + warehouses: [ + { + __typename: "Warehouse", + id: "WH1", + name: "Warehouse 1", + }, + { + __typename: "Warehouse", + id: "WH2", + name: "Warehouse 2", + }, + ], }, { __typename: "Channel", @@ -99,6 +180,22 @@ export const channelsList: ChannelDetailsFragment[] = [ country: "Poland", __typename: "CountryDisplay", }, + stockSettings: { + __typename: "StockSettings", + allocationStrategy: AllocationStrategyEnum.PRIORITIZE_HIGH_STOCK, + }, + warehouses: [ + { + __typename: "Warehouse", + id: "WH1", + name: "Warehouse 1", + }, + { + __typename: "Warehouse", + id: "WH2", + name: "Warehouse 2", + }, + ], }, { __typename: "Channel", @@ -113,6 +210,22 @@ export const channelsList: ChannelDetailsFragment[] = [ country: "Poland", __typename: "CountryDisplay", }, + stockSettings: { + __typename: "StockSettings", + allocationStrategy: AllocationStrategyEnum.PRIORITIZE_HIGH_STOCK, + }, + warehouses: [ + { + __typename: "Warehouse", + id: "WH1", + name: "Warehouse 1", + }, + { + __typename: "Warehouse", + id: "WH2", + name: "Warehouse 2", + }, + ], }, ]; @@ -129,6 +242,22 @@ export const channel: ChannelDetailsFragment = { country: "Poland", __typename: "CountryDisplay", }, + stockSettings: { + __typename: "StockSettings", + allocationStrategy: AllocationStrategyEnum.PRIORITIZE_HIGH_STOCK, + }, + warehouses: [ + { + __typename: "Warehouse", + id: "WH1", + name: "Warehouse 1", + }, + { + __typename: "Warehouse", + id: "WH2", + name: "Warehouse 2", + }, + ], }; type ProductChannelsWithPricing = ProductFragment["channelListings"][0] & { diff --git a/src/channels/mutations.ts b/src/channels/mutations.ts index 20d539297..414eb3c8d 100644 --- a/src/channels/mutations.ts +++ b/src/channels/mutations.ts @@ -61,3 +61,16 @@ export const channelDeactivateMutation = gql` } } `; + +export const ChannelReorderWarehousesMutation = gql` + mutation ChannelReorderWarehouses($channelId: ID!, $moves: [ReorderInput!]!) { + channelReorderWarehouses(channelId: $channelId, moves: $moves) { + channel { + ...ChannelDetails + } + errors { + ...ChannelError + } + } + } +`; diff --git a/src/channels/pages/ChannelDetailsPage/ChannelDetailsPage.tsx b/src/channels/pages/ChannelDetailsPage/ChannelDetailsPage.tsx index 58e37e2aa..9db0afefc 100644 --- a/src/channels/pages/ChannelDetailsPage/ChannelDetailsPage.tsx +++ b/src/channels/pages/ChannelDetailsPage/ChannelDetailsPage.tsx @@ -1,3 +1,4 @@ +import ChannelAllocationStrategy from "@saleor/channels/components/ChannelAllocationStrategy"; import ShippingZones from "@saleor/channels/components/ShippingZones"; import Warehouses from "@saleor/channels/components/Warehouses"; import { channelsListUrl } from "@saleor/channels/urls"; @@ -7,12 +8,14 @@ import Grid from "@saleor/components/Grid"; import Savebar from "@saleor/components/Savebar"; import { SingleAutocompleteChoiceType } from "@saleor/components/SingleAutocompleteSelectField"; import { + AllocationStrategyEnum, ChannelDetailsFragment, ChannelErrorFragment, CountryCode, CountryFragment, SearchShippingZonesQuery, SearchWarehousesQuery, + StockSettingsInput, } from "@saleor/graphql"; import { SearchData } from "@saleor/hooks/makeTopLevelSearch"; import { getParsedSearchData } from "@saleor/hooks/makeTopLevelSearch/utils"; @@ -20,10 +23,6 @@ import { SubmitPromise } from "@saleor/hooks/useForm"; import useNavigator from "@saleor/hooks/useNavigator"; import useStateFromProps from "@saleor/hooks/useStateFromProps"; import { ConfirmButtonTransitionState } from "@saleor/macaw-ui"; -import { - getById, - getByUnmatchingId, -} from "@saleor/orders/components/OrderReturnPage/utils"; import { FetchMoreProps, RelayToFlat } from "@saleor/types"; import createSingleAutocompleteSelectHandler from "@saleor/utils/handlers/singleAutocompleteSelectChangeHandler"; import { mapCountriesToChoices } from "@saleor/utils/maps"; @@ -31,8 +30,14 @@ import React, { useState } from "react"; import { ChannelForm, FormData } from "../../components/ChannelForm"; import { ChannelStatus } from "../../components/ChannelStatus/ChannelStatus"; +import { + createShippingZoneAddHandler, + createShippingZoneRemoveHandler, + createWarehouseAddHandler, + createWarehouseRemoveHandler, + createWarehouseReorderHandler, +} from "./handlers"; import { ChannelShippingZones, ChannelWarehouses } from "./types"; -import { getUpdatedIdsWithNewId, getUpdatedIdsWithoutNewId } from "./utils"; export interface ChannelDetailsPageProps { channel?: ChannelDetailsFragment; @@ -87,16 +92,14 @@ const ChannelDetailsPage = function({ setSelectedCountryDisplayName, ] = useStateFromProps(channel?.defaultCountry.country || ""); - const [shippingZonesToDisplay, setShippingZonesToDisplay] = useStateFromProps< - ChannelShippingZones - >(channelShippingZones); - const [warehousesToDisplay, setWarehousesToDisplay] = useStateFromProps< - ChannelWarehouses - >(channelWarehouses); - const countryChoices = mapCountriesToChoices(countries || []); - const { defaultCountry, ...formData } = channel || {}; + const { defaultCountry, stockSettings, ...formData } = + channel || ({} as ChannelDetailsFragment); + const initialStockSettings: StockSettingsInput = { + allocationStrategy: AllocationStrategyEnum.PRIORITIZE_SORTING_ORDER, + ...stockSettings, + }; const initialData: FormData = { currencyCode: "", name: "", @@ -107,15 +110,22 @@ const ChannelDetailsPage = function({ warehousesIdsToRemove: [], defaultCountry: (defaultCountry?.code || "") as CountryCode, ...formData, + ...initialStockSettings, + shippingZonesToDisplay: channelShippingZones, + warehousesToDisplay: channelWarehouses, }; - const getFilteredShippingZonesChoices = (): RelayToFlat => + const getFilteredShippingZonesChoices = ( + shippingZonesToDisplay: ChannelShippingZones, + ): RelayToFlat => getParsedSearchData({ data: searchShippingZonesData }).filter( ({ id: searchedZoneId }) => !shippingZonesToDisplay.some(({ id }) => id === searchedZoneId), ); - const getFilteredWarehousesChoices = (): RelayToFlat => + const getFilteredWarehousesChoices = ( + warehousesToDisplay: ChannelWarehouses, + ): RelayToFlat => getParsedSearchData({ data: searchWarehousesData }).filter( ({ id: searchedWarehouseId }) => !warehousesToDisplay.some(({ id }) => id === searchedWarehouseId), @@ -151,91 +161,30 @@ const ChannelDetailsPage = function({ countryChoices, ); - const addShippingZone = (zoneId: string) => { - triggerChange(); + const addShippingZone = createShippingZoneAddHandler( + data, + searchShippingZonesData, + set, + triggerChange, + ); + const removeShippingZone = createShippingZoneRemoveHandler( + data, + set, + triggerChange, + ); - set({ - ...data, - shippingZonesIdsToRemove: getUpdatedIdsWithoutNewId( - data.shippingZonesIdsToRemove, - zoneId, - ), - shippingZonesIdsToAdd: getUpdatedIdsWithNewId( - data.shippingZonesIdsToAdd, - zoneId, - ), - }); - - setShippingZonesToDisplay([ - ...shippingZonesToDisplay, - getParsedSearchData({ data: searchShippingZonesData }).find( - getById(zoneId), - ), - ]); - }; - - const removeShippingZone = (zoneId: string) => { - triggerChange(); - - set({ - ...data, - shippingZonesIdsToAdd: getUpdatedIdsWithoutNewId( - data.shippingZonesIdsToAdd, - zoneId, - ), - shippingZonesIdsToRemove: getUpdatedIdsWithNewId( - data.shippingZonesIdsToRemove, - zoneId, - ), - }); - - setShippingZonesToDisplay( - shippingZonesToDisplay.filter(getByUnmatchingId(zoneId)), - ); - }; - - const addWarehouse = (warehouseId: string) => { - triggerChange(); - - set({ - ...data, - warehousesIdsToRemove: getUpdatedIdsWithoutNewId( - data.warehousesIdsToRemove, - warehouseId, - ), - warehousesIdsToAdd: getUpdatedIdsWithNewId( - data.warehousesIdsToAdd, - warehouseId, - ), - }); - - setWarehousesToDisplay([ - ...warehousesToDisplay, - getParsedSearchData({ data: searchWarehousesData }).find( - getById(warehouseId), - ), - ]); - }; - - const removeWarehouse = (warehouseId: string) => { - triggerChange(); - - set({ - ...data, - warehousesIdsToAdd: getUpdatedIdsWithoutNewId( - data.warehousesIdsToAdd, - warehouseId, - ), - warehousesIdsToRemove: getUpdatedIdsWithNewId( - data.warehousesIdsToRemove, - warehouseId, - ), - }); - - setWarehousesToDisplay( - warehousesToDisplay.filter(getByUnmatchingId(warehouseId)), - ); - }; + const addWarehouse = createWarehouseAddHandler( + data, + searchWarehousesData, + set, + triggerChange, + ); + const removeWarehouse = createWarehouseRemoveHandler( + data, + set, + triggerChange, + ); + const reorderWarehouse = createWarehouseReorderHandler(data, set); return ( <> @@ -266,23 +215,36 @@ const ChannelDetailsPage = function({ )} + + diff --git a/src/channels/pages/ChannelDetailsPage/handlers.ts b/src/channels/pages/ChannelDetailsPage/handlers.ts new file mode 100644 index 000000000..7db87b286 --- /dev/null +++ b/src/channels/pages/ChannelDetailsPage/handlers.ts @@ -0,0 +1,138 @@ +import { FormData } from "@saleor/channels/components/ChannelForm"; +import { SearchData } from "@saleor/hooks/makeTopLevelSearch"; +import { getParsedSearchData } from "@saleor/hooks/makeTopLevelSearch/utils"; +import { + getById, + getByUnmatchingId, +} from "@saleor/orders/components/OrderReturnPage/utils"; +import { ReorderAction, ReorderEvent } from "@saleor/types"; +import { move } from "@saleor/utils/lists"; + +import { getUpdatedIdsWithNewId, getUpdatedIdsWithoutNewId } from "./utils"; + +export function createShippingZoneAddHandler( + data: FormData, + searchShippingZonesData: SearchData, + set: (data: Partial) => void, + triggerChange: () => void, +) { + return (zoneId: string) => { + triggerChange(); + + set({ + ...data, + shippingZonesIdsToRemove: getUpdatedIdsWithoutNewId( + data.shippingZonesIdsToRemove, + zoneId, + ), + shippingZonesIdsToAdd: getUpdatedIdsWithNewId( + data.shippingZonesIdsToAdd, + zoneId, + ), + shippingZonesToDisplay: [ + ...data.shippingZonesToDisplay, + getParsedSearchData({ data: searchShippingZonesData }).find( + getById(zoneId), + ), + ], + }); + }; +} + +export function createShippingZoneRemoveHandler( + data: FormData, + set: (data: Partial) => void, + triggerChange: () => void, +) { + return (zoneId: string) => { + triggerChange(); + + set({ + ...data, + shippingZonesIdsToAdd: getUpdatedIdsWithoutNewId( + data.shippingZonesIdsToAdd, + zoneId, + ), + shippingZonesIdsToRemove: getUpdatedIdsWithNewId( + data.shippingZonesIdsToRemove, + zoneId, + ), + shippingZonesToDisplay: data.shippingZonesToDisplay.filter( + getByUnmatchingId(zoneId), + ), + }); + }; +} + +export function createWarehouseAddHandler( + data: FormData, + searchWarehousesData: SearchData, + set: (data: Partial) => void, + triggerChange: () => void, +) { + return (warehouseId: string) => { + triggerChange(); + + set({ + ...data, + warehousesIdsToRemove: getUpdatedIdsWithoutNewId( + data.warehousesIdsToRemove, + warehouseId, + ), + warehousesIdsToAdd: getUpdatedIdsWithNewId( + data.warehousesIdsToAdd, + warehouseId, + ), + warehousesToDisplay: [ + ...data.warehousesToDisplay, + getParsedSearchData({ data: searchWarehousesData }).find( + getById(warehouseId), + ), + ], + }); + }; +} + +export function createWarehouseRemoveHandler( + data: FormData, + set: (data: Partial) => void, + triggerChange: () => void, +) { + return (warehouseId: string) => { + triggerChange(); + + set({ + ...data, + warehousesIdsToAdd: getUpdatedIdsWithoutNewId( + data.warehousesIdsToAdd, + warehouseId, + ), + warehousesIdsToRemove: getUpdatedIdsWithNewId( + data.warehousesIdsToRemove, + warehouseId, + ), + warehousesToDisplay: data.warehousesToDisplay.filter( + getByUnmatchingId(warehouseId), + ), + }); + }; +} + +export function createWarehouseReorderHandler( + data: FormData, + set: (data: Partial) => void, +): ReorderAction { + return ({ oldIndex, newIndex }: ReorderEvent) => { + const updatedWarehousesToDisplay = move( + data.warehousesToDisplay[oldIndex], + data.warehousesToDisplay, + (a, b) => a.id === b.id, + newIndex, + ); + + set({ + ...data, + warehousesToDisplay: updatedWarehousesToDisplay, + }); + }; +} diff --git a/src/channels/pages/ChannelDetailsPage/types.ts b/src/channels/pages/ChannelDetailsPage/types.ts index e2ae9dacd..346e2dd53 100644 --- a/src/channels/pages/ChannelDetailsPage/types.ts +++ b/src/channels/pages/ChannelDetailsPage/types.ts @@ -1,7 +1,4 @@ -import { - ChannelShippingZonesQuery, - ChannelWarehousesQuery, -} from "@saleor/graphql"; +import { ChannelShippingZonesQuery, WarehouseFragment } from "@saleor/graphql"; import { RelayToFlat } from "@saleor/types"; export type ChannelShippingZones = RelayToFlat< @@ -10,8 +7,6 @@ export type ChannelShippingZones = RelayToFlat< export type ChannelShippingZone = ChannelShippingZones[0]; -export type ChannelWarehouses = RelayToFlat< - ChannelWarehousesQuery["warehouses"] ->; +export type ChannelWarehouses = WarehouseFragment[]; export type ChannelWarehouse = ChannelWarehouses[0]; diff --git a/src/channels/views/ChannelCreate/ChannelCreate.tsx b/src/channels/views/ChannelCreate/ChannelCreate.tsx index faef4e05f..6a7ed2f6b 100644 --- a/src/channels/views/ChannelCreate/ChannelCreate.tsx +++ b/src/channels/views/ChannelCreate/ChannelCreate.tsx @@ -6,7 +6,9 @@ import { WindowTitle } from "@saleor/components/WindowTitle"; import { DEFAULT_INITIAL_SEARCH_DATA } from "@saleor/config"; import { ChannelCreateMutation, + ChannelErrorFragment, useChannelCreateMutation, + useChannelReorderWarehousesMutation, useShippingZonesCountQuery, useWarehousesCountQuery, } from "@saleor/graphql"; @@ -19,12 +21,14 @@ import { sectionNames } from "@saleor/intl"; import { extractMutationErrors } from "@saleor/misc"; import useShippingZonesSearch from "@saleor/searches/useShippingZonesSearch"; import useWarehouseSearch from "@saleor/searches/useWarehouseSearch"; +import getChannelsErrorMessage from "@saleor/utils/errors/channels"; import currencyCodes from "currency-codes"; import React from "react"; import { useIntl } from "react-intl"; import ChannelDetailsPage from "../../pages/ChannelDetailsPage"; import { channelPath, channelsListUrl } from "../../urls"; +import { calculateItemsOrderMoves } from "../ChannelDetails/handlers"; export const ChannelCreateView = ({}) => { const navigate = useNavigator(); @@ -32,38 +36,74 @@ export const ChannelCreateView = ({}) => { const intl = useIntl(); const shop = useShop(); - const [createChannel, createChannelOpts] = useChannelCreateMutation({ - onCompleted: ({ - channelCreate: { errors, channel }, - }: ChannelCreateMutation) => { - notify(getDefaultNotifierSuccessErrorData(errors, intl)); + const handleError = (error: ChannelErrorFragment) => { + notify({ + status: "error", + text: getChannelsErrorMessage(error, intl), + }); + }; - if (!errors.length) { - navigate(channelPath(channel.id)); - } + const [createChannel, createChannelOpts] = useChannelCreateMutation({ + onCompleted: ({ channelCreate: { errors } }: ChannelCreateMutation) => { + notify(getDefaultNotifierSuccessErrorData(errors, intl)); }, }); - const handleSubmit = ({ + const [reorderChannelWarehouses] = useChannelReorderWarehousesMutation({ + onCompleted: data => { + const errors = data.channelReorderWarehouses.errors; + if (errors.length) { + errors.forEach(error => handleError(error)); + } + + navigate(channelPath(data.channelReorderWarehouses.channel?.id)); + }, + }); + + const handleSubmit = async ({ shippingZonesIdsToAdd, shippingZonesIdsToRemove, warehousesIdsToAdd, warehousesIdsToRemove, + warehousesToDisplay, + shippingZonesToDisplay, currencyCode, + allocationStrategy, ...rest - }: FormData) => - extractMutationErrors( - createChannel({ - variables: { - input: { - ...rest, - currencyCode: currencyCode.toUpperCase(), - addShippingZones: shippingZonesIdsToAdd, - addWarehouses: warehousesIdsToAdd, + }: FormData) => { + const createChannelMutation = createChannel({ + variables: { + input: { + ...rest, + currencyCode: currencyCode.toUpperCase(), + addShippingZones: shippingZonesIdsToAdd, + addWarehouses: warehousesIdsToAdd, + stockSettings: { + allocationStrategy, }, }, - }), - ); + }, + }); + + const result = await createChannelMutation; + const errors = await extractMutationErrors(createChannelMutation); + + if (!errors?.length) { + const moves = calculateItemsOrderMoves( + result.data?.channelCreate.channel?.warehouses, + warehousesToDisplay, + ); + + await reorderChannelWarehouses({ + variables: { + channelId: result.data?.channelCreate.channel?.id, + moves, + }, + }); + } + + return errors; + }; const { data: shippingZonesCountData, diff --git a/src/channels/views/ChannelDetails/ChannelDetails.tsx b/src/channels/views/ChannelDetails/ChannelDetails.tsx index 61834bcdc..b87096e42 100644 --- a/src/channels/views/ChannelDetails/ChannelDetails.tsx +++ b/src/channels/views/ChannelDetails/ChannelDetails.tsx @@ -14,10 +14,10 @@ import { useChannelDeactivateMutation, useChannelDeleteMutation, useChannelQuery, + useChannelReorderWarehousesMutation, useChannelShippingZonesQuery, useChannelsQuery, useChannelUpdateMutation, - useChannelWarehousesQuery, useShippingZonesCountQuery, useWarehousesCountQuery, } from "@saleor/graphql"; @@ -32,6 +32,7 @@ import useShippingZonesSearch from "@saleor/searches/useShippingZonesSearch"; import useWarehouseSearch from "@saleor/searches/useWarehouseSearch"; import getChannelsErrorMessage from "@saleor/utils/errors/channels"; import createDialogActionHandlers from "@saleor/utils/handlers/dialogActionHandlers"; +import { mapEdgesToItems } from "@saleor/utils/maps"; import React from "react"; import { useIntl } from "react-intl"; @@ -42,6 +43,7 @@ import { ChannelUrlDialog, ChannelUrlQueryParams, } from "../../urls"; +import { calculateItemsOrderMoves } from "./handlers"; interface ChannelDetailsProps { id: string; @@ -102,31 +104,66 @@ export const ChannelDetails: React.FC = ({ }, }); - const handleSubmit = ({ + const [ + reorderChannelWarehouses, + reorderChannelWarehousesOpts, + ] = useChannelReorderWarehousesMutation({ + onCompleted: data => { + const errors = data.channelReorderWarehouses.errors; + if (errors.length) { + errors.forEach(error => handleError(error)); + } + }, + }); + + const handleSubmit = async ({ name, slug, shippingZonesIdsToRemove, shippingZonesIdsToAdd, warehousesIdsToRemove, warehousesIdsToAdd, + warehousesToDisplay, defaultCountry, - }: FormData) => - extractMutationErrors( - updateChannel({ - variables: { - id: data?.channel.id, - input: { - name, - slug, - defaultCountry, - addShippingZones: shippingZonesIdsToAdd, - removeShippingZones: shippingZonesIdsToRemove, - addWarehouses: warehousesIdsToAdd, - removeWarehouses: warehousesIdsToRemove, + allocationStrategy, + }: FormData) => { + const updateChannelMutation = updateChannel({ + variables: { + id: data?.channel.id, + input: { + name, + slug, + defaultCountry, + addShippingZones: shippingZonesIdsToAdd, + removeShippingZones: shippingZonesIdsToRemove, + addWarehouses: warehousesIdsToAdd, + removeWarehouses: warehousesIdsToRemove, + stockSettings: { + allocationStrategy, }, }, - }), - ); + }, + }); + + const result = await updateChannelMutation; + const errors = await extractMutationErrors(updateChannelMutation); + + if (!errors?.length) { + const moves = calculateItemsOrderMoves( + result.data?.channelUpdate.channel?.warehouses, + warehousesToDisplay, + ); + + await reorderChannelWarehouses({ + variables: { + channelId: id, + moves, + }, + }); + } + + return errors; + }; const onDeleteCompleted = (data: ChannelDeleteMutation) => { const errors = data.channelDelete.errors; @@ -194,17 +231,6 @@ export const ChannelDetails: React.FC = ({ loading: warehousesCountLoading, } = useWarehousesCountQuery(); - const { - data: channelWarehousesData, - loading: channelsWarehousesLoading, - } = useChannelWarehousesQuery({ - variables: { - filter: { - channels: [id], - }, - }, - }); - const { loadMore: fetchMoreWarehouses, search: searchWarehouses, @@ -213,6 +239,11 @@ export const ChannelDetails: React.FC = ({ variables: DEFAULT_INITIAL_SEARCH_DATA, }); + const channelWarehouses = data?.channel?.warehouses || []; + const channelShippingZones = mapEdgesToItems( + channelShippingZonesData?.shippingZones, + ); + return ( <> = ({ node, - )} + channelShippingZones={channelShippingZones} allShippingZonesCount={ shippingZonesCountData?.shippingZones?.totalCount } @@ -240,9 +269,7 @@ export const ChannelDetails: React.FC = ({ searchShippingZonesResult, fetchMoreShippingZones, )} - channelWarehouses={channelWarehousesData?.warehouses?.edges?.map( - ({ node }) => node, - )} + channelWarehouses={channelWarehouses} allWarehousesCount={warehousesCountData?.warehouses?.totalCount} searchWarehouses={searchWarehouses} searchWarehousesData={searchWarehousesResult.data} @@ -253,11 +280,11 @@ export const ChannelDetails: React.FC = ({ channel={data?.channel} disabled={ updateChannelOpts.loading || + reorderChannelWarehousesOpts.loading || loading || shippingZonesCountLoading || warehousesCountLoading || - channelsShippingZonesLoading || - channelsWarehousesLoading + channelsShippingZonesLoading } disabledStatus={ activateChannelOpts.loading || deactivateChannelOpts.loading diff --git a/src/channels/views/ChannelDetails/handlers.ts b/src/channels/views/ChannelDetails/handlers.ts new file mode 100644 index 000000000..1d09b193e --- /dev/null +++ b/src/channels/views/ChannelDetails/handlers.ts @@ -0,0 +1,44 @@ +import { ReorderInput } from "@saleor/graphql"; +import { Node } from "@saleor/types"; +import { move } from "@saleor/utils/lists"; + +export function calculateItemsOrderMoves( + itemsInputOrder: T[], + itemsOutputOrder: T[], +): ReorderInput[] { + const itemsInputOrderIds = itemsInputOrder.map(item => item.id); + const itemsOutputOrderIds = itemsOutputOrder.map(item => item.id); + let itemsIntermediateOrderIds = itemsInputOrderIds; + + const itemsOrderMoves = itemsOutputOrderIds.reduce( + (moves, itemId, newIndex) => { + const oldIndex = itemsIntermediateOrderIds.indexOf(itemId); + + const sortOrder = newIndex - oldIndex; + + if (sortOrder === 0) { + return moves; + } + + const newMoves = [ + ...moves, + { + id: itemId, + sortOrder, + }, + ]; + + itemsIntermediateOrderIds = move( + itemsIntermediateOrderIds[oldIndex], + itemsIntermediateOrderIds, + (a, b) => a === b, + newIndex, + ); + + return newMoves; + }, + [] as ReorderInput[], + ); + + return itemsOrderMoves; +} diff --git a/src/fragments/channels.ts b/src/fragments/channels.ts index 0393c93d4..a8ebd57b1 100644 --- a/src/fragments/channels.ts +++ b/src/fragments/channels.ts @@ -19,6 +19,9 @@ export const channelFragment = gql` code country } + stockSettings { + allocationStrategy + } } `; @@ -26,5 +29,8 @@ export const channelDetailsFragment = gql` fragment ChannelDetails on Channel { ...Channel hasOrders + warehouses { + ...Warehouse + } } `; diff --git a/src/graphql/hooks.generated.ts b/src/graphql/hooks.generated.ts index 8adc43c25..c32b16d95 100644 --- a/src/graphql/hooks.generated.ts +++ b/src/graphql/hooks.generated.ts @@ -185,14 +185,27 @@ export const ChannelFragmentDoc = gql` code country } + stockSettings { + allocationStrategy + } +} + `; +export const WarehouseFragmentDoc = gql` + fragment Warehouse on Warehouse { + id + name } `; export const ChannelDetailsFragmentDoc = gql` fragment ChannelDetails on Channel { ...Channel hasOrders + warehouses { + ...Warehouse + } } - ${ChannelFragmentDoc}`; + ${ChannelFragmentDoc} +${WarehouseFragmentDoc}`; export const CollectionFragmentDoc = gql` fragment Collection on Collection { id @@ -1203,12 +1216,6 @@ export const OrderEventFragmentDoc = gql` } } `; -export const WarehouseFragmentDoc = gql` - fragment Warehouse on Warehouse { - id - name -} - `; export const StockFragmentDoc = gql` fragment Stock on Stock { id @@ -4387,6 +4394,46 @@ export function useChannelDeactivateMutation(baseOptions?: ApolloReactHooks.Muta export type ChannelDeactivateMutationHookResult = ReturnType; export type ChannelDeactivateMutationResult = Apollo.MutationResult; export type ChannelDeactivateMutationOptions = Apollo.BaseMutationOptions; +export const ChannelReorderWarehousesDocument = gql` + mutation ChannelReorderWarehouses($channelId: ID!, $moves: [ReorderInput!]!) { + channelReorderWarehouses(channelId: $channelId, moves: $moves) { + channel { + ...ChannelDetails + } + errors { + ...ChannelError + } + } +} + ${ChannelDetailsFragmentDoc} +${ChannelErrorFragmentDoc}`; +export type ChannelReorderWarehousesMutationFn = Apollo.MutationFunction; + +/** + * __useChannelReorderWarehousesMutation__ + * + * To run a mutation, you first call `useChannelReorderWarehousesMutation` within a React component and pass it any options that fit your needs. + * When your component renders, `useChannelReorderWarehousesMutation` returns a tuple that includes: + * - A mutate function that you can call at any time to execute the mutation + * - An object with fields that represent the current status of the mutation's execution + * + * @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2; + * + * @example + * const [channelReorderWarehousesMutation, { data, loading, error }] = useChannelReorderWarehousesMutation({ + * variables: { + * channelId: // value for 'channelId' + * moves: // value for 'moves' + * }, + * }); + */ +export function useChannelReorderWarehousesMutation(baseOptions?: ApolloReactHooks.MutationHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return ApolloReactHooks.useMutation(ChannelReorderWarehousesDocument, options); + } +export type ChannelReorderWarehousesMutationHookResult = ReturnType; +export type ChannelReorderWarehousesMutationResult = Apollo.MutationResult; +export type ChannelReorderWarehousesMutationOptions = Apollo.BaseMutationOptions; export const BaseChannelsDocument = gql` query BaseChannels { channels { @@ -16487,46 +16534,6 @@ export function useWarehouseDetailsLazyQuery(baseOptions?: ApolloReactHooks.Lazy export type WarehouseDetailsQueryHookResult = ReturnType; export type WarehouseDetailsLazyQueryHookResult = ReturnType; export type WarehouseDetailsQueryResult = Apollo.QueryResult; -export const ChannelWarehousesDocument = gql` - query ChannelWarehouses($filter: WarehouseFilterInput) { - warehouses(filter: $filter, first: 100) { - edges { - node { - id - name - } - } - } -} - `; - -/** - * __useChannelWarehousesQuery__ - * - * To run a query within a React component, call `useChannelWarehousesQuery` and pass it any options that fit your needs. - * When your component renders, `useChannelWarehousesQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useChannelWarehousesQuery({ - * variables: { - * filter: // value for 'filter' - * }, - * }); - */ -export function useChannelWarehousesQuery(baseOptions?: ApolloReactHooks.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return ApolloReactHooks.useQuery(ChannelWarehousesDocument, options); - } -export function useChannelWarehousesLazyQuery(baseOptions?: ApolloReactHooks.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return ApolloReactHooks.useLazyQuery(ChannelWarehousesDocument, options); - } -export type ChannelWarehousesQueryHookResult = ReturnType; -export type ChannelWarehousesLazyQueryHookResult = ReturnType; -export type ChannelWarehousesQueryResult = Apollo.QueryResult; export const WarehousesCountDocument = gql` query WarehousesCount { warehouses { diff --git a/src/graphql/typePolicies.generated.ts b/src/graphql/typePolicies.generated.ts index 44fd86327..8268053ca 100644 --- a/src/graphql/typePolicies.generated.ts +++ b/src/graphql/typePolicies.generated.ts @@ -716,7 +716,7 @@ export type CategoryUpdatedFieldPolicy = { recipient?: FieldPolicy | FieldReadFunction, category?: FieldPolicy | FieldReadFunction }; -export type ChannelKeySpecifier = ('id' | 'slug' | 'name' | 'isActive' | 'currencyCode' | 'hasOrders' | 'defaultCountry' | 'warehouses' | 'countries' | 'availableShippingMethodsPerCountry' | ChannelKeySpecifier)[]; +export type ChannelKeySpecifier = ('id' | 'slug' | 'name' | 'isActive' | 'currencyCode' | 'hasOrders' | 'defaultCountry' | 'warehouses' | 'countries' | 'availableShippingMethodsPerCountry' | 'stockSettings' | ChannelKeySpecifier)[]; export type ChannelFieldPolicy = { id?: FieldPolicy | FieldReadFunction, slug?: FieldPolicy | FieldReadFunction, @@ -727,7 +727,8 @@ export type ChannelFieldPolicy = { defaultCountry?: FieldPolicy | FieldReadFunction, warehouses?: FieldPolicy | FieldReadFunction, countries?: FieldPolicy | FieldReadFunction, - availableShippingMethodsPerCountry?: FieldPolicy | FieldReadFunction + availableShippingMethodsPerCountry?: FieldPolicy | FieldReadFunction, + stockSettings?: FieldPolicy | FieldReadFunction }; export type ChannelActivateKeySpecifier = ('channel' | 'channelErrors' | 'errors' | ChannelActivateKeySpecifier)[]; export type ChannelActivateFieldPolicy = { @@ -777,6 +778,11 @@ export type ChannelErrorFieldPolicy = { shippingZones?: FieldPolicy | FieldReadFunction, warehouses?: FieldPolicy | FieldReadFunction }; +export type ChannelReorderWarehousesKeySpecifier = ('channel' | 'errors' | ChannelReorderWarehousesKeySpecifier)[]; +export type ChannelReorderWarehousesFieldPolicy = { + channel?: FieldPolicy | FieldReadFunction, + errors?: FieldPolicy | FieldReadFunction +}; export type ChannelStatusChangedKeySpecifier = ('issuedAt' | 'version' | 'issuingPrincipal' | 'recipient' | 'channel' | ChannelStatusChangedKeySpecifier)[]; export type ChannelStatusChangedFieldPolicy = { issuedAt?: FieldPolicy | FieldReadFunction, @@ -2232,7 +2238,7 @@ export type MoneyRangeFieldPolicy = { start?: FieldPolicy | FieldReadFunction, stop?: FieldPolicy | FieldReadFunction }; -export type MutationKeySpecifier = ('webhookCreate' | 'webhookDelete' | 'webhookUpdate' | 'eventDeliveryRetry' | 'createWarehouse' | 'updateWarehouse' | 'deleteWarehouse' | 'assignWarehouseShippingZone' | 'unassignWarehouseShippingZone' | 'staffNotificationRecipientCreate' | 'staffNotificationRecipientUpdate' | 'staffNotificationRecipientDelete' | 'shopDomainUpdate' | 'shopSettingsUpdate' | 'shopFetchTaxRates' | 'shopSettingsTranslate' | 'shopAddressUpdate' | 'orderSettingsUpdate' | 'giftCardSettingsUpdate' | 'shippingMethodChannelListingUpdate' | 'shippingPriceCreate' | 'shippingPriceDelete' | 'shippingPriceBulkDelete' | 'shippingPriceUpdate' | 'shippingPriceTranslate' | 'shippingPriceExcludeProducts' | 'shippingPriceRemoveProductFromExclude' | 'shippingZoneCreate' | 'shippingZoneDelete' | 'shippingZoneBulkDelete' | 'shippingZoneUpdate' | 'productAttributeAssign' | 'productAttributeAssignmentUpdate' | 'productAttributeUnassign' | 'categoryCreate' | 'categoryDelete' | 'categoryBulkDelete' | 'categoryUpdate' | 'categoryTranslate' | 'collectionAddProducts' | 'collectionCreate' | 'collectionDelete' | 'collectionReorderProducts' | 'collectionBulkDelete' | 'collectionRemoveProducts' | 'collectionUpdate' | 'collectionTranslate' | 'collectionChannelListingUpdate' | 'productCreate' | 'productDelete' | 'productBulkDelete' | 'productUpdate' | 'productTranslate' | 'productChannelListingUpdate' | 'productMediaCreate' | 'productVariantReorder' | 'productMediaDelete' | 'productMediaBulkDelete' | 'productMediaReorder' | 'productMediaUpdate' | 'productTypeCreate' | 'productTypeDelete' | 'productTypeBulkDelete' | 'productTypeUpdate' | 'productTypeReorderAttributes' | 'productReorderAttributeValues' | 'digitalContentCreate' | 'digitalContentDelete' | 'digitalContentUpdate' | 'digitalContentUrlCreate' | 'productVariantCreate' | 'productVariantDelete' | 'productVariantBulkCreate' | 'productVariantBulkDelete' | 'productVariantStocksCreate' | 'productVariantStocksDelete' | 'productVariantStocksUpdate' | 'productVariantUpdate' | 'productVariantSetDefault' | 'productVariantTranslate' | 'productVariantChannelListingUpdate' | 'productVariantReorderAttributeValues' | 'productVariantPreorderDeactivate' | 'variantMediaAssign' | 'variantMediaUnassign' | 'paymentCapture' | 'paymentRefund' | 'paymentVoid' | 'paymentInitialize' | 'paymentCheckBalance' | 'transactionCreate' | 'transactionUpdate' | 'transactionRequestAction' | 'pageCreate' | 'pageDelete' | 'pageBulkDelete' | 'pageBulkPublish' | 'pageUpdate' | 'pageTranslate' | 'pageTypeCreate' | 'pageTypeUpdate' | 'pageTypeDelete' | 'pageTypeBulkDelete' | 'pageAttributeAssign' | 'pageAttributeUnassign' | 'pageTypeReorderAttributes' | 'pageReorderAttributeValues' | 'draftOrderComplete' | 'draftOrderCreate' | 'draftOrderDelete' | 'draftOrderBulkDelete' | 'draftOrderLinesBulkDelete' | 'draftOrderUpdate' | 'orderAddNote' | 'orderCancel' | 'orderCapture' | 'orderConfirm' | 'orderFulfill' | 'orderFulfillmentCancel' | 'orderFulfillmentApprove' | 'orderFulfillmentUpdateTracking' | 'orderFulfillmentRefundProducts' | 'orderFulfillmentReturnProducts' | 'orderLinesCreate' | 'orderLineDelete' | 'orderLineUpdate' | 'orderDiscountAdd' | 'orderDiscountUpdate' | 'orderDiscountDelete' | 'orderLineDiscountUpdate' | 'orderLineDiscountRemove' | 'orderMarkAsPaid' | 'orderRefund' | 'orderUpdate' | 'orderUpdateShipping' | 'orderVoid' | 'orderBulkCancel' | 'deleteMetadata' | 'deletePrivateMetadata' | 'updateMetadata' | 'updatePrivateMetadata' | 'assignNavigation' | 'menuCreate' | 'menuDelete' | 'menuBulkDelete' | 'menuUpdate' | 'menuItemCreate' | 'menuItemDelete' | 'menuItemBulkDelete' | 'menuItemUpdate' | 'menuItemTranslate' | 'menuItemMove' | 'invoiceRequest' | 'invoiceRequestDelete' | 'invoiceCreate' | 'invoiceDelete' | 'invoiceUpdate' | 'invoiceSendNotification' | 'giftCardActivate' | 'giftCardCreate' | 'giftCardDelete' | 'giftCardDeactivate' | 'giftCardUpdate' | 'giftCardResend' | 'giftCardAddNote' | 'giftCardBulkCreate' | 'giftCardBulkDelete' | 'giftCardBulkActivate' | 'giftCardBulkDeactivate' | 'pluginUpdate' | 'externalNotificationTrigger' | 'saleCreate' | 'saleDelete' | 'saleBulkDelete' | 'saleUpdate' | 'saleCataloguesAdd' | 'saleCataloguesRemove' | 'saleTranslate' | 'saleChannelListingUpdate' | 'voucherCreate' | 'voucherDelete' | 'voucherBulkDelete' | 'voucherUpdate' | 'voucherCataloguesAdd' | 'voucherCataloguesRemove' | 'voucherTranslate' | 'voucherChannelListingUpdate' | 'exportProducts' | 'exportGiftCards' | 'fileUpload' | 'checkoutAddPromoCode' | 'checkoutBillingAddressUpdate' | 'checkoutComplete' | 'checkoutCreate' | 'checkoutCustomerAttach' | 'checkoutCustomerDetach' | 'checkoutEmailUpdate' | 'checkoutLineDelete' | 'checkoutLinesDelete' | 'checkoutLinesAdd' | 'checkoutLinesUpdate' | 'checkoutRemovePromoCode' | 'checkoutPaymentCreate' | 'checkoutShippingAddressUpdate' | 'checkoutShippingMethodUpdate' | 'checkoutDeliveryMethodUpdate' | 'checkoutLanguageCodeUpdate' | 'orderCreateFromCheckout' | 'channelCreate' | 'channelUpdate' | 'channelDelete' | 'channelActivate' | 'channelDeactivate' | 'attributeCreate' | 'attributeDelete' | 'attributeUpdate' | 'attributeTranslate' | 'attributeBulkDelete' | 'attributeValueBulkDelete' | 'attributeValueCreate' | 'attributeValueDelete' | 'attributeValueUpdate' | 'attributeValueTranslate' | 'attributeReorderValues' | 'appCreate' | 'appUpdate' | 'appDelete' | 'appTokenCreate' | 'appTokenDelete' | 'appTokenVerify' | 'appInstall' | 'appRetryInstall' | 'appDeleteFailedInstallation' | 'appFetchManifest' | 'appActivate' | 'appDeactivate' | 'tokenCreate' | 'tokenRefresh' | 'tokenVerify' | 'tokensDeactivateAll' | 'externalAuthenticationUrl' | 'externalObtainAccessTokens' | 'externalRefresh' | 'externalLogout' | 'externalVerify' | 'requestPasswordReset' | 'confirmAccount' | 'setPassword' | 'passwordChange' | 'requestEmailChange' | 'confirmEmailChange' | 'accountAddressCreate' | 'accountAddressUpdate' | 'accountAddressDelete' | 'accountSetDefaultAddress' | 'accountRegister' | 'accountUpdate' | 'accountRequestDeletion' | 'accountDelete' | 'addressCreate' | 'addressUpdate' | 'addressDelete' | 'addressSetDefault' | 'customerCreate' | 'customerUpdate' | 'customerDelete' | 'customerBulkDelete' | 'staffCreate' | 'staffUpdate' | 'staffDelete' | 'staffBulkDelete' | 'userAvatarUpdate' | 'userAvatarDelete' | 'userBulkSetActive' | 'permissionGroupCreate' | 'permissionGroupUpdate' | 'permissionGroupDelete' | MutationKeySpecifier)[]; +export type MutationKeySpecifier = ('webhookCreate' | 'webhookDelete' | 'webhookUpdate' | 'eventDeliveryRetry' | 'createWarehouse' | 'updateWarehouse' | 'deleteWarehouse' | 'assignWarehouseShippingZone' | 'unassignWarehouseShippingZone' | 'staffNotificationRecipientCreate' | 'staffNotificationRecipientUpdate' | 'staffNotificationRecipientDelete' | 'shopDomainUpdate' | 'shopSettingsUpdate' | 'shopFetchTaxRates' | 'shopSettingsTranslate' | 'shopAddressUpdate' | 'orderSettingsUpdate' | 'giftCardSettingsUpdate' | 'shippingMethodChannelListingUpdate' | 'shippingPriceCreate' | 'shippingPriceDelete' | 'shippingPriceBulkDelete' | 'shippingPriceUpdate' | 'shippingPriceTranslate' | 'shippingPriceExcludeProducts' | 'shippingPriceRemoveProductFromExclude' | 'shippingZoneCreate' | 'shippingZoneDelete' | 'shippingZoneBulkDelete' | 'shippingZoneUpdate' | 'productAttributeAssign' | 'productAttributeAssignmentUpdate' | 'productAttributeUnassign' | 'categoryCreate' | 'categoryDelete' | 'categoryBulkDelete' | 'categoryUpdate' | 'categoryTranslate' | 'collectionAddProducts' | 'collectionCreate' | 'collectionDelete' | 'collectionReorderProducts' | 'collectionBulkDelete' | 'collectionRemoveProducts' | 'collectionUpdate' | 'collectionTranslate' | 'collectionChannelListingUpdate' | 'productCreate' | 'productDelete' | 'productBulkDelete' | 'productUpdate' | 'productTranslate' | 'productChannelListingUpdate' | 'productMediaCreate' | 'productVariantReorder' | 'productMediaDelete' | 'productMediaBulkDelete' | 'productMediaReorder' | 'productMediaUpdate' | 'productTypeCreate' | 'productTypeDelete' | 'productTypeBulkDelete' | 'productTypeUpdate' | 'productTypeReorderAttributes' | 'productReorderAttributeValues' | 'digitalContentCreate' | 'digitalContentDelete' | 'digitalContentUpdate' | 'digitalContentUrlCreate' | 'productVariantCreate' | 'productVariantDelete' | 'productVariantBulkCreate' | 'productVariantBulkDelete' | 'productVariantStocksCreate' | 'productVariantStocksDelete' | 'productVariantStocksUpdate' | 'productVariantUpdate' | 'productVariantSetDefault' | 'productVariantTranslate' | 'productVariantChannelListingUpdate' | 'productVariantReorderAttributeValues' | 'productVariantPreorderDeactivate' | 'variantMediaAssign' | 'variantMediaUnassign' | 'paymentCapture' | 'paymentRefund' | 'paymentVoid' | 'paymentInitialize' | 'paymentCheckBalance' | 'transactionCreate' | 'transactionUpdate' | 'transactionRequestAction' | 'pageCreate' | 'pageDelete' | 'pageBulkDelete' | 'pageBulkPublish' | 'pageUpdate' | 'pageTranslate' | 'pageTypeCreate' | 'pageTypeUpdate' | 'pageTypeDelete' | 'pageTypeBulkDelete' | 'pageAttributeAssign' | 'pageAttributeUnassign' | 'pageTypeReorderAttributes' | 'pageReorderAttributeValues' | 'draftOrderComplete' | 'draftOrderCreate' | 'draftOrderDelete' | 'draftOrderBulkDelete' | 'draftOrderLinesBulkDelete' | 'draftOrderUpdate' | 'orderAddNote' | 'orderCancel' | 'orderCapture' | 'orderConfirm' | 'orderFulfill' | 'orderFulfillmentCancel' | 'orderFulfillmentApprove' | 'orderFulfillmentUpdateTracking' | 'orderFulfillmentRefundProducts' | 'orderFulfillmentReturnProducts' | 'orderLinesCreate' | 'orderLineDelete' | 'orderLineUpdate' | 'orderDiscountAdd' | 'orderDiscountUpdate' | 'orderDiscountDelete' | 'orderLineDiscountUpdate' | 'orderLineDiscountRemove' | 'orderMarkAsPaid' | 'orderRefund' | 'orderUpdate' | 'orderUpdateShipping' | 'orderVoid' | 'orderBulkCancel' | 'deleteMetadata' | 'deletePrivateMetadata' | 'updateMetadata' | 'updatePrivateMetadata' | 'assignNavigation' | 'menuCreate' | 'menuDelete' | 'menuBulkDelete' | 'menuUpdate' | 'menuItemCreate' | 'menuItemDelete' | 'menuItemBulkDelete' | 'menuItemUpdate' | 'menuItemTranslate' | 'menuItemMove' | 'invoiceRequest' | 'invoiceRequestDelete' | 'invoiceCreate' | 'invoiceDelete' | 'invoiceUpdate' | 'invoiceSendNotification' | 'giftCardActivate' | 'giftCardCreate' | 'giftCardDelete' | 'giftCardDeactivate' | 'giftCardUpdate' | 'giftCardResend' | 'giftCardAddNote' | 'giftCardBulkCreate' | 'giftCardBulkDelete' | 'giftCardBulkActivate' | 'giftCardBulkDeactivate' | 'pluginUpdate' | 'externalNotificationTrigger' | 'saleCreate' | 'saleDelete' | 'saleBulkDelete' | 'saleUpdate' | 'saleCataloguesAdd' | 'saleCataloguesRemove' | 'saleTranslate' | 'saleChannelListingUpdate' | 'voucherCreate' | 'voucherDelete' | 'voucherBulkDelete' | 'voucherUpdate' | 'voucherCataloguesAdd' | 'voucherCataloguesRemove' | 'voucherTranslate' | 'voucherChannelListingUpdate' | 'exportProducts' | 'exportGiftCards' | 'fileUpload' | 'checkoutAddPromoCode' | 'checkoutBillingAddressUpdate' | 'checkoutComplete' | 'checkoutCreate' | 'checkoutCustomerAttach' | 'checkoutCustomerDetach' | 'checkoutEmailUpdate' | 'checkoutLineDelete' | 'checkoutLinesDelete' | 'checkoutLinesAdd' | 'checkoutLinesUpdate' | 'checkoutRemovePromoCode' | 'checkoutPaymentCreate' | 'checkoutShippingAddressUpdate' | 'checkoutShippingMethodUpdate' | 'checkoutDeliveryMethodUpdate' | 'checkoutLanguageCodeUpdate' | 'orderCreateFromCheckout' | 'channelCreate' | 'channelUpdate' | 'channelDelete' | 'channelActivate' | 'channelDeactivate' | 'channelReorderWarehouses' | 'attributeCreate' | 'attributeDelete' | 'attributeUpdate' | 'attributeTranslate' | 'attributeBulkDelete' | 'attributeValueBulkDelete' | 'attributeValueCreate' | 'attributeValueDelete' | 'attributeValueUpdate' | 'attributeValueTranslate' | 'attributeReorderValues' | 'appCreate' | 'appUpdate' | 'appDelete' | 'appTokenCreate' | 'appTokenDelete' | 'appTokenVerify' | 'appInstall' | 'appRetryInstall' | 'appDeleteFailedInstallation' | 'appFetchManifest' | 'appActivate' | 'appDeactivate' | 'tokenCreate' | 'tokenRefresh' | 'tokenVerify' | 'tokensDeactivateAll' | 'externalAuthenticationUrl' | 'externalObtainAccessTokens' | 'externalRefresh' | 'externalLogout' | 'externalVerify' | 'requestPasswordReset' | 'confirmAccount' | 'setPassword' | 'passwordChange' | 'requestEmailChange' | 'confirmEmailChange' | 'accountAddressCreate' | 'accountAddressUpdate' | 'accountAddressDelete' | 'accountSetDefaultAddress' | 'accountRegister' | 'accountUpdate' | 'accountRequestDeletion' | 'accountDelete' | 'addressCreate' | 'addressUpdate' | 'addressDelete' | 'addressSetDefault' | 'customerCreate' | 'customerUpdate' | 'customerDelete' | 'customerBulkDelete' | 'staffCreate' | 'staffUpdate' | 'staffDelete' | 'staffBulkDelete' | 'userAvatarUpdate' | 'userAvatarDelete' | 'userBulkSetActive' | 'permissionGroupCreate' | 'permissionGroupUpdate' | 'permissionGroupDelete' | MutationKeySpecifier)[]; export type MutationFieldPolicy = { webhookCreate?: FieldPolicy | FieldReadFunction, webhookDelete?: FieldPolicy | FieldReadFunction, @@ -2447,6 +2453,7 @@ export type MutationFieldPolicy = { channelDelete?: FieldPolicy | FieldReadFunction, channelActivate?: FieldPolicy | FieldReadFunction, channelDeactivate?: FieldPolicy | FieldReadFunction, + channelReorderWarehouses?: FieldPolicy | FieldReadFunction, attributeCreate?: FieldPolicy | FieldReadFunction, attributeDelete?: FieldPolicy | FieldReadFunction, attributeUpdate?: FieldPolicy | FieldReadFunction, @@ -4614,6 +4621,10 @@ export type StockErrorFieldPolicy = { message?: FieldPolicy | FieldReadFunction, code?: FieldPolicy | FieldReadFunction }; +export type StockSettingsKeySpecifier = ('allocationStrategy' | StockSettingsKeySpecifier)[]; +export type StockSettingsFieldPolicy = { + allocationStrategy?: FieldPolicy | FieldReadFunction +}; export type SubscriptionKeySpecifier = ('event' | SubscriptionKeySpecifier)[]; export type SubscriptionFieldPolicy = { event?: FieldPolicy | FieldReadFunction @@ -5570,6 +5581,10 @@ export type StrictTypedTypePolicies = { keyFields?: false | ChannelErrorKeySpecifier | (() => undefined | ChannelErrorKeySpecifier), fields?: ChannelErrorFieldPolicy, }, + ChannelReorderWarehouses?: Omit & { + keyFields?: false | ChannelReorderWarehousesKeySpecifier | (() => undefined | ChannelReorderWarehousesKeySpecifier), + fields?: ChannelReorderWarehousesFieldPolicy, + }, ChannelStatusChanged?: Omit & { keyFields?: false | ChannelStatusChangedKeySpecifier | (() => undefined | ChannelStatusChangedKeySpecifier), fields?: ChannelStatusChangedFieldPolicy, @@ -7370,6 +7385,10 @@ export type StrictTypedTypePolicies = { keyFields?: false | StockErrorKeySpecifier | (() => undefined | StockErrorKeySpecifier), fields?: StockErrorFieldPolicy, }, + StockSettings?: Omit & { + keyFields?: false | StockSettingsKeySpecifier | (() => undefined | StockSettingsKeySpecifier), + fields?: StockSettingsFieldPolicy, + }, Subscription?: Omit & { keyFields?: false | SubscriptionKeySpecifier | (() => undefined | SubscriptionKeySpecifier), fields?: SubscriptionFieldPolicy, diff --git a/src/graphql/types.generated.ts b/src/graphql/types.generated.ts index 1440fdac8..942098d50 100644 --- a/src/graphql/types.generated.ts +++ b/src/graphql/types.generated.ts @@ -156,6 +156,21 @@ export enum AddressTypeEnum { SHIPPING = 'SHIPPING' } +/** + * Determine the allocation strategy for the channel. + * + * PRIORITIZE_SORTING_ORDER - the allocation is prioritized by the warehouses' sort + * order within the channel + * + * PRIORITIZE_HIGH_STOCK - the allocation is prioritized by the highest available + * quantity in stocks + * + */ +export enum AllocationStrategyEnum { + PRIORITIZE_SORTING_ORDER = 'PRIORITIZE_SORTING_ORDER', + PRIORITIZE_HIGH_STOCK = 'PRIORITIZE_HIGH_STOCK' +} + /** An enumeration. */ export enum AppErrorCode { FORBIDDEN = 'FORBIDDEN', @@ -606,6 +621,14 @@ export type CategorySortingInput = { export type ChannelCreateInput = { /** isActive flag. */ isActive?: InputMaybe; + /** + * The channel stock settings. + * + * Added in Saleor 3.7. + * + * Note: this API is currently in Feature Preview and can be subject to changes at later point. + */ + stockSettings?: InputMaybe; /** List of shipping zones to assign to the channel. */ addShippingZones?: InputMaybe>; /** @@ -653,6 +676,14 @@ export enum ChannelErrorCode { export type ChannelUpdateInput = { /** isActive flag. */ isActive?: InputMaybe; + /** + * The channel stock settings. + * + * Added in Saleor 3.7. + * + * Note: this API is currently in Feature Preview and can be subject to changes at later point. + */ + stockSettings?: InputMaybe; /** List of shipping zones to assign to the channel. */ addShippingZones?: InputMaybe>; /** @@ -3031,6 +3062,12 @@ export type OrderFulfillInput = { notifyCustomer?: InputMaybe; /** If true, then allow proceed fulfillment when stock is exceeded. */ allowStockToBeExceeded?: InputMaybe; + /** + * Fulfillment tracking number. + * + * Added in Saleor 3.6. + */ + trackingNumber?: InputMaybe; }; export type OrderFulfillLineInput = { @@ -3963,6 +4000,8 @@ export type ProductVariantBulkCreateInput = { attributes: Array; /** Stock keeping unit. */ sku?: InputMaybe; + /** Variant name. */ + name?: InputMaybe; /** Determines if the inventory of this variant should be tracked. If false, the quantity won't change when customers buy this item. */ trackInventory?: InputMaybe; /** Weight of the Product Variant. */ @@ -4011,6 +4050,8 @@ export type ProductVariantCreateInput = { attributes: Array; /** Stock keeping unit. */ sku?: InputMaybe; + /** Variant name. */ + name?: InputMaybe; /** Determines if the inventory of this variant should be tracked. If false, the quantity won't change when customers buy this item. */ trackInventory?: InputMaybe; /** Weight of the Product Variant. */ @@ -4050,6 +4091,8 @@ export type ProductVariantInput = { attributes?: InputMaybe>; /** Stock keeping unit. */ sku?: InputMaybe; + /** Variant name. */ + name?: InputMaybe; /** Determines if the inventory of this variant should be tracked. If false, the quantity won't change when customers buy this item. */ trackInventory?: InputMaybe; /** Weight of the Product Variant. */ @@ -4493,6 +4536,11 @@ export type StockInput = { quantity: Scalars['Int']; }; +export type StockSettingsInput = { + /** Allocation strategy options. Strategy defines the preference of warehouses for allocations and reservations. */ + allocationStrategy: AllocationStrategyEnum; +}; + /** Enum representing the type of a payment storage in a gateway. */ export enum StorePaymentMethodEnum { /** On session storage type. The payment is stored only to be reused when the customer is present in the checkout flow. */ @@ -4965,7 +5013,11 @@ export type WebhookCreateInput = { app?: InputMaybe; /** Determine if webhook will be set active or not. */ isActive?: InputMaybe; - /** The secret key used to create a hash signature with each payload. */ + /** + * The secret key used to create a hash signature with each payload. + * + * DEPRECATED: this field will be removed in Saleor 4.0. As of Saleor 3.5, webhook payloads default to signing using a verifiable JWS. + */ secretKey?: InputMaybe; /** * Subscription query used to define a webhook payload. @@ -5562,7 +5614,11 @@ export type WebhookUpdateInput = { app?: InputMaybe; /** Determine if webhook will be set active or not. */ isActive?: InputMaybe; - /** Use to create a hash signature with each payload. */ + /** + * Use to create a hash signature with each payload. + * + * DEPRECATED: this field will be removed in Saleor 4.0. As of Saleor 3.5, webhook payloads default to signing using a verifiable JWS. + */ secretKey?: InputMaybe; /** * Subscription query used to define a webhook payload. @@ -5867,7 +5923,7 @@ export type ChannelCreateMutationVariables = Exact<{ }>; -export type ChannelCreateMutation = { __typename: 'Mutation', channelCreate: { __typename: 'ChannelCreate', channel: { __typename: 'Channel', hasOrders: boolean, id: string, isActive: boolean, name: string, slug: string, currencyCode: string, defaultCountry: { __typename: 'CountryDisplay', code: string, country: string } } | null, errors: Array<{ __typename: 'ChannelError', code: ChannelErrorCode, field: string | null, message: string | null }> } | null }; +export type ChannelCreateMutation = { __typename: 'Mutation', channelCreate: { __typename: 'ChannelCreate', channel: { __typename: 'Channel', hasOrders: boolean, id: string, isActive: boolean, name: string, slug: string, currencyCode: string, warehouses: Array<{ __typename: 'Warehouse', id: string, name: string }>, defaultCountry: { __typename: 'CountryDisplay', code: string, country: string }, stockSettings: { __typename: 'StockSettings', allocationStrategy: AllocationStrategyEnum } } | null, errors: Array<{ __typename: 'ChannelError', code: ChannelErrorCode, field: string | null, message: string | null }> } | null }; export type ChannelUpdateMutationVariables = Exact<{ id: Scalars['ID']; @@ -5875,7 +5931,7 @@ export type ChannelUpdateMutationVariables = Exact<{ }>; -export type ChannelUpdateMutation = { __typename: 'Mutation', channelUpdate: { __typename: 'ChannelUpdate', channel: { __typename: 'Channel', hasOrders: boolean, id: string, isActive: boolean, name: string, slug: string, currencyCode: string, defaultCountry: { __typename: 'CountryDisplay', code: string, country: string } } | null, errors: Array<{ __typename: 'ChannelError', code: ChannelErrorCode, field: string | null, message: string | null }> } | null }; +export type ChannelUpdateMutation = { __typename: 'Mutation', channelUpdate: { __typename: 'ChannelUpdate', channel: { __typename: 'Channel', hasOrders: boolean, id: string, isActive: boolean, name: string, slug: string, currencyCode: string, warehouses: Array<{ __typename: 'Warehouse', id: string, name: string }>, defaultCountry: { __typename: 'CountryDisplay', code: string, country: string }, stockSettings: { __typename: 'StockSettings', allocationStrategy: AllocationStrategyEnum } } | null, errors: Array<{ __typename: 'ChannelError', code: ChannelErrorCode, field: string | null, message: string | null }> } | null }; export type ChannelDeleteMutationVariables = Exact<{ id: Scalars['ID']; @@ -5890,31 +5946,39 @@ export type ChannelActivateMutationVariables = Exact<{ }>; -export type ChannelActivateMutation = { __typename: 'Mutation', channelActivate: { __typename: 'ChannelActivate', channel: { __typename: 'Channel', hasOrders: boolean, id: string, isActive: boolean, name: string, slug: string, currencyCode: string, defaultCountry: { __typename: 'CountryDisplay', code: string, country: string } } | null, errors: Array<{ __typename: 'ChannelError', code: ChannelErrorCode, field: string | null, message: string | null }> } | null }; +export type ChannelActivateMutation = { __typename: 'Mutation', channelActivate: { __typename: 'ChannelActivate', channel: { __typename: 'Channel', hasOrders: boolean, id: string, isActive: boolean, name: string, slug: string, currencyCode: string, warehouses: Array<{ __typename: 'Warehouse', id: string, name: string }>, defaultCountry: { __typename: 'CountryDisplay', code: string, country: string }, stockSettings: { __typename: 'StockSettings', allocationStrategy: AllocationStrategyEnum } } | null, errors: Array<{ __typename: 'ChannelError', code: ChannelErrorCode, field: string | null, message: string | null }> } | null }; export type ChannelDeactivateMutationVariables = Exact<{ id: Scalars['ID']; }>; -export type ChannelDeactivateMutation = { __typename: 'Mutation', channelDeactivate: { __typename: 'ChannelDeactivate', channel: { __typename: 'Channel', hasOrders: boolean, id: string, isActive: boolean, name: string, slug: string, currencyCode: string, defaultCountry: { __typename: 'CountryDisplay', code: string, country: string } } | null, errors: Array<{ __typename: 'ChannelError', code: ChannelErrorCode, field: string | null, message: string | null }> } | null }; +export type ChannelDeactivateMutation = { __typename: 'Mutation', channelDeactivate: { __typename: 'ChannelDeactivate', channel: { __typename: 'Channel', hasOrders: boolean, id: string, isActive: boolean, name: string, slug: string, currencyCode: string, warehouses: Array<{ __typename: 'Warehouse', id: string, name: string }>, defaultCountry: { __typename: 'CountryDisplay', code: string, country: string }, stockSettings: { __typename: 'StockSettings', allocationStrategy: AllocationStrategyEnum } } | null, errors: Array<{ __typename: 'ChannelError', code: ChannelErrorCode, field: string | null, message: string | null }> } | null }; + +export type ChannelReorderWarehousesMutationVariables = Exact<{ + channelId: Scalars['ID']; + moves: Array | ReorderInput; +}>; + + +export type ChannelReorderWarehousesMutation = { __typename: 'Mutation', channelReorderWarehouses: { __typename: 'ChannelReorderWarehouses', channel: { __typename: 'Channel', hasOrders: boolean, id: string, isActive: boolean, name: string, slug: string, currencyCode: string, warehouses: Array<{ __typename: 'Warehouse', id: string, name: string }>, defaultCountry: { __typename: 'CountryDisplay', code: string, country: string }, stockSettings: { __typename: 'StockSettings', allocationStrategy: AllocationStrategyEnum } } | null, errors: Array<{ __typename: 'ChannelError', code: ChannelErrorCode, field: string | null, message: string | null }> } | null }; export type BaseChannelsQueryVariables = Exact<{ [key: string]: never; }>; -export type BaseChannelsQuery = { __typename: 'Query', channels: Array<{ __typename: 'Channel', id: string, isActive: boolean, name: string, slug: string, currencyCode: string, defaultCountry: { __typename: 'CountryDisplay', code: string, country: string } }> | null }; +export type BaseChannelsQuery = { __typename: 'Query', channels: Array<{ __typename: 'Channel', id: string, isActive: boolean, name: string, slug: string, currencyCode: string, defaultCountry: { __typename: 'CountryDisplay', code: string, country: string }, stockSettings: { __typename: 'StockSettings', allocationStrategy: AllocationStrategyEnum } }> | null }; export type ChannelsQueryVariables = Exact<{ [key: string]: never; }>; -export type ChannelsQuery = { __typename: 'Query', channels: Array<{ __typename: 'Channel', hasOrders: boolean, id: string, isActive: boolean, name: string, slug: string, currencyCode: string, defaultCountry: { __typename: 'CountryDisplay', code: string, country: string } }> | null }; +export type ChannelsQuery = { __typename: 'Query', channels: Array<{ __typename: 'Channel', hasOrders: boolean, id: string, isActive: boolean, name: string, slug: string, currencyCode: string, warehouses: Array<{ __typename: 'Warehouse', id: string, name: string }>, defaultCountry: { __typename: 'CountryDisplay', code: string, country: string }, stockSettings: { __typename: 'StockSettings', allocationStrategy: AllocationStrategyEnum } }> | null }; export type ChannelQueryVariables = Exact<{ id: Scalars['ID']; }>; -export type ChannelQuery = { __typename: 'Query', channel: { __typename: 'Channel', hasOrders: boolean, id: string, isActive: boolean, name: string, slug: string, currencyCode: string, defaultCountry: { __typename: 'CountryDisplay', code: string, country: string } } | null }; +export type ChannelQuery = { __typename: 'Query', channel: { __typename: 'Channel', hasOrders: boolean, id: string, isActive: boolean, name: string, slug: string, currencyCode: string, warehouses: Array<{ __typename: 'Warehouse', id: string, name: string }>, defaultCountry: { __typename: 'CountryDisplay', code: string, country: string }, stockSettings: { __typename: 'StockSettings', allocationStrategy: AllocationStrategyEnum } } | null }; export type CollectionUpdateMutationVariables = Exact<{ id: Scalars['ID']; @@ -6082,7 +6146,7 @@ export type SetCustomerDefaultAddressMutationVariables = Exact<{ }>; -export type SetCustomerDefaultAddressMutation = { __typename: 'Mutation', addressSetDefault: { __typename: 'AddressSetDefault', errors: Array<{ __typename: 'AccountError', code: AccountErrorCode, field: string | null, addressType: AddressTypeEnum | null, message: string | null }>, user: { __typename: 'User', id: string, email: string, firstName: string, lastName: string, addresses: Array<{ __typename: 'Address', city: string, cityArea: string, companyName: string, countryArea: string, firstName: string, id: string, lastName: string, phone: string | null, postalCode: string, streetAddress1: string, streetAddress2: string, country: { __typename: 'CountryDisplay', code: string, country: string } }> | null, defaultBillingAddress: { __typename: 'Address', id: string } | null, defaultShippingAddress: { __typename: 'Address', id: string } | null } | null } | null }; +export type SetCustomerDefaultAddressMutation = { __typename: 'Mutation', addressSetDefault: { __typename: 'AddressSetDefault', errors: Array<{ __typename: 'AccountError', code: AccountErrorCode, field: string | null, addressType: AddressTypeEnum | null, message: string | null }>, user: { __typename: 'User', id: string, email: string, firstName: string, lastName: string, addresses: Array<{ __typename: 'Address', city: string, cityArea: string, companyName: string, countryArea: string, firstName: string, id: string, lastName: string, phone: string | null, postalCode: string, streetAddress1: string, streetAddress2: string, country: { __typename: 'CountryDisplay', code: string, country: string } }>, defaultBillingAddress: { __typename: 'Address', id: string } | null, defaultShippingAddress: { __typename: 'Address', id: string } | null } | null } | null }; export type CreateCustomerAddressMutationVariables = Exact<{ id: Scalars['ID']; @@ -6090,7 +6154,7 @@ export type CreateCustomerAddressMutationVariables = Exact<{ }>; -export type CreateCustomerAddressMutation = { __typename: 'Mutation', addressCreate: { __typename: 'AddressCreate', errors: Array<{ __typename: 'AccountError', code: AccountErrorCode, field: string | null, addressType: AddressTypeEnum | null, message: string | null }>, address: { __typename: 'Address', city: string, cityArea: string, companyName: string, countryArea: string, firstName: string, id: string, lastName: string, phone: string | null, postalCode: string, streetAddress1: string, streetAddress2: string, country: { __typename: 'CountryDisplay', code: string, country: string } } | null, user: { __typename: 'User', id: string, email: string, firstName: string, lastName: string, addresses: Array<{ __typename: 'Address', city: string, cityArea: string, companyName: string, countryArea: string, firstName: string, id: string, lastName: string, phone: string | null, postalCode: string, streetAddress1: string, streetAddress2: string, country: { __typename: 'CountryDisplay', code: string, country: string } }> | null, defaultBillingAddress: { __typename: 'Address', id: string } | null, defaultShippingAddress: { __typename: 'Address', id: string } | null } | null } | null }; +export type CreateCustomerAddressMutation = { __typename: 'Mutation', addressCreate: { __typename: 'AddressCreate', errors: Array<{ __typename: 'AccountError', code: AccountErrorCode, field: string | null, addressType: AddressTypeEnum | null, message: string | null }>, address: { __typename: 'Address', city: string, cityArea: string, companyName: string, countryArea: string, firstName: string, id: string, lastName: string, phone: string | null, postalCode: string, streetAddress1: string, streetAddress2: string, country: { __typename: 'CountryDisplay', code: string, country: string } } | null, user: { __typename: 'User', id: string, email: string, firstName: string, lastName: string, addresses: Array<{ __typename: 'Address', city: string, cityArea: string, companyName: string, countryArea: string, firstName: string, id: string, lastName: string, phone: string | null, postalCode: string, streetAddress1: string, streetAddress2: string, country: { __typename: 'CountryDisplay', code: string, country: string } }>, defaultBillingAddress: { __typename: 'Address', id: string } | null, defaultShippingAddress: { __typename: 'Address', id: string } | null } | null } | null }; export type UpdateCustomerAddressMutationVariables = Exact<{ id: Scalars['ID']; @@ -6105,7 +6169,7 @@ export type RemoveCustomerAddressMutationVariables = Exact<{ }>; -export type RemoveCustomerAddressMutation = { __typename: 'Mutation', addressDelete: { __typename: 'AddressDelete', errors: Array<{ __typename: 'AccountError', code: AccountErrorCode, field: string | null, addressType: AddressTypeEnum | null, message: string | null }>, user: { __typename: 'User', id: string, email: string, firstName: string, lastName: string, addresses: Array<{ __typename: 'Address', city: string, cityArea: string, companyName: string, countryArea: string, firstName: string, id: string, lastName: string, phone: string | null, postalCode: string, streetAddress1: string, streetAddress2: string, country: { __typename: 'CountryDisplay', code: string, country: string } }> | null, defaultBillingAddress: { __typename: 'Address', id: string } | null, defaultShippingAddress: { __typename: 'Address', id: string } | null } | null } | null }; +export type RemoveCustomerAddressMutation = { __typename: 'Mutation', addressDelete: { __typename: 'AddressDelete', errors: Array<{ __typename: 'AccountError', code: AccountErrorCode, field: string | null, addressType: AddressTypeEnum | null, message: string | null }>, user: { __typename: 'User', id: string, email: string, firstName: string, lastName: string, addresses: Array<{ __typename: 'Address', city: string, cityArea: string, companyName: string, countryArea: string, firstName: string, id: string, lastName: string, phone: string | null, postalCode: string, streetAddress1: string, streetAddress2: string, country: { __typename: 'CountryDisplay', code: string, country: string } }>, defaultBillingAddress: { __typename: 'Address', id: string } | null, defaultShippingAddress: { __typename: 'Address', id: string } | null } | null } | null }; export type BulkRemoveCustomersMutationVariables = Exact<{ ids: Array | Scalars['ID']; @@ -6140,7 +6204,7 @@ export type CustomerAddressesQueryVariables = Exact<{ }>; -export type CustomerAddressesQuery = { __typename: 'Query', user: { __typename: 'User', id: string, email: string, firstName: string, lastName: string, addresses: Array<{ __typename: 'Address', city: string, cityArea: string, companyName: string, countryArea: string, firstName: string, id: string, lastName: string, phone: string | null, postalCode: string, streetAddress1: string, streetAddress2: string, country: { __typename: 'CountryDisplay', code: string, country: string } }> | null, defaultBillingAddress: { __typename: 'Address', id: string } | null, defaultShippingAddress: { __typename: 'Address', id: string } | null } | null }; +export type CustomerAddressesQuery = { __typename: 'Query', user: { __typename: 'User', id: string, email: string, firstName: string, lastName: string, addresses: Array<{ __typename: 'Address', city: string, cityArea: string, companyName: string, countryArea: string, firstName: string, id: string, lastName: string, phone: string | null, postalCode: string, streetAddress1: string, streetAddress2: string, country: { __typename: 'CountryDisplay', code: string, country: string } }>, defaultBillingAddress: { __typename: 'Address', id: string } | null, defaultShippingAddress: { __typename: 'Address', id: string } | null } | null }; export type CustomerCreateDataQueryVariables = Exact<{ [key: string]: never; }>; @@ -6357,9 +6421,9 @@ export type CategoryDetailsFragment = { __typename: 'Category', id: string, name export type ChannelErrorFragment = { __typename: 'ChannelError', code: ChannelErrorCode, field: string | null, message: string | null }; -export type ChannelFragment = { __typename: 'Channel', id: string, isActive: boolean, name: string, slug: string, currencyCode: string, defaultCountry: { __typename: 'CountryDisplay', code: string, country: string } }; +export type ChannelFragment = { __typename: 'Channel', id: string, isActive: boolean, name: string, slug: string, currencyCode: string, defaultCountry: { __typename: 'CountryDisplay', code: string, country: string }, stockSettings: { __typename: 'StockSettings', allocationStrategy: AllocationStrategyEnum } }; -export type ChannelDetailsFragment = { __typename: 'Channel', hasOrders: boolean, id: string, isActive: boolean, name: string, slug: string, currencyCode: string, defaultCountry: { __typename: 'CountryDisplay', code: string, country: string } }; +export type ChannelDetailsFragment = { __typename: 'Channel', hasOrders: boolean, id: string, isActive: boolean, name: string, slug: string, currencyCode: string, warehouses: Array<{ __typename: 'Warehouse', id: string, name: string }>, defaultCountry: { __typename: 'CountryDisplay', code: string, country: string }, stockSettings: { __typename: 'StockSettings', allocationStrategy: AllocationStrategyEnum } }; export type CollectionFragment = { __typename: 'Collection', id: string, name: string, channelListings: Array<{ __typename: 'CollectionChannelListing', isPublished: boolean, publicationDate: any | null, channel: { __typename: 'Channel', id: string, name: string } }> | null }; @@ -6371,7 +6435,7 @@ export type CustomerFragment = { __typename: 'User', id: string, email: string, export type CustomerDetailsFragment = { __typename: 'User', dateJoined: any, lastLogin: any | null, note: string | null, isActive: boolean, id: string, email: string, firstName: string, lastName: string, defaultShippingAddress: { __typename: 'Address', city: string, cityArea: string, companyName: string, countryArea: string, firstName: string, id: string, lastName: string, phone: string | null, postalCode: string, streetAddress1: string, streetAddress2: string, country: { __typename: 'CountryDisplay', code: string, country: string } } | null, defaultBillingAddress: { __typename: 'Address', city: string, cityArea: string, companyName: string, countryArea: string, firstName: string, id: string, lastName: string, phone: string | null, postalCode: string, streetAddress1: string, streetAddress2: string, country: { __typename: 'CountryDisplay', code: string, country: string } } | null, metadata: Array<{ __typename: 'MetadataItem', key: string, value: string }>, privateMetadata: Array<{ __typename: 'MetadataItem', key: string, value: string }> }; -export type CustomerAddressesFragment = { __typename: 'User', id: string, email: string, firstName: string, lastName: string, addresses: Array<{ __typename: 'Address', city: string, cityArea: string, companyName: string, countryArea: string, firstName: string, id: string, lastName: string, phone: string | null, postalCode: string, streetAddress1: string, streetAddress2: string, country: { __typename: 'CountryDisplay', code: string, country: string } }> | null, defaultBillingAddress: { __typename: 'Address', id: string } | null, defaultShippingAddress: { __typename: 'Address', id: string } | null }; +export type CustomerAddressesFragment = { __typename: 'User', id: string, email: string, firstName: string, lastName: string, addresses: Array<{ __typename: 'Address', city: string, cityArea: string, companyName: string, countryArea: string, firstName: string, id: string, lastName: string, phone: string | null, postalCode: string, streetAddress1: string, streetAddress2: string, country: { __typename: 'CountryDisplay', code: string, country: string } }>, defaultBillingAddress: { __typename: 'Address', id: string } | null, defaultShippingAddress: { __typename: 'Address', id: string } | null }; export type SaleFragment = { __typename: 'Sale', id: string, name: string, type: SaleType, startDate: any, endDate: any | null, channelListings: Array<{ __typename: 'SaleChannelListing', id: string, discountValue: number, currency: string, channel: { __typename: 'Channel', id: string, name: string, currencyCode: string } }> | null, metadata: Array<{ __typename: 'MetadataItem', key: string, value: string }>, privateMetadata: Array<{ __typename: 'MetadataItem', key: string, value: string }> }; @@ -8616,13 +8680,6 @@ export type WarehouseDetailsQueryVariables = Exact<{ export type WarehouseDetailsQuery = { __typename: 'Query', warehouse: { __typename: 'Warehouse', isPrivate: boolean, clickAndCollectOption: WarehouseClickAndCollectOptionEnum, id: string, name: string, address: { __typename: 'Address', city: string, cityArea: string, companyName: string, countryArea: string, firstName: string, id: string, lastName: string, phone: string | null, postalCode: string, streetAddress1: string, streetAddress2: string, country: { __typename: 'CountryDisplay', code: string, country: string } }, shippingZones: { __typename: 'ShippingZoneCountableConnection', edges: Array<{ __typename: 'ShippingZoneCountableEdge', node: { __typename: 'ShippingZone', id: string, name: string } }> } } | null }; -export type ChannelWarehousesQueryVariables = Exact<{ - filter?: InputMaybe; -}>; - - -export type ChannelWarehousesQuery = { __typename: 'Query', warehouses: { __typename: 'WarehouseCountableConnection', edges: Array<{ __typename: 'WarehouseCountableEdge', node: { __typename: 'Warehouse', id: string, name: string } }> } | null }; - export type WarehousesCountQueryVariables = Exact<{ [key: string]: never; }>; diff --git a/src/storybook/__snapshots__/Stories.test.ts.snap b/src/storybook/__snapshots__/Stories.test.ts.snap index dabaa8626..78fd78144 100644 --- a/src/storybook/__snapshots__/Stories.test.ts.snap +++ b/src/storybook/__snapshots__/Stories.test.ts.snap @@ -24482,6 +24482,119 @@ exports[`Storyshots Shipping zones details / Settings Card default 1`] = ` `; +exports[`Storyshots Shipping zones loading 1`] = ` +
+
+
+
+ + Shipping Zones + +
+
+
+
+ Select shipping zones that will be supplied via this channel. You can assign shipping zones to multiple channels. +
+
+
+
+ +
+
+
+
+
+
+
+ + ‌ + +
+
+
+
+
+
+
+`; + exports[`Storyshots Shipping zones with no options selected 1`] = `
+
@@ -24713,78 +24827,88 @@ exports[`Storyshots Shipping zones with options selected 1`] = `
-
+
- Fancy shipping zone -
- -
-
-
+
+ Fancy shipping zone +
+
+ +
+
- Nice shipping zone -
- +
+ Nice shipping zone +
+
+ +
+
-
@@ -47131,78 +47255,88 @@ exports[`Storyshots Views / Channels / Channel details default 1`] = `
-
+
- Europe -
- -
-
-
+
+ Europe +
+
+ +
+
- USA -
- +
+ USA +
+
+ +
+
-
@@ -47262,7 +47396,7 @@ exports[`Storyshots Views / Channels / Channel details default 1`] = `
- Select warehouses that will be used in this channel. You can assign warehouses to multiple channels. + Assign and sort warehouses that will be used in this channel (warehouses can be assigned in multiple channels).
-
+
- Warehouse 1 -
- -
-
-
+ +
+ Warehouse 1 +
+
+ +
+
- Warehouse 2 -
- + +
+ Warehouse 2 +
+
+ + +
-
@@ -47439,6 +47621,183 @@ exports[`Storyshots Views / Channels / Channel details default 1`] = `
+
+
+
+
+ +
+ Allocation strategy +
+ + Preview + +
+
+
+
+
+
+
+ +
+ + +
+
+
+
@@ -47815,11 +48174,12 @@ exports[`Storyshots Views / Channels / Channel details disabled 1`] = `
-
- 2 shipping zones -
+ ‌ +
-
-
- Europe -
- -
-
-
-
- USA -
- -
-
- + ‌ +
@@ -47998,7 +48264,7 @@ exports[`Storyshots Views / Channels / Channel details disabled 1`] = `
- Select warehouses that will be used in this channel. You can assign warehouses to multiple channels. + Assign and sort warehouses that will be used in this channel (warehouses can be assigned in multiple channels).
-
- 2 warehouses -
+ ‌ +
-
-
- Warehouse 1 -
- -
-
-
-
- Warehouse 2 -
- -
-
-
- - Add Warehouses - - -
+ ‌ +
+
+
+
+
+ +
+ Allocation strategy +
+ + Preview + +
+
+
+
+
+
+
+ +
+ + +
+
+
+
@@ -48599,78 +48953,88 @@ exports[`Storyshots Views / Channels / Channel details loading 1`] = `
-
+
- Europe -
- -
-
-
+
+ Europe +
+
+ +
+
- USA -
- +
+ USA +
+ + + +
-
@@ -48730,7 +49094,7 @@ exports[`Storyshots Views / Channels / Channel details loading 1`] = `
- Select warehouses that will be used in this channel. You can assign warehouses to multiple channels. + Assign and sort warehouses that will be used in this channel (warehouses can be assigned in multiple channels).
-
+
- Warehouse 1 -
- -
-
-
+ +
+ Warehouse 1 +
+
+ +
+
- Warehouse 2 -
- + +
+ Warehouse 2 +
+
+ + +
-
@@ -48907,6 +49319,183 @@ exports[`Storyshots Views / Channels / Channel details loading 1`] = `
+
+
+
+
+ +
+ Allocation strategy +
+ + Preview + +
+
+
+
+
+
+
+ +
+ + +
+
+
+
@@ -49331,78 +49920,88 @@ exports[`Storyshots Views / Channels / Channel details with data 1`] = `
-
+
- Europe -
- -
-
-
+
+ Europe +
+
+ +
+
- USA -
- +
+ USA +
+ + + +
-
@@ -49462,7 +50061,7 @@ exports[`Storyshots Views / Channels / Channel details with data 1`] = `
- Select warehouses that will be used in this channel. You can assign warehouses to multiple channels. + Assign and sort warehouses that will be used in this channel (warehouses can be assigned in multiple channels).
-
+
- Warehouse 1 -
- -
-
-
+ +
+ Warehouse 1 +
+
+ +
+
- Warehouse 2 -
- + +
+ Warehouse 2 +
+
+ + +
-
@@ -49639,6 +50286,183 @@ exports[`Storyshots Views / Channels / Channel details with data 1`] = `
+
+
+
+
+ +
+ Allocation strategy +
+ + Preview + +
+
+
+
+
+
+
+ +
+ + +
+
+
+
@@ -50069,78 +50893,88 @@ exports[`Storyshots Views / Channels / Channel details with errors 1`] = `
-
+
- Europe -
- -
-
-
+
+ Europe +
+
+ +
+
- USA -
- +
+ USA +
+ + + +
-
@@ -50200,7 +51034,7 @@ exports[`Storyshots Views / Channels / Channel details with errors 1`] = `
- Select warehouses that will be used in this channel. You can assign warehouses to multiple channels. + Assign and sort warehouses that will be used in this channel (warehouses can be assigned in multiple channels).
-
+
- Warehouse 1 -
- -
-
-
+ +
+ Warehouse 1 +
+
+ +
+
- Warehouse 2 -
- + +
+ Warehouse 2 +
+
+ + +
-
@@ -50377,6 +51259,183 @@ exports[`Storyshots Views / Channels / Channel details with errors 1`] = `
+
+
+
+
+ +
+ Allocation strategy +
+ + Preview + +
+
+
+
+
+
+
+ +
+ + +
+
+
+
@@ -50739,78 +51798,88 @@ exports[`Storyshots Views / Channels / Channel details without editable currency
-
+
- Europe -
- -
-
-
+
+ Europe +
+
+ +
+
- USA -
- +
+ USA +
+ + + +
-
@@ -50870,7 +51939,7 @@ exports[`Storyshots Views / Channels / Channel details without editable currency
- Select warehouses that will be used in this channel. You can assign warehouses to multiple channels. + Assign and sort warehouses that will be used in this channel (warehouses can be assigned in multiple channels).
-
+
- Warehouse 1 -
- -
-
-
+ +
+ Warehouse 1 +
+
+ +
+
- Warehouse 2 -
- + +
+ Warehouse 2 +
+
+ + +
-
@@ -51047,6 +52164,183 @@ exports[`Storyshots Views / Channels / Channel details without editable currency
+
+
+
+
+ +
+ Allocation strategy +
+ + Preview + +
+
+
+
+
+
+
+ +
+ + +
+
+
+
@@ -252682,6 +253976,119 @@ exports[`Storyshots Views / Warehouses / Warehouse list no limits 1`] = ` `; +exports[`Storyshots Warehouses loading 1`] = ` +
+
+
+
+ + Warehouses + +
+
+
+
+ Assign and sort warehouses that will be used in this channel (warehouses can be assigned in multiple channels). +
+
+
+
+ +
+
+
+
+
+
+
+ + ‌ + +
+
+
+
+
+
+
+`; + exports[`Storyshots Warehouses with no options selected 1`] = `
- Select warehouses that will be used in this channel. You can assign warehouses to multiple channels. + Assign and sort warehouses that will be used in this channel (warehouses can be assigned in multiple channels).
+
@@ -252842,7 +254250,7 @@ exports[`Storyshots Warehouses with options selected 1`] = `
- Select warehouses that will be used in this channel. You can assign warehouses to multiple channels. + Assign and sort warehouses that will be used in this channel (warehouses can be assigned in multiple channels).
-
+
- Fancy warehouse -
- -
-
-
+ +
+ Fancy warehouse +
+
+ +
+
- Nice warehouse -
- + +
+ Nice warehouse +
+
+ +
+
-
diff --git a/src/warehouses/queries.ts b/src/warehouses/queries.ts index 62d6aaaa2..71dbef723 100644 --- a/src/warehouses/queries.ts +++ b/src/warehouses/queries.ts @@ -37,20 +37,6 @@ export const warehouseDetails = gql` } `; -// first: 100 - to be removed when we implement pagintion in ui for this query -export const channelWarehouses = gql` - query ChannelWarehouses($filter: WarehouseFilterInput) { - warehouses(filter: $filter, first: 100) { - edges { - node { - id - name - } - } - } - } -`; - export const warehousesCount = gql` query WarehousesCount { warehouses {