saleor-dashboard/src/storybook/stories/home/HomePage.tsx

68 lines
2.2 KiB
TypeScript
Raw Normal View History

2019-06-19 14:40:52 +00:00
import { Omit } from "@material-ui/core";
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
2019-08-12 11:47:38 +00:00
import placeholderImage from "@assets/images/placeholder60x60.png";
import { adminUserPermissions } from "@saleor/fixtures";
2019-10-25 13:31:27 +00:00
import { PermissionEnum } from "@saleor/types/globalTypes";
2019-06-19 14:40:52 +00:00
import HomePage, { HomePageProps } from "../../../home/components/HomePage";
import { shop as shopFixture } from "../../../home/fixtures";
import Decorator from "../../Decorator";
const shop = shopFixture(placeholderImage);
2019-08-27 09:35:54 +00:00
const homePageProps: Omit<HomePageProps, "classes"> = {
2019-06-19 14:40:52 +00:00
activities: shop.activities.edges.map(edge => edge.node),
onOrdersToCaptureClick: () => undefined,
onOrdersToFulfillClick: () => undefined,
onProductClick: () => undefined,
onProductsOutOfStockClick: () => undefined,
orders: shop.ordersToday.totalCount,
ordersToCapture: shop.ordersToCapture.totalCount,
ordersToFulfill: shop.ordersToFulfill.totalCount,
productsOutOfStock: shop.productsOutOfStock.totalCount,
sales: shop.salesToday.gross,
topProducts: shop.productTopToday.edges.map(edge => edge.node),
2019-10-25 13:31:27 +00:00
userName: "admin@example.com",
userPermissions: adminUserPermissions
2019-06-19 14:40:52 +00:00
};
storiesOf("Views / HomePage", module)
.addDecorator(Decorator)
2019-08-27 09:35:54 +00:00
.add("default", () => <HomePage {...homePageProps} />)
2019-06-19 14:40:52 +00:00
.add("loading", () => (
<HomePage
2019-08-27 09:35:54 +00:00
{...homePageProps}
2019-06-19 14:40:52 +00:00
activities={undefined}
orders={undefined}
ordersToCapture={undefined}
ordersToFulfill={undefined}
productsOutOfStock={undefined}
sales={undefined}
topProducts={undefined}
userName={undefined}
/>
))
.add("no data", () => (
2019-08-27 09:35:54 +00:00
<HomePage {...homePageProps} topProducts={[]} activities={[]} />
2019-10-25 13:31:27 +00:00
))
.add("no permissions", () => (
<HomePage {...homePageProps} userPermissions={[]} />
))
.add("product permissions", () => (
<HomePage
{...homePageProps}
userPermissions={adminUserPermissions.filter(
2019-10-25 13:31:27 +00:00
perm => perm.code === PermissionEnum.MANAGE_PRODUCTS
)}
/>
))
.add("order permissions", () => (
<HomePage
{...homePageProps}
userPermissions={adminUserPermissions.filter(
2019-10-25 13:31:27 +00:00
perm => perm.code === PermissionEnum.MANAGE_ORDERS
)}
/>
2019-06-19 14:40:52 +00:00
));