saleor-dashboard/src/storybook/stories/collections/CollectionDetailsPage.tsx

81 lines
2.2 KiB
TypeScript
Raw Normal View History

import placeholderCollectionImage from "@assets/images/block1.jpg";
import placeholderProductImage from "@assets/images/placeholder60x60.png";
2019-06-19 14:40:52 +00:00
import { Omit } from "@material-ui/core";
import { ProductErrorCode } 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 CollectionDetailsPage, {
CollectionDetailsPageProps
} from "../../../collections/components/CollectionDetailsPage";
import { collection as collectionFixture } from "../../../collections/fixtures";
import { listActionsProps, pageListProps } from "../../../fixtures";
import Decorator from "../../Decorator";
const collection = collectionFixture(
placeholderCollectionImage,
placeholderProductImage
);
const props: Omit<CollectionDetailsPageProps, "classes"> = {
...listActionsProps,
...pageListProps.default,
collection,
disabled: false,
2020-02-24 14:14:48 +00:00
errors: [],
2019-06-19 14:40:52 +00:00
isFeatured: true,
onBack: () => undefined,
onCollectionRemove: () => undefined,
onImageDelete: () => undefined,
onImageUpload: () => undefined,
onProductUnassign: () => undefined,
onSubmit: () => undefined,
saveButtonBarState: "default"
};
storiesOf("Views / Collections / Collection details", module)
.addDecorator(Decorator)
.add("default", () => <CollectionDetailsPage {...props} />)
.add("loading", () => (
<CollectionDetailsPage {...props} collection={undefined} disabled={true} />
))
2020-02-24 14:14:48 +00:00
.add("form errors", () => (
<CollectionDetailsPage
{...props}
2020-03-05 15:03:10 +00:00
errors={[
{
code: ProductErrorCode.REQUIRED,
field: "name"
},
{
code: ProductErrorCode.REQUIRED,
field: "descriptionJson"
},
{
code: ProductErrorCode.INVALID,
field: "publicationDate"
},
{
code: ProductErrorCode.INVALID,
field: "isPublished"
}
].map(err => ({
__typename: "ProductError",
...err
}))}
2020-02-24 14:14:48 +00:00
/>
))
2019-06-19 14:40:52 +00:00
.add("no products", () => (
<CollectionDetailsPage
{...props}
collection={{
...collection,
products: {
...collection.products,
edges: []
}
}}
disabled={true}
/>
));