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

127 lines
2.5 KiB
TypeScript
Raw Normal View History

// @ts-strict-ignore
import { AccountErrorCode } from "@dashboard/graphql";
2019-08-09 10:26:22 +00:00
import React from "react";
2019-06-19 14:40:52 +00:00
import { MockedUserProvider } from "../../../../.storybook/helpers";
2023-01-05 12:34:34 +00:00
import { customer } from "../../fixtures";
import CustomerDetailsPageComponent, {
CustomerDetailsPageProps,
2023-01-05 12:34:34 +00:00
} from "./CustomerDetailsPage";
2019-06-19 14:40:52 +00:00
const props: Omit<CustomerDetailsPageProps, "classes"> = {
customerId: "123",
2019-06-19 14:40:52 +00:00
customer,
disabled: false,
errors: [],
onDelete: () => undefined,
onSubmit: () => undefined,
saveButtonBar: "default",
2019-06-19 14:40:52 +00:00
};
interface CustomerDetailsPageErrors {
firstName: string;
email: string;
lastName: string;
note: string;
}
const CustomerDetailsPage = props => (
<MockedUserProvider>
<CustomerDetailsPageComponent {...props} />
</MockedUserProvider>
);
export default {
title: "Customers / Customer details",
};
export const Default = () => <CustomerDetailsPage {...props} />;
export const Loading = () => (
<CustomerDetailsPage {...props} customer={undefined} disabled={true} />
);
export const FormErrors = () => (
<CustomerDetailsPage
{...props}
errors={(
["email", "firstName", "lastName"] as Array<
2019-06-19 14:40:52 +00:00
keyof CustomerDetailsPageErrors
>
).map(field => ({
__typename: "AccountError",
code: AccountErrorCode.INVALID,
field,
addressType: null,
message: "Account invalid",
}))}
/>
);
export const DifferentAddresses = () => (
<CustomerDetailsPage
{...props}
customer={{
...customer,
defaultBillingAddress: {
...customer.defaultBillingAddress,
id: "AvSduf72=",
},
}}
/>
);
export const NeverLogged = () => (
<CustomerDetailsPage
{...props}
customer={{
...customer,
lastLogin: null,
}}
/>
);
export const NeverPlacedOrder = () => (
<CustomerDetailsPage
{...props}
customer={{
...customer,
lastPlacedOrder: {
...customer.lastPlacedOrder,
edges: [],
},
}}
/>
);
export const NoDefaultBillingAddress = () => (
<CustomerDetailsPage
{...props}
customer={{
...customer,
defaultBillingAddress: null,
}}
/>
);
export const NoDefaultShippingAddress = () => (
<CustomerDetailsPage
{...props}
customer={{
...customer,
defaultShippingAddress: null,
}}
/>
);
export const NoAddressAtAll = () => (
<CustomerDetailsPage
{...props}
customer={{
...customer,
defaultBillingAddress: null,
defaultShippingAddress: null,
}}
/>
);