saleor-dashboard/src/storybook/stories/customers/CustomerCreatePage.tsx
2020-03-24 13:54:08 +01:00

51 lines
1.4 KiB
TypeScript

import { Omit } from "@material-ui/core";
import { storiesOf } from "@storybook/react";
import React from "react";
import { AccountErrorCode } from "@saleor/types/globalTypes";
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"
] as Array<keyof CustomerCreatePageFormData>).map(field => ({
__typename: "AccountError",
code: AccountErrorCode.INVALID,
field
}))}
/>
));