Handle insufficient stock error
This commit is contained in:
parent
8a7126f7a7
commit
d44f293e2d
3 changed files with 18 additions and 0 deletions
|
@ -6645,6 +6645,10 @@
|
|||
"src_dot_utils_dot_errors_dot_graphqlError": {
|
||||
"string": "API error"
|
||||
},
|
||||
"src_dot_utils_dot_errors_dot_insufficientStock": {
|
||||
"context": "error message",
|
||||
"string": "Cannot change the quantity because of insufficient stock"
|
||||
},
|
||||
"src_dot_utils_dot_errors_dot_invalid": {
|
||||
"string": "Invalid value"
|
||||
},
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import messages from "@saleor/containers/BackgroundTasks/messages";
|
||||
import useNavigator from "@saleor/hooks/useNavigator";
|
||||
import useNotifier from "@saleor/hooks/useNotifier";
|
||||
import getOrderErrorMessage from "@saleor/utils/errors/order";
|
||||
import createDialogActionHandlers from "@saleor/utils/handlers/dialogActionHandlers";
|
||||
import React from "react";
|
||||
import { useIntl } from "react-intl";
|
||||
|
@ -205,6 +206,13 @@ export const OrderDetailsMessages: React.FC<OrderDetailsMessages> = ({
|
|||
defaultMessage: "Order line updated"
|
||||
})
|
||||
});
|
||||
} else {
|
||||
errs.forEach(error =>
|
||||
pushMessage({
|
||||
status: "error",
|
||||
text: getOrderErrorMessage(error, intl)
|
||||
})
|
||||
);
|
||||
}
|
||||
};
|
||||
const handleOrderFulfillmentCancel = (data: OrderFulfillmentCancel) => {
|
||||
|
|
|
@ -34,6 +34,10 @@ const messages = defineMessages({
|
|||
defaultMessage: "Only pre-authorized payments can be captured",
|
||||
description: "error message"
|
||||
},
|
||||
insufficientStock: {
|
||||
defaultMessage: "Cannot change the quantity because of insufficient stock",
|
||||
description: "error message"
|
||||
},
|
||||
noShippingAddress: {
|
||||
defaultMessage:
|
||||
"Cannot choose a shipping method for an order without the shipping address",
|
||||
|
@ -79,6 +83,8 @@ function getOrderErrorMessage(
|
|||
return intl.formatMessage(commonErrorMessages.graphqlError);
|
||||
case OrderErrorCode.INVALID:
|
||||
return intl.formatMessage(commonErrorMessages.invalid);
|
||||
case OrderErrorCode.INSUFFICIENT_STOCK:
|
||||
return intl.formatMessage(messages.insufficientStock);
|
||||
case OrderErrorCode.NOT_EDITABLE:
|
||||
return intl.formatMessage(messages.notEditable);
|
||||
case OrderErrorCode.ORDER_NO_SHIPPING_ADDRESS:
|
||||
|
|
Loading…
Reference in a new issue