This commit is contained in:
dominik-zeglen 2020-03-09 12:22:34 +01:00
parent ff74c566ab
commit 6bacb5fb3a
6 changed files with 25 additions and 5 deletions

View file

@ -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";

View file

@ -1,3 +1,5 @@
import { ProductErrorFragment } from "@saleor/attributes/types/ProductErrorFragment";
export function formError<TErrorPayload>(
field: string,
opts?: Partial<Omit<TErrorPayload, "field" | "message">>

View file

@ -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<keyof ProductUpdatePageFormData>).map(formError)}
] as Array<keyof ProductUpdatePageFormData>).map(field => ({
__typename: "ProductError",
code: ProductErrorCode.INVALID,
field
}))}
/>
));

View file

@ -42,7 +42,6 @@ storiesOf("Views / Products / Create product variant", module)
}
].map(error => ({
__typename: "ProductError",
message: "Generic form error",
...error
}))}
header="Add variant"

View file

@ -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;

View file

@ -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);
}