2019-06-19 14:40:52 +00:00
|
|
|
import { Omit } from "@material-ui/core";
|
|
|
|
import { storiesOf } from "@storybook/react";
|
2019-08-09 10:26:22 +00:00
|
|
|
import React from "react";
|
2019-06-19 14:40:52 +00:00
|
|
|
|
2020-03-11 09:55:14 +00:00
|
|
|
import { AccountErrorCode } from "@saleor/types/globalTypes";
|
2019-06-19 14:40:52 +00:00
|
|
|
import CustomerCreatePage, {
|
|
|
|
CustomerCreatePageFormData,
|
|
|
|
CustomerCreatePageProps
|
|
|
|
} from "../../../customers/components/CustomerCreatePage";
|
|
|
|
import Decorator from "../../Decorator";
|
|
|
|
|
|
|
|
const props: Omit<CustomerCreatePageProps, "classes"> = {
|
|
|
|
countries: [
|
|
|
|
{ __typename: "CountryDisplay", code: "UK", country: "United Kingdom" },
|
|
|
|
{ __typename: "CountryDisplay", code: "PL", country: "Poland" }
|
|
|
|
],
|
|
|
|
disabled: false,
|
|
|
|
errors: [],
|
|
|
|
onBack: () => undefined,
|
|
|
|
onSubmit: () => undefined,
|
|
|
|
saveButtonBar: "default"
|
|
|
|
};
|
|
|
|
|
|
|
|
storiesOf("Views / Customers / Create customer", module)
|
|
|
|
.addDecorator(Decorator)
|
|
|
|
.add("default", () => <CustomerCreatePage {...props} />)
|
|
|
|
.add("loading", () => <CustomerCreatePage {...props} disabled={true} />)
|
|
|
|
.add("form errors", () => (
|
|
|
|
<CustomerCreatePage
|
|
|
|
{...props}
|
|
|
|
errors={([
|
|
|
|
"city",
|
|
|
|
"cityArea",
|
|
|
|
"companyName",
|
|
|
|
"country",
|
|
|
|
"countryArea",
|
|
|
|
"email",
|
|
|
|
"firstName",
|
|
|
|
"lastName",
|
|
|
|
"note",
|
|
|
|
"phone",
|
|
|
|
"postalCode",
|
|
|
|
"streetAddress1",
|
|
|
|
"streetAddress2"
|
2020-03-11 09:55:14 +00:00
|
|
|
] as Array<keyof CustomerCreatePageFormData>).map(field => ({
|
|
|
|
__typename: "AccountError",
|
|
|
|
code: AccountErrorCode.INVALID,
|
|
|
|
field
|
|
|
|
}))}
|
2019-06-19 14:40:52 +00:00
|
|
|
/>
|
|
|
|
));
|