diff --git a/src/products/views/ProductUpdate/ProductUpdate.tsx b/src/products/views/ProductUpdate/ProductUpdate.tsx index b478e2caa..4de424226 100644 --- a/src/products/views/ProductUpdate/ProductUpdate.tsx +++ b/src/products/views/ProductUpdate/ProductUpdate.tsx @@ -19,7 +19,6 @@ import useCategorySearch from "@saleor/searches/useCategorySearch"; import useCollectionSearch from "@saleor/searches/useCollectionSearch"; import createDialogActionHandlers from "@saleor/utils/handlers/dialogActionHandlers"; import NotFoundPage from "@saleor/components/NotFoundPage"; -import { ProductErrorCode } from "@saleor/types/globalTypes"; import { getMutationState, maybe } from "../../../misc"; import ProductUpdatePage from "../../components/ProductUpdatePage"; import ProductUpdateOperations from "../../containers/ProductUpdateOperations"; diff --git a/src/storybook/misc.ts b/src/storybook/misc.ts index 6a28d4117..b1f96fe36 100644 --- a/src/storybook/misc.ts +++ b/src/storybook/misc.ts @@ -1,3 +1,5 @@ +import { ProductErrorFragment } from "@saleor/attributes/types/ProductErrorFragment"; + export function formError( field: string, opts?: Partial> diff --git a/src/storybook/stories/products/ProductUpdatePage.tsx b/src/storybook/stories/products/ProductUpdatePage.tsx index a3c0b2d74..4deb5d08e 100644 --- a/src/storybook/stories/products/ProductUpdatePage.tsx +++ b/src/storybook/stories/products/ProductUpdatePage.tsx @@ -9,7 +9,7 @@ import ProductUpdatePage, { } from "@saleor/products/components/ProductUpdatePage"; import { product as productFixture } from "@saleor/products/fixtures"; import { ProductUpdatePageFormData } from "@saleor/products/utils/data"; -import { formError } from "@saleor/storybook/misc"; +import { ProductErrorCode } from "@saleor/types/globalTypes"; import Decorator from "../../Decorator"; const product = productFixture(placeholderImage); @@ -94,7 +94,6 @@ storiesOf("Views / Products / Product edit", module) "category", "chargeTaxes", "collections", - "description", "isPublished", "name", "publicationDate", @@ -102,6 +101,10 @@ storiesOf("Views / Products / Product edit", module) "seoTitle", "sku", "stockQuantity" - ] as Array).map(formError)} + ] as Array).map(field => ({ + __typename: "ProductError", + code: ProductErrorCode.INVALID, + field + }))} /> )); diff --git a/src/storybook/stories/products/ProductVariantCreatePage.tsx b/src/storybook/stories/products/ProductVariantCreatePage.tsx index 6d42174b3..9269ae5e2 100644 --- a/src/storybook/stories/products/ProductVariantCreatePage.tsx +++ b/src/storybook/stories/products/ProductVariantCreatePage.tsx @@ -42,7 +42,6 @@ storiesOf("Views / Products / Create product variant", module) } ].map(error => ({ __typename: "ProductError", - message: "Generic form error", ...error }))} header="Add variant" diff --git a/src/utils/errors/common.ts b/src/utils/errors/common.ts new file mode 100644 index 000000000..332510ff5 --- /dev/null +++ b/src/utils/errors/common.ts @@ -0,0 +1,15 @@ +import { defineMessages } from "react-intl"; + +const commonErrorMessages = defineMessages({ + graphqlError: { + defaultMessage: "API error" + }, + invalid: { + defaultMessage: "Invalid value" + }, + unknownError: { + defaultMessage: "Unknown error" + } +}); + +export default commonErrorMessages; diff --git a/src/utils/errors/product.ts b/src/utils/errors/product.ts index 3e5e1d9e3..0886770ec 100644 --- a/src/utils/errors/product.ts +++ b/src/utils/errors/product.ts @@ -44,6 +44,8 @@ function getProductErrorMessage( return intl.formatMessage(commonMessages.requiredField); case ProductErrorCode.VARIANT_NO_DIGITAL_CONTENT: return intl.formatMessage(messages.variantNoDigitalContent); + case ProductErrorCode.INVALID: + return intl.formatMessage(commonErrorMessages.invalid); default: return intl.formatMessage(commonErrorMessages.unknownError); }