2020-12-02 11:35:02 +00:00
|
|
|
import Decorator from "@saleor/storybook//Decorator";
|
2021-02-23 08:58:25 +00:00
|
|
|
import {
|
|
|
|
PostalCodeRuleInclusionTypeEnum,
|
|
|
|
ShippingMethodTypeEnum
|
|
|
|
} from "@saleor/types/globalTypes";
|
2020-12-02 11:35:02 +00:00
|
|
|
import { storiesOf } from "@storybook/react";
|
|
|
|
import React from "react";
|
|
|
|
|
|
|
|
import ShippingZoneRatesCreatePage, {
|
|
|
|
ShippingZoneRatesCreatePageProps
|
|
|
|
} from "./ShippingZoneRatesCreatePage";
|
|
|
|
|
|
|
|
const channels = [
|
|
|
|
{
|
|
|
|
currency: "USD",
|
|
|
|
id: "1",
|
|
|
|
maxValue: "10",
|
|
|
|
minValue: "0",
|
|
|
|
name: "channel",
|
|
|
|
price: "5"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
currency: "USD",
|
|
|
|
id: "2",
|
|
|
|
maxValue: "20",
|
|
|
|
minValue: "1",
|
|
|
|
name: "test",
|
|
|
|
price: "6"
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
const defaultChannels = [
|
|
|
|
{
|
|
|
|
currency: "USD",
|
|
|
|
id: "1",
|
|
|
|
maxValue: "",
|
|
|
|
minValue: "",
|
|
|
|
name: "channel",
|
|
|
|
price: ""
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
const props: ShippingZoneRatesCreatePageProps = {
|
|
|
|
allChannelsCount: 3,
|
|
|
|
channelErrors: [],
|
|
|
|
disabled: false,
|
|
|
|
errors: [],
|
|
|
|
onBack: () => undefined,
|
|
|
|
onChannelsChange: () => undefined,
|
|
|
|
onDelete: () => undefined,
|
2021-02-23 08:58:25 +00:00
|
|
|
onPostalCodeAssign: () => undefined,
|
|
|
|
onPostalCodeInclusionChange: () => undefined,
|
|
|
|
onPostalCodeUnassign: () => undefined,
|
2020-12-02 11:35:02 +00:00
|
|
|
onSubmit: () => undefined,
|
|
|
|
openChannelsModal: () => undefined,
|
2021-02-23 08:58:25 +00:00
|
|
|
postalCodes: [
|
2020-12-02 11:35:02 +00:00
|
|
|
{
|
2021-02-23 08:58:25 +00:00
|
|
|
__typename: "ShippingMethodPostalCodeRule",
|
2020-12-02 11:35:02 +00:00
|
|
|
end: "51-200",
|
|
|
|
id: "1",
|
2021-02-23 08:58:25 +00:00
|
|
|
inclusionType: PostalCodeRuleInclusionTypeEnum.EXCLUDE,
|
2020-12-02 11:35:02 +00:00
|
|
|
start: "51-220"
|
|
|
|
},
|
|
|
|
{
|
2021-02-23 08:58:25 +00:00
|
|
|
__typename: "ShippingMethodPostalCodeRule",
|
2020-12-02 11:35:02 +00:00
|
|
|
end: "31-101",
|
|
|
|
id: "1",
|
2021-02-23 08:58:25 +00:00
|
|
|
inclusionType: PostalCodeRuleInclusionTypeEnum.EXCLUDE,
|
2020-12-02 11:35:02 +00:00
|
|
|
start: "44-205"
|
|
|
|
}
|
2021-02-23 08:58:25 +00:00
|
|
|
],
|
|
|
|
saveButtonBarState: "default",
|
|
|
|
shippingChannels: defaultChannels,
|
|
|
|
variant: ShippingMethodTypeEnum.PRICE
|
2020-12-02 11:35:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
storiesOf("Shipping / ShippingZoneRatesCreatePage page", module)
|
|
|
|
.addDecorator(Decorator)
|
|
|
|
.add("create price", () => <ShippingZoneRatesCreatePage {...props} />)
|
|
|
|
.add("loading", () => (
|
|
|
|
<ShippingZoneRatesCreatePage
|
|
|
|
{...props}
|
|
|
|
disabled={true}
|
|
|
|
saveButtonBarState={"loading"}
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
.add("create weight", () => (
|
|
|
|
<ShippingZoneRatesCreatePage
|
|
|
|
{...props}
|
|
|
|
shippingChannels={channels}
|
|
|
|
variant={ShippingMethodTypeEnum.WEIGHT}
|
|
|
|
/>
|
|
|
|
));
|