Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add proper props for storybook

Lukasz Szewczykb213e1622ea4
diff --git a/saleor/static/dashboard-next/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx b/saleor/static/dashboard-next/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx
index 067b98e846..6fdb20625e 100644
--- a/saleor/static/dashboard-next/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx
+++ b/saleor/static/dashboard-next/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx
@@ -18,39 +18,28 @@ import Toggle from "../../../components/Toggle";
import SaveButtonBar, {
SaveButtonBarState
} from "../../../components/SaveButtonBar/SaveButtonBar";
-
import Tabs, { SingleTab } from "../../../components/Tab";
-
import { UserError } from "../../../";
-// import Card from "@material-ui/core/Card";
import Button from "@material-ui/core/Button";
-// import CardContent from "@material-ui/core/CardContent";
-// import AddPhotoIcon from "@material-ui/icons/AddAPhoto";
-// import Typography from "@material-ui/core/Typography";
-// import CardTitle from "../../../components/CardTitle";
-
import i18n from "../../../i18n";
interface FormData {
- //CategoryDetailsForm
description: string;
name: string;
-
- // SeoForm
seoTitle: string;
seoDescription: string;
}
-interface CategoryUpdatePageProps {
+export interface CategoryUpdatePageProps {
errors: UserError[];
disabled: boolean;
productCount?: number;
- category?: {
- SeoDescription?: string;
- SeoTitle?: string;
- name?: string;
- description?: string;
+ category: {
+ SeoDescription: string;
+ SeoTitle: string;
+ name: string;
+ description: string;
};
- products?: Array<{
+ products: Array<{
id: string;
name: string;
productType: {
@@ -62,7 +51,7 @@ interface CategoryUpdatePageProps {
};
price: MoneyType;
}>;
- subcategories?: Array<{
+ subcategories: Array<{
id: string;
name: string;
children: {
@@ -72,7 +61,7 @@ interface CategoryUpdatePageProps {
totalCount: number;
};
}>;
- pageInfo?: {
+ pageInfo: {
hasNextPage: boolean;
hasPreviousPage: boolean;
};
@@ -86,7 +75,6 @@ interface CategoryUpdatePageProps {
onAddProduct?();
onBack?();
onDelete?();
- onSubmit?(data: FormData);
onAddCategory?();
onCategoryClick?(id: string): () => void;
}
diff --git a/saleor/static/dashboard-next/storybook/stories/categories/CategoryUpdatePage.tsx b/saleor/static/dashboard-next/storybook/stories/categories/CategoryUpdatePage.tsx
index 0b5959bbed..31570cb1c3 100644
--- a/saleor/static/dashboard-next/storybook/stories/categories/CategoryUpdatePage.tsx
+++ b/saleor/static/dashboard-next/storybook/stories/categories/CategoryUpdatePage.tsx
@@ -3,57 +3,50 @@ import * as React from "react";
import { category as categoryFixture } from "../../../categories/fixtures";
-import CategoryUpdatePage from "../../../categories/components/CategoryUpdatePage";
+import CategoryUpdatePage, {
+ CategoryUpdatePageProps
+} from "../../../categories/components/CategoryUpdatePage";
import Decorator from "../../Decorator";
const category = categoryFixture("");
+const updateProps: CategoryUpdatePageProps = {
+ category: category,
+ subcategories: category.children,
+ disabled: false,
+ errors: [],
+ products: category.products,
+ loading: false,
+ pageInfo: {
+ hasNextPage: true,
+ hasPreviousPage: true
+ },
+ onNextPage: undefined,
+ onPreviousPage: undefined,
+ onProductClick: () => undefined,
+ onAddProduct: undefined,
+ onCategoryClick: () => undefined,
+ onAddCategory: undefined,
+ onBack: undefined,
+ onDelete: undefined
+};
+
storiesOf("Views / Categories / Update category", module)
.addDecorator(Decorator)
- .add("default", () => (
- <CategoryUpdatePage
- subcategories={category.children}
- disabled={false}
- category={category}
- errors={[]}
- products={category.products}
- loading={false}
- pageInfo={{
- hasNextPage: true,
- hasPreviousPage: true
- }}
- onNextPage={undefined}
- onPreviousPage={undefined}
- onProductClick={() => undefined}
- onAddProduct={undefined}
- onCategoryClick={() => undefined}
- onAddCategory={undefined}
- />
- ))
+ .add("default", () => <CategoryUpdatePage {...updateProps} />)
.add("When in root", () => (
<CategoryUpdatePage
- subcategories={category.children}
- disabled={false}
- errors={[]}
- loading={false}
+ {...updateProps}
+ products={undefined}
category={undefined}
- onNextPage={undefined}
- onPreviousPage={undefined}
- onProductClick={() => undefined}
- onAddProduct={undefined}
- onCategoryClick={() => undefined}
- onAddCategory={undefined}
/>
))
.add("When loading", () => (
<CategoryUpdatePage
+ {...updateProps}
subcategories={undefined}
- disabled={false}
- category={category}
- errors={[]}
+ disabled={true}
products={undefined}
loading={true}
- onProductClick={() => undefined}
- onCategoryClick={() => undefined}
/>
));