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

95 lines
1.9 KiB
TypeScript
Raw Normal View History

// @ts-strict-ignore
2019-09-12 13:31:08 +00:00
import {
filterPageProps,
2019-09-12 13:31:08 +00:00
listActionsProps,
pageListProps,
searchPageProps,
2020-01-02 12:22:12 +00:00
sortPageProps,
tabPageProps,
} from "@dashboard/fixtures";
import { Meta, StoryObj } from "@storybook/react";
2023-01-05 12:34:34 +00:00
import React from "react";
import { PaginatorContextDecorator } from "../../../../.storybook/decorators";
import { MockedUserProvider } from "../../../../.storybook/helpers";
2023-01-05 12:34:34 +00:00
import { customerList } from "../../fixtures";
import { CustomerListUrlSortField } from "../../urls";
import CustomerListPageComponent, {
CustomerListPageProps,
} from "./CustomerListPage";
2019-06-19 14:40:52 +00:00
const props: CustomerListPageProps = {
2020-01-02 12:22:12 +00:00
...filterPageProps,
2019-06-19 14:40:52 +00:00
...listActionsProps,
...pageListProps.default,
2019-09-12 13:31:08 +00:00
...searchPageProps,
2019-12-17 17:13:56 +00:00
...sortPageProps,
2019-09-12 13:31:08 +00:00
...tabPageProps,
2019-12-17 17:13:56 +00:00
customers: customerList,
selectedCustomerIds: ["123"],
2020-01-02 12:22:12 +00:00
filterOpts: {
joined: {
active: false,
value: {
max: undefined,
min: undefined,
},
2020-01-02 12:22:12 +00:00
},
numberOfOrders: {
active: false,
value: {
max: undefined,
min: undefined,
},
},
2020-01-02 12:22:12 +00:00
},
2019-12-17 17:13:56 +00:00
sort: {
...sortPageProps.sort,
sort: CustomerListUrlSortField.name,
},
2019-06-19 14:40:52 +00:00
};
const CustomerListPage = props => (
<MockedUserProvider>
<CustomerListPageComponent {...props} />
</MockedUserProvider>
);
const meta: Meta<typeof CustomerListPage> = {
title: "Customers / Customer list",
decorators: [PaginatorContextDecorator],
component: CustomerListPage,
};
export default meta;
type Story = StoryObj<typeof CustomerListPage>;
export const Default: Story = {
args: {
...props,
},
parameters: {
chromatic: { diffThreshold: 0.85 },
},
};
export const Loading: Story = {
args: {
...props,
customers: undefined,
disabled: true,
},
parameters: {
chromatic: { diffThreshold: 0.85 },
},
};
export const NoData: Story = {
args: {
...props,
customers: [],
},
parameters: {
chromatic: { diffThreshold: 0.85 },
},
};