saleor-dashboard/src/discounts/components/VoucherListPage/VoucherListPage.stories.tsx

106 lines
2.2 KiB
TypeScript
Raw Normal View History

import { voucherList } from "@dashboard/discounts/fixtures";
import { VoucherListUrlSortField } from "@dashboard/discounts/urls";
2019-09-12 13:31:08 +00:00
import {
filterPageProps,
2019-09-12 13:31:08 +00:00
listActionsProps,
pageListProps,
searchPageProps,
2020-01-03 15:17:51 +00:00
sortPageProps,
tabPageProps,
} from "@dashboard/fixtures";
import { DiscountStatusEnum, VoucherDiscountType } from "@dashboard/graphql";
import { Meta, StoryObj } from "@storybook/react";
2023-01-05 12:34:34 +00:00
import { PaginatorContextDecorator } from "../../../../.storybook/decorators";
2023-01-05 12:34:34 +00:00
import VoucherListPage, { VoucherListPageProps } from "./VoucherListPage";
2019-06-19 14:40:52 +00:00
const props: VoucherListPageProps = {
...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,
2020-01-03 15:17:51 +00:00
...filterPageProps,
filterOpts: {
channel: {
active: false,
value: "default-channel",
choices: [
{
value: "default-channel",
label: "Default channel",
},
],
},
2020-01-03 15:17:51 +00:00
saleType: {
active: false,
value: [VoucherDiscountType.FIXED, VoucherDiscountType.PERCENTAGE],
2020-01-03 15:17:51 +00:00
},
started: {
active: false,
value: {
max: undefined,
min: undefined,
},
2020-01-03 15:17:51 +00:00
},
status: {
active: false,
value: [DiscountStatusEnum.ACTIVE],
2020-01-03 15:17:51 +00:00
},
timesUsed: {
active: false,
value: {
max: undefined,
min: undefined,
},
},
2020-01-03 15:17:51 +00:00
},
selectedChannelId: "123",
2019-12-17 17:13:56 +00:00
sort: {
...sortPageProps.sort,
sort: VoucherListUrlSortField.code,
2019-12-17 17:13:56 +00:00
},
vouchers: voucherList,
2019-06-19 14:40:52 +00:00
};
const meta: Meta<typeof VoucherListPage> = {
title: "Discounts / Voucher list",
decorators: [PaginatorContextDecorator],
component: VoucherListPage,
};
export default meta;
type Story = StoryObj<typeof VoucherListPage>;
export const Default: Story = {
args: {
...props,
},
parameters: {
chromatic: { diffThreshold: 0.85 },
},
};
export const Loading: Story = {
args: {
...props,
vouchers: undefined,
},
parameters: {
chromatic: { diffThreshold: 0.85 },
},
};
export const NoChannels: Story = {
args: {
...props,
selectedChannelId: "",
vouchers: voucherList.map(voucher => ({
...voucher,
channelListings: [],
})),
},
parameters: {
chromatic: { diffThreshold: 0.85 },
},
};