Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Display attribute error in snackbar
dominik-zeglen5e9f2b1da4d0
diff --git a/saleor/static/dashboard-next/products/views/ProductCreate.tsx b/saleor/static/dashboard-next/products/views/ProductCreate.tsxindex 837811c8b1..47b70babe9 100644--- a/saleor/static/dashboard-next/products/views/ProductCreate.tsx+++ b/saleor/static/dashboard-next/products/views/ProductCreate.tsx@@ -44,6 +44,13 @@ export const ProductUpdate: React.StatelessComponent<text: i18n.t("Product created")});navigate(productUrl(data.productCreate.product.id));+ } else {+ const attributeError = data.productCreate.errors.find(+ err => err.field === "attributes"+ );+ if (!!attributeError) {+ notify({ text: attributeError.message });+ }}};diff --git a/saleor/static/dashboard-next/products/views/ProductUpdate.tsx b/saleor/static/dashboard-next/products/views/ProductUpdate.tsxindex 3874002b43..0ebf767d9c 100644--- a/saleor/static/dashboard-next/products/views/ProductUpdate.tsx+++ b/saleor/static/dashboard-next/products/views/ProductUpdate.tsx@@ -25,6 +25,7 @@ import {ProductImageCreate,ProductImageCreateVariables} from "../types/ProductImageCreate";+import { ProductUpdate } from "../types/ProductUpdate";import { ProductVariantBulkDelete } from "../types/ProductVariantBulkDelete";import {productImageUrl,@@ -65,8 +66,19 @@ export const ProductUpdate: React.StatelessComponent<ProductUpdateProps> = ({notify({ text: i18n.t("Product removed") });navigate(productListUrl());};- const handleUpdate = () =>- notify({ text: i18n.t("Saved changes") });+ const handleUpdate = (data: ProductUpdate) => {+ if (data.productUpdate.errors.length === 0) {+ notify({ text: i18n.t("Saved changes") });+ } else {+ const attributeError = data.productUpdate.errors.find(+ err => err.field === "attributes"+ );+ if (!!attributeError) {+ notify({ text: attributeError.message });+ }+ }+ };+const handleImageCreate = (data: ProductImageCreate) => {const imageError = data.productImageCreate.errors.find(error =>