From 467319ebce963450f92761f0a171e27b789038f2 Mon Sep 17 00:00:00 2001 From: Magdalena Markusik Date: Thu, 13 May 2021 11:23:08 +0200 Subject: [PATCH] Add error for co category set for product --- src/products/views/ProductUpdate/ProductUpdate.tsx | 7 ++++++- src/utils/errors/product.ts | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/products/views/ProductUpdate/ProductUpdate.tsx b/src/products/views/ProductUpdate/ProductUpdate.tsx index e3425ea21..6e4201d4f 100644 --- a/src/products/views/ProductUpdate/ProductUpdate.tsx +++ b/src/products/views/ProductUpdate/ProductUpdate.tsx @@ -300,7 +300,12 @@ export const ProductUpdate: React.FC = ({ id, params }) => { const [updateChannels, updateChannelsOpts] = useProductChannelListingUpdate({ onCompleted: data => { if (!!data.productChannelListingUpdate.errors.length) { - return; + data.productChannelListingUpdate.errors.map(error => + notify({ + status: "error", + text: getProductErrorMessage(error, intl) + }) + ); } } }); diff --git a/src/utils/errors/product.ts b/src/utils/errors/product.ts index fef746bdf..38209dfe4 100644 --- a/src/utils/errors/product.ts +++ b/src/utils/errors/product.ts @@ -50,6 +50,10 @@ const messages = defineMessages({ variantUnique: { defaultMessage: "This variant already exists", description: "product attribute error" + }, + noCategorySet: { + defaultMessage: "Product category not set", + description: "no category set error" } }); @@ -79,6 +83,8 @@ function getProductErrorMessage( return intl.formatMessage(messages.variantNoDigitalContent); case ProductErrorCode.UNSUPPORTED_MEDIA_PROVIDER: return intl.formatMessage(messages.unsupportedMediaProvider); + case ProductErrorCode.PRODUCT_WITHOUT_CATEGORY: + return intl.formatMessage(messages.noCategorySet); case ProductErrorCode.INVALID: if (err.field === "price") { return intl.formatMessage(messages.priceInvalid);