diff --git a/CHANGELOG.md b/CHANGELOG.md index a790e41ca..56c31ece8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,7 @@ All notable, unreleased changes to this project will be documented in this file. - Fix minor visual bugs - #521 by @dominik-zeglen - Handle session expiration - #520 by @dominik-zeglen - Update product stock management to newest design - #515 by @dominik-zeglen +- Handle untracked products - #523 by @dominik-zeglen - Display correct error if there were no graphql errors - #525 by @dominik-zeglen ## 2.0.0 diff --git a/locale/defaultMessages.json b/locale/defaultMessages.json index f1d38d88a..efb382289 100644 --- a/locale/defaultMessages.json +++ b/locale/defaultMessages.json @@ -2768,10 +2768,6 @@ "context": "order total price", "string": "Total" }, - "src_dot_orders_dot_components_dot_OrderProductAddDialog_dot_1542417144": { - "context": "dialog header", - "string": "Create Product" - }, "src_dot_orders_dot_components_dot_OrderProductAddDialog_dot_2272209368": { "context": "variant sku", "string": "SKU {sku}" @@ -2779,6 +2775,10 @@ "src_dot_orders_dot_components_dot_OrderProductAddDialog_dot_2336947364": { "string": "Search by product name, attribute, product type etc..." }, + "src_dot_orders_dot_components_dot_OrderProductAddDialog_dot_2775402904": { + "context": "dialog header", + "string": "Add Product" + }, "src_dot_orders_dot_components_dot_OrderProductAddDialog_dot_2850255786": { "string": "Search Products" }, diff --git a/src/orders/components/OrderFulfillPage/OrderFulfillPage.tsx b/src/orders/components/OrderFulfillPage/OrderFulfillPage.tsx index 61844d7d5..9ba8d9c15 100644 --- a/src/orders/components/OrderFulfillPage/OrderFulfillPage.tsx +++ b/src/orders/components/OrderFulfillPage/OrderFulfillPage.tsx @@ -35,80 +35,86 @@ import { renderCollection } from "@saleor/misc"; import Skeleton from "@saleor/components/Skeleton"; import AppHeader from "@saleor/components/AppHeader"; import { FulfillOrder_orderFulfill_errors } from "@saleor/orders/types/FulfillOrder"; +import { CSSProperties } from "@material-ui/styles"; type ClassKey = | "actionBar" | "table" | "colName" | "colQuantity" - | "colQuantityContent" | "colQuantityHeader" | "colQuantityTotal" | "colSku" | "error" | "full" | "quantityInnerInput" - | "quantityInput" + | "quantityInnerInputNoRemaining" | "remainingQuantity"; const useStyles = makeStyles( - theme => ({ - [theme.breakpoints.up("lg")]: { + theme => { + const inputPadding: CSSProperties = { + paddingBottom: theme.spacing(2), + paddingTop: theme.spacing(2) + }; + + return { + [theme.breakpoints.up("lg")]: { + colName: { + width: ({ warehouses }) => (warehouses?.length > 3 ? 250 : "auto") + } + }, + [theme.breakpoints.only("md")]: { + colName: { + width: ({ warehouses }) => (warehouses?.length > 2 ? 250 : "auto") + } + }, + actionBar: { + flexDirection: "row", + paddingLeft: theme.spacing(2) + 2 + }, colName: { - width: ({ warehouses }) => (warehouses?.length > 3 ? 250 : "auto") + width: 250 + }, + colQuantity: { + textAlign: "right", + width: 210 + }, + colQuantityHeader: { + textAlign: "right" + }, + colQuantityTotal: { + textAlign: "right", + width: 180 + }, + colSku: { + textAlign: "right", + textOverflow: "ellipsis", + width: 150 + }, + error: { + color: theme.palette.error.main + }, + full: { + fontWeight: 600 + }, + quantityInnerInput: { + ...inputPadding + }, + quantityInnerInputNoRemaining: { + paddingRight: 0 + }, + remainingQuantity: { + ...inputPadding, + color: theme.palette.text.secondary, + whiteSpace: "nowrap" + }, + table: { + "&&": { + tableLayout: "fixed" + } } - }, - [theme.breakpoints.only("md")]: { - colName: { - width: ({ warehouses }) => (warehouses?.length > 2 ? 250 : "auto") - } - }, - actionBar: { - flexDirection: "row", - paddingLeft: theme.spacing(2) + 2 - }, - colName: { - width: 250 - }, - colQuantity: { - width: 210 - }, - colQuantityContent: { - alignItems: "center", - display: "inline-flex" - }, - colQuantityHeader: { - textAlign: "right" - }, - colQuantityTotal: { - textAlign: "right", - width: 180 - }, - colSku: { - textAlign: "right", - textOverflow: "ellipsis", - width: 150 - }, - error: { - color: theme.palette.error.main - }, - full: { - fontWeight: 600 - }, - quantityInnerInput: { - padding: "16px 0 14px 12px" - }, - quantityInput: { - width: 100 - }, - remainingQuantity: { - marginLeft: theme.spacing() - }, - table: { - "&&": { - tableLayout: "fixed" - } - } - }), + }; + }, { name: "OrderFulfillPage" } ); @@ -343,50 +349,64 @@ const OrderFulfillPage: React.FC = props => { className={classes.colQuantity} key={warehouseStock.id} > -
- - formsetChange( - line.id, - update( - { - quantity: parseInt( - event.target.value, - 10 - ), - warehouse: warehouse.id - }, - formsetData[lineIndex].value, - (a, b) => a.warehouse === b.warehouse - ) + + formsetChange( + line.id, + update( + { + quantity: parseInt( + event.target.value, + 10 + ), + warehouse: warehouse.id + }, + formsetData[lineIndex].value, + (a, b) => a.warehouse === b.warehouse ) - } - error={ - overfulfill || + ) + } + error={ + overfulfill || + (line.variant.trackInventory && formsetStock.quantity > - availableQuantity || - !!errors?.find( - err => - err.warehouse === warehouse.id && - err.orderLine === line.id && - err.code === - OrderErrorCode.INSUFFICIENT_STOCK - ) - } - /> -
- / {availableQuantity} -
-
+ availableQuantity) || + !!errors?.find( + err => + err.warehouse === warehouse.id && + err.orderLine === line.id && + err.code === + OrderErrorCode.INSUFFICIENT_STOCK + ) + } + InputProps={{ + endAdornment: line.variant + .trackInventory && ( +
+ / {availableQuantity} +
+ ) + }} + /> ); })} diff --git a/src/orders/components/OrderFulfillPage/fixtures.ts b/src/orders/components/OrderFulfillPage/fixtures.ts index fdb2857bc..06ec729c9 100644 --- a/src/orders/components/OrderFulfillPage/fixtures.ts +++ b/src/orders/components/OrderFulfillPage/fixtures.ts @@ -61,7 +61,8 @@ export const orderToFulfill: OrderFulfillData_order = { quantity: 1220, quantityAllocated: 7 } - ] + ], + trackInventory: false }, thumbnail: { __typename: "Image", @@ -114,7 +115,8 @@ export const orderToFulfill: OrderFulfillData_order = { quantity: 760, quantityAllocated: 4 } - ] + ], + trackInventory: true }, thumbnail: { __typename: "Image", @@ -160,7 +162,8 @@ export const orderToFulfill: OrderFulfillData_order = { quantity: 587, quantityAllocated: 1 } - ] + ], + trackInventory: true }, thumbnail: { __typename: "Image", diff --git a/src/orders/components/OrderProductAddDialog/OrderProductAddDialog.tsx b/src/orders/components/OrderProductAddDialog/OrderProductAddDialog.tsx index ffde5a9be..004bd4b03 100644 --- a/src/orders/components/OrderProductAddDialog/OrderProductAddDialog.tsx +++ b/src/orders/components/OrderProductAddDialog/OrderProductAddDialog.tsx @@ -208,7 +208,7 @@ const OrderProductAddDialog: React.FC = props => { > diff --git a/src/orders/queries.ts b/src/orders/queries.ts index 2c49a87b3..c633515e5 100644 --- a/src/orders/queries.ts +++ b/src/orders/queries.ts @@ -371,6 +371,7 @@ const orderFulfillData = gql` quantity quantityAllocated } + trackInventory } thumbnail(size: 64) { url diff --git a/src/orders/types/OrderFulfillData.ts b/src/orders/types/OrderFulfillData.ts index 1bc8412b8..047fc94c0 100644 --- a/src/orders/types/OrderFulfillData.ts +++ b/src/orders/types/OrderFulfillData.ts @@ -37,6 +37,7 @@ export interface OrderFulfillData_order_lines_variant { sku: string; attributes: OrderFulfillData_order_lines_variant_attributes[]; stocks: (OrderFulfillData_order_lines_variant_stocks | null)[] | null; + trackInventory: boolean; } export interface OrderFulfillData_order_lines_thumbnail { diff --git a/src/storybook/__snapshots__/Stories.test.ts.snap b/src/storybook/__snapshots__/Stories.test.ts.snap index 383ddcd27..d3613879a 100644 --- a/src/storybook/__snapshots__/Stories.test.ts.snap +++ b/src/storybook/__snapshots__/Stories.test.ts.snap @@ -64450,43 +64450,33 @@ exports[`Storyshots Views / Orders / Fulfill order default 1`] = ` class="MuiTableCell-root-id MuiTableCell-body-id OrderFulfillPage-colQuantity-id" >
-
+
-
-
- / 1207 + + ​ + + +
@@ -64494,43 +64484,33 @@ exports[`Storyshots Views / Orders / Fulfill order default 1`] = ` class="MuiTableCell-root-id MuiTableCell-body-id OrderFulfillPage-colQuantity-id" >
-
+
-
-
- / 1197 + + ​ + + +
@@ -64538,43 +64518,33 @@ exports[`Storyshots Views / Orders / Fulfill order default 1`] = ` class="MuiTableCell-root-id MuiTableCell-body-id OrderFulfillPage-colQuantity-id" >
-
+
-
-
- / 1213 + + ​ + + +
@@ -64582,43 +64552,33 @@ exports[`Storyshots Views / Orders / Fulfill order default 1`] = ` class="MuiTableCell-root-id MuiTableCell-body-id OrderFulfillPage-colQuantity-id" >
-
+
-
-
- / 1213 + + ​ + + +
@@ -64676,43 +64636,39 @@ exports[`Storyshots Views / Orders / Fulfill order default 1`] = ` class="MuiTableCell-root-id MuiTableCell-body-id OrderFulfillPage-colQuantity-id" >
+
- - + / 758
-
-
- / 758 +
@@ -64720,43 +64676,39 @@ exports[`Storyshots Views / Orders / Fulfill order default 1`] = ` class="MuiTableCell-root-id MuiTableCell-body-id OrderFulfillPage-colQuantity-id" >
+
- - + / 727
-
-
- / 727 +
@@ -64764,43 +64716,39 @@ exports[`Storyshots Views / Orders / Fulfill order default 1`] = ` class="MuiTableCell-root-id MuiTableCell-body-id OrderFulfillPage-colQuantity-id" >
+
- - + / 756
-
-
- / 756 +
@@ -64853,43 +64801,39 @@ exports[`Storyshots Views / Orders / Fulfill order default 1`] = ` class="MuiTableCell-root-id MuiTableCell-body-id OrderFulfillPage-colQuantity-id" >
+
- - + / 587
-
-
- / 587 +
@@ -64902,43 +64846,39 @@ exports[`Storyshots Views / Orders / Fulfill order default 1`] = ` class="MuiTableCell-root-id MuiTableCell-body-id OrderFulfillPage-colQuantity-id" >
+
- - + / 586
-
-
- / 586 +
@@ -65134,43 +65074,33 @@ exports[`Storyshots Views / Orders / Fulfill order error 1`] = ` class="MuiTableCell-root-id MuiTableCell-body-id OrderFulfillPage-colQuantity-id" >
-
+
-
-
- / 1207 + + ​ + + +
@@ -65178,43 +65108,33 @@ exports[`Storyshots Views / Orders / Fulfill order error 1`] = ` class="MuiTableCell-root-id MuiTableCell-body-id OrderFulfillPage-colQuantity-id" >
-
+
-
-
- / 1197 + + ​ + + +
@@ -65222,43 +65142,33 @@ exports[`Storyshots Views / Orders / Fulfill order error 1`] = ` class="MuiTableCell-root-id MuiTableCell-body-id OrderFulfillPage-colQuantity-id" >
-
+
-
-
- / 1213 + + ​ + + +
@@ -65266,43 +65176,33 @@ exports[`Storyshots Views / Orders / Fulfill order error 1`] = ` class="MuiTableCell-root-id MuiTableCell-body-id OrderFulfillPage-colQuantity-id" >
-
+
-
-
- / 1213 + + ​ + + +
@@ -65360,43 +65260,39 @@ exports[`Storyshots Views / Orders / Fulfill order error 1`] = ` class="MuiTableCell-root-id MuiTableCell-body-id OrderFulfillPage-colQuantity-id" >
+
- - + / 758
-
-
- / 758 +
@@ -65404,43 +65300,39 @@ exports[`Storyshots Views / Orders / Fulfill order error 1`] = ` class="MuiTableCell-root-id MuiTableCell-body-id OrderFulfillPage-colQuantity-id" >
+
- - + / 727
-
-
- / 727 +
@@ -65448,43 +65340,39 @@ exports[`Storyshots Views / Orders / Fulfill order error 1`] = ` class="MuiTableCell-root-id MuiTableCell-body-id OrderFulfillPage-colQuantity-id" >
+
- - + / 756
-
-
- / 756 +
@@ -65537,43 +65425,39 @@ exports[`Storyshots Views / Orders / Fulfill order error 1`] = ` class="MuiTableCell-root-id MuiTableCell-body-id OrderFulfillPage-colQuantity-id" >
+
- - + / 587
-
-
- / 587 +
@@ -65586,43 +65470,39 @@ exports[`Storyshots Views / Orders / Fulfill order error 1`] = ` class="MuiTableCell-root-id MuiTableCell-body-id OrderFulfillPage-colQuantity-id" >
+
- - + / 586
-
-
- / 586 +
@@ -65969,43 +65849,33 @@ exports[`Storyshots Views / Orders / Fulfill order one warehouse 1`] = ` class="MuiTableCell-root-id MuiTableCell-body-id OrderFulfillPage-colQuantity-id" >
-
+
-
-
- / 1207 + + ​ + + +
@@ -66108,43 +65978,39 @@ exports[`Storyshots Views / Orders / Fulfill order one warehouse 1`] = ` class="MuiTableCell-root-id MuiTableCell-body-id OrderFulfillPage-colQuantity-id" >
+
- - + / 587
-
-
- / 587 +