saleor-dashboard/src/storybook/stories/customers/CustomerDetailsPage.tsx

111 lines
2.6 KiB
TypeScript
Raw Normal View History

2019-06-19 14:40:52 +00:00
import { Omit } from "@material-ui/core";
import { AccountErrorCode } from "@saleor/types/globalTypes";
2019-06-19 14:40:52 +00:00
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
import CustomerDetailsPage, {
CustomerDetailsPageProps
} from "../../../customers/components/CustomerDetailsPage";
import { customer } from "../../../customers/fixtures";
import Decorator from "../../Decorator";
const props: Omit<CustomerDetailsPageProps, "classes"> = {
customer,
disabled: false,
errors: [],
onAddressManageClick: () => undefined,
onBack: () => undefined,
onDelete: () => undefined,
onRowClick: () => undefined,
onSubmit: () => undefined,
onViewAllOrdersClick: () => undefined,
saveButtonBar: "default"
};
interface CustomerDetailsPageErrors {
firstName: string;
email: string;
lastName: string;
note: string;
}
storiesOf("Views / Customers / Customer details", module)
.addDecorator(Decorator)
.add("default", () => <CustomerDetailsPage {...props} />)
.add("loading", () => (
<CustomerDetailsPage {...props} customer={undefined} disabled={true} />
))
.add("form errors", () => (
<CustomerDetailsPage
{...props}
errors={(["email", "firstName", "lastName"] as Array<
keyof CustomerDetailsPageErrors
2020-03-11 09:55:14 +00:00
>).map(field => ({
__typename: "AccountError",
code: AccountErrorCode.INVALID,
field
}))}
2019-06-19 14:40:52 +00:00
/>
))
.add("different addresses", () => (
<CustomerDetailsPage
{...props}
customer={{
...customer,
defaultBillingAddress: {
...customer.defaultBillingAddress,
id: "AvSduf72="
}
}}
/>
))
.add("never logged", () => (
<CustomerDetailsPage
{...props}
customer={{
...customer,
lastLogin: null
}}
/>
))
.add("never placed order", () => (
<CustomerDetailsPage
{...props}
customer={{
...customer,
lastPlacedOrder: {
...customer.lastPlacedOrder,
edges: []
}
}}
/>
))
.add("no default billing address", () => (
<CustomerDetailsPage
{...props}
customer={{
...customer,
defaultBillingAddress: null
}}
/>
))
.add("no default shipping address", () => (
<CustomerDetailsPage
{...props}
customer={{
...customer,
defaultShippingAddress: null
}}
/>
))
.add("no address at all", () => (
<CustomerDetailsPage
{...props}
customer={{
...customer,
defaultBillingAddress: null,
defaultShippingAddress: null
}}
/>
));