saleor-dashboard/src/storybook/stories/discounts/VoucherDetailsPage.tsx
Dominik Żegleń a175fb9497
Add global channel picker (#841)
* Move theme switch to user menu

* Add global channel picker

* Fix picker styles

* Use app channel state

* Improve prop naming to indicate id vs slug

* Disable picker if no reason to pick channel

* Remove settings modal leftovers

* Remove channel settings dialog

* Remove unused props

* Skip channel fetching if user is not authenticated

* Remove channel selection from components

* Update messages

* Fix e2e tests

* Remove channel picker leftover

* Revert ChannelSettingsDialog deletion

* Update snapshots

* Update messages
2020-11-23 10:39:24 +01:00

81 lines
2.4 KiB
TypeScript

import { channelsList } from "@saleor/channels/fixtures";
import { createChannelsDataWithDiscountPrice } from "@saleor/channels/utils";
import { DiscountErrorCode } from "@saleor/types/globalTypes";
import { storiesOf } from "@storybook/react";
import React from "react";
import VoucherDetailsPage, {
VoucherDetailsPageFormData,
VoucherDetailsPageProps,
VoucherDetailsPageTab
} from "../../../discounts/components/VoucherDetailsPage";
import { voucherDetails } from "../../../discounts/fixtures";
import { listActionsProps, pageListProps } from "../../../fixtures";
import Decorator from "../../Decorator";
const channels = createChannelsDataWithDiscountPrice(
voucherDetails,
channelsList
);
const props: VoucherDetailsPageProps = {
...listActionsProps,
...pageListProps.default,
activeTab: VoucherDetailsPageTab.products,
allChannelsCount: channels.length,
categoryListToolbar: null,
channelListings: channels,
collectionListToolbar: null,
errors: [],
hasChannelChanged: false,
onBack: () => undefined,
onCategoryAssign: () => undefined,
onCategoryClick: () => undefined,
onCategoryUnassign: () => undefined,
onChannelsChange: () => undefined,
onCollectionAssign: () => undefined,
onCollectionClick: () => undefined,
onCollectionUnassign: () => undefined,
onCountryAssign: () => undefined,
onCountryUnassign: () => undefined,
onProductAssign: () => undefined,
onProductClick: () => undefined,
onProductUnassign: () => undefined,
onRemove: () => undefined,
onSubmit: () => undefined,
onTabClick: () => undefined,
openChannelsModal: () => undefined,
productListToolbar: null,
saveButtonBarState: "default",
selectedChannelId: "123",
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",
"minSpent",
"name",
"startDate",
"type",
"usageLimit",
"discountValue"
] as Array<keyof VoucherDetailsPageFormData>).map(field => ({
__typename: "DiscountError",
channels: [],
code: DiscountErrorCode.INVALID,
field
}))}
/>
));