saleor-dashboard/src/storybook/stories/discounts/VoucherDetailsPage.tsx

69 lines
2 KiB
TypeScript
Raw Normal View History

import { DiscountErrorCode } 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 VoucherDetailsPage, {
2020-10-22 11:33:29 +00:00
VoucherDetailsPageFormData,
2019-06-19 14:40:52 +00:00
VoucherDetailsPageProps,
VoucherDetailsPageTab
} from "../../../discounts/components/VoucherDetailsPage";
import { voucherDetails } from "../../../discounts/fixtures";
import { listActionsProps, pageListProps } from "../../../fixtures";
import Decorator from "../../Decorator";
const props: VoucherDetailsPageProps = {
...listActionsProps,
...pageListProps.default,
activeTab: VoucherDetailsPageTab.products,
categoryListToolbar: null,
collectionListToolbar: null,
defaultCurrency: "USD",
errors: [],
onBack: () => undefined,
onCategoryAssign: () => undefined,
onCategoryClick: () => undefined,
onCategoryUnassign: () => undefined,
onCollectionAssign: () => undefined,
onCollectionClick: () => undefined,
onCollectionUnassign: () => undefined,
onCountryAssign: () => undefined,
onCountryUnassign: () => undefined,
onProductAssign: () => undefined,
onProductClick: () => undefined,
onProductUnassign: () => undefined,
onRemove: () => undefined,
onSubmit: () => undefined,
onTabClick: () => undefined,
productListToolbar: null,
saveButtonBarState: "default",
voucher: voucherDetails
};
storiesOf("Views / Discounts / Voucher details", module)
.addDecorator(Decorator)
.add("default", () => <VoucherDetailsPage {...props} />)
.add("loading", () => (
<VoucherDetailsPage {...props} disabled={true} voucher={undefined} />
))
.add("form errors", () => (
<VoucherDetailsPage
{...props}
errors={([
"applyOncePerOrder",
"code",
"discountType",
"endDate",
2020-01-09 11:27:57 +00:00
"minSpent",
2019-06-19 14:40:52 +00:00
"name",
"startDate",
"type",
"usageLimit",
"discountValue"
2020-10-22 11:33:29 +00:00
] as Array<keyof VoucherDetailsPageFormData>).map(field => ({
2020-03-23 19:31:05 +00:00
__typename: "DiscountError",
code: DiscountErrorCode.INVALID,
field
}))}
2019-06-19 14:40:52 +00:00
/>
));