2019-08-09 10:17:04 +00:00
|
|
|
import AttributePage, {
|
|
|
|
AttributePageProps
|
|
|
|
} from "@saleor/attributes/components/AttributePage";
|
|
|
|
import { attribute } from "@saleor/attributes/fixtures";
|
2020-03-09 14:59:58 +00:00
|
|
|
import {
|
2020-11-19 14:42:14 +00:00
|
|
|
AttributeErrorCode,
|
|
|
|
AttributeInputTypeEnum
|
2020-03-09 14:59:58 +00:00
|
|
|
} from "@saleor/types/globalTypes";
|
2020-05-14 09:30:32 +00:00
|
|
|
import { storiesOf } from "@storybook/react";
|
|
|
|
import React from "react";
|
|
|
|
|
2019-08-09 10:17:04 +00:00
|
|
|
import Decorator from "../../Decorator";
|
|
|
|
|
|
|
|
const props: AttributePageProps = {
|
|
|
|
attribute,
|
|
|
|
disabled: false,
|
|
|
|
errors: [],
|
|
|
|
onBack: () => undefined,
|
|
|
|
onDelete: () => undefined,
|
|
|
|
onSubmit: () => undefined,
|
|
|
|
onValueAdd: () => undefined,
|
|
|
|
onValueDelete: () => undefined,
|
|
|
|
onValueReorder: () => undefined,
|
|
|
|
onValueUpdate: () => undefined,
|
|
|
|
saveButtonBarState: "default",
|
2021-06-02 19:11:30 +00:00
|
|
|
values: attribute.choices,
|
2021-05-24 11:01:18 +00:00
|
|
|
pageInfo: {
|
|
|
|
hasNextPage: false,
|
|
|
|
hasPreviousPage: false
|
|
|
|
},
|
|
|
|
onNextPage: () => undefined,
|
|
|
|
onPreviousPage: () => undefined
|
2019-08-09 10:17:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
storiesOf("Views / Attributes / Attribute details", module)
|
|
|
|
.addDecorator(Decorator)
|
|
|
|
.add("default", () => <AttributePage {...props} />)
|
|
|
|
.add("loading", () => (
|
|
|
|
<AttributePage
|
|
|
|
{...props}
|
|
|
|
attribute={undefined}
|
|
|
|
disabled={true}
|
|
|
|
values={undefined}
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
.add("no values", () => <AttributePage {...props} values={undefined} />)
|
|
|
|
.add("form errors", () => (
|
|
|
|
<AttributePage
|
|
|
|
{...props}
|
2020-03-09 14:59:58 +00:00
|
|
|
errors={["name", "slug", "storefrontSearchPosition"].map(field => ({
|
2020-11-19 14:42:14 +00:00
|
|
|
__typename: "AttributeError",
|
|
|
|
code: AttributeErrorCode.INVALID,
|
2020-03-09 14:59:58 +00:00
|
|
|
field
|
|
|
|
}))}
|
2019-08-09 10:17:04 +00:00
|
|
|
/>
|
|
|
|
))
|
|
|
|
.add("multiple select input", () => (
|
|
|
|
<AttributePage
|
|
|
|
{...props}
|
|
|
|
attribute={{
|
|
|
|
...attribute,
|
|
|
|
inputType: AttributeInputTypeEnum.MULTISELECT
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
.add("create", () => <AttributePage {...props} attribute={null} />);
|