2019-08-09 10:17:04 +00:00
|
|
|
import AttributePage, {
|
2022-06-21 09:36:55 +00:00
|
|
|
AttributePageProps,
|
2019-08-09 10:17:04 +00:00
|
|
|
} from "@saleor/attributes/components/AttributePage";
|
|
|
|
import { attribute } from "@saleor/attributes/fixtures";
|
2022-03-09 08:56:55 +00:00
|
|
|
import { AttributeErrorCode, AttributeInputTypeEnum } from "@saleor/graphql";
|
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 = {
|
2021-09-21 13:16:21 +00:00
|
|
|
children: () => null,
|
2019-08-09 10:17:04 +00:00
|
|
|
attribute,
|
|
|
|
disabled: false,
|
|
|
|
errors: [],
|
|
|
|
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,
|
2022-06-21 09:36:55 +00:00
|
|
|
hasPreviousPage: false,
|
2021-05-24 11:01:18 +00:00
|
|
|
},
|
|
|
|
onNextPage: () => undefined,
|
2022-06-21 09:36:55 +00:00
|
|
|
onPreviousPage: () => undefined,
|
2019-08-09 10:17:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
storiesOf("Views / Attributes / Attribute details", module)
|
|
|
|
.addDecorator(Decorator)
|
2021-09-21 13:16:21 +00:00
|
|
|
.add("default", () => <AttributePage {...props}>{() => null}</AttributePage>)
|
2019-08-09 10:17:04 +00:00
|
|
|
.add("loading", () => (
|
|
|
|
<AttributePage
|
|
|
|
{...props}
|
|
|
|
attribute={undefined}
|
|
|
|
disabled={true}
|
|
|
|
values={undefined}
|
2021-09-21 13:16:21 +00:00
|
|
|
>
|
|
|
|
{() => null}
|
|
|
|
</AttributePage>
|
|
|
|
))
|
|
|
|
.add("no values", () => (
|
|
|
|
<AttributePage {...props} values={undefined}>
|
|
|
|
{() => null}
|
|
|
|
</AttributePage>
|
2019-08-09 10:17:04 +00:00
|
|
|
))
|
|
|
|
.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,
|
2022-03-04 10:52:58 +00:00
|
|
|
field,
|
2022-06-21 09:36:55 +00:00
|
|
|
message: "Attribute code invalid",
|
2020-03-09 14:59:58 +00:00
|
|
|
}))}
|
2021-09-21 13:16:21 +00:00
|
|
|
>
|
|
|
|
{() => null}
|
|
|
|
</AttributePage>
|
2019-08-09 10:17:04 +00:00
|
|
|
))
|
|
|
|
.add("multiple select input", () => (
|
|
|
|
<AttributePage
|
|
|
|
{...props}
|
|
|
|
attribute={{
|
|
|
|
...attribute,
|
2022-06-21 09:36:55 +00:00
|
|
|
inputType: AttributeInputTypeEnum.MULTISELECT,
|
2019-08-09 10:17:04 +00:00
|
|
|
}}
|
2021-09-21 13:16:21 +00:00
|
|
|
>
|
|
|
|
{() => null}
|
|
|
|
</AttributePage>
|
2019-08-09 10:17:04 +00:00
|
|
|
))
|
2021-09-21 13:16:21 +00:00
|
|
|
.add("create", () => (
|
|
|
|
<AttributePage {...props} attribute={null}>
|
|
|
|
{() => null}
|
|
|
|
</AttributePage>
|
|
|
|
));
|