Skip to content

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

Improve code separation

dominik-zeglen70df2fd004db
diff --git a/saleor/static/dashboard-next/fixtures.ts b/saleor/static/dashboard-next/fixtures.ts
index 1be8133ff1..4d2b8bf426 100644
--- a/saleor/static/dashboard-next/fixtures.ts
+++ b/saleor/static/dashboard-next/fixtures.ts
@@ -1,4 +1,5 @@
-import { ListActions, PageListProps } from "./types";
+import { Filter } from "./components/TableFilter";
+import { FilterPageProps, ListActions, PageListProps } from "./types";
const pageInfo = {
hasNextPage: true,
@@ -37,3 +38,83 @@ export const countries = [
{ code: "DZ", label: "Algeria" },
{ code: "AS", label: "American Samoa" }
];
+
+export const filterPageProps: FilterPageProps<{}> = {
+ currencySymbol: "USD",
+ currentTab: 0,
+ filterTabs: [],
+ filtersList: [],
+ initialSearch: "",
+ onAll: () => undefined,
+ onFilterAdd: () => undefined,
+ onFilterDelete: () => undefined,
+ onFilterSave: () => undefined,
+ onSearchChange: () => undefined,
+ onTabChange: () => undefined
+};
+
+export const filters: Filter[] = [
+ {
+ label: "Property X is ",
+ onClick: () => undefined
+ },
+ {
+ label: "Property Y is ",
+ onClick: () => undefined
+ },
+ {
+ label: "Property Z is ",
+ onClick: () => undefined
+ },
+ {
+ label: "Property X is ",
+ onClick: () => undefined
+ },
+ {
+ label: "Property Y is ",
+ onClick: () => undefined
+ },
+ {
+ label: "Property Z is ",
+ onClick: () => undefined
+ },
+ {
+ label: "Property X is ",
+ onClick: () => undefined
+ },
+ {
+ label: "Property Y is ",
+ onClick: () => undefined
+ },
+ {
+ label: "Property Z is ",
+ onClick: () => undefined
+ },
+ {
+ label: "Property X is ",
+ onClick: () => undefined
+ },
+ {
+ label: "Property Y is ",
+ onClick: () => undefined
+ },
+ {
+ label: "Property Z is ",
+ onClick: () => undefined
+ },
+ {
+ label: "Property X is ",
+ onClick: () => undefined
+ },
+ {
+ label: "Property Y is ",
+ onClick: () => undefined
+ },
+ {
+ label: "Property Z is ",
+ onClick: () => undefined
+ }
+].map((filter, filterIndex) => ({
+ ...filter,
+ label: filter.label + filterIndex
+}));
diff --git a/saleor/static/dashboard-next/storybook/stories/products/ProductListCard.tsx b/saleor/static/dashboard-next/storybook/stories/products/ProductListCard.tsx
index c80feedc7a..de08a8bf7b 100644
--- a/saleor/static/dashboard-next/storybook/stories/products/ProductListCard.tsx
+++ b/saleor/static/dashboard-next/storybook/stories/products/ProductListCard.tsx
@@ -4,7 +4,12 @@ import * as React from "react";
import { Filter } from "@saleor/components/TableFilter";
import * as placeholderImage from "../../../../images/placeholder255x255.png";
import { category as categoryFixture } from "../../../categories/fixtures";
-import { listActionsProps, pageListProps } from "../../../fixtures";
+import {
+ filterPageProps,
+ filters,
+ listActionsProps,
+ pageListProps
+} from "../../../fixtures";
import ProductListCard, {
ProductListCardProps
} from "../../../products/components/ProductListCard";
@@ -14,86 +19,10 @@ const products = categoryFixture(placeholderImage).products.edges.map(
edge => edge.node
);
-const filtersList: Filter[] = [
- {
- label: "Property X is ",
- onClick: () => undefined
- },
- {
- label: "Property Y is ",
- onClick: () => undefined
- },
- {
- label: "Property Z is ",
- onClick: () => undefined
- },
- {
- label: "Property X is ",
- onClick: () => undefined
- },
- {
- label: "Property Y is ",
- onClick: () => undefined
- },
- {
- label: "Property Z is ",
- onClick: () => undefined
- },
- {
- label: "Property X is ",
- onClick: () => undefined
- },
- {
- label: "Property Y is ",
- onClick: () => undefined
- },
- {
- label: "Property Z is ",
- onClick: () => undefined
- },
- {
- label: "Property X is ",
- onClick: () => undefined
- },
- {
- label: "Property Y is ",
- onClick: () => undefined
- },
- {
- label: "Property Z is ",
- onClick: () => undefined
- },
- {
- label: "Property X is ",
- onClick: () => undefined
- },
- {
- label: "Property Y is ",
- onClick: () => undefined
- },
- {
- label: "Property Z is ",
- onClick: () => undefined
- }
-].map((filter, filterIndex) => ({
- ...filter,
- label: filter.label + filterIndex
-}));
-
const props: ProductListCardProps = {
...listActionsProps,
...pageListProps.default,
- currencySymbol: "USD",
- currentTab: 0,
- filterTabs: [],
- filtersList: [],
- initialSearch: "",
- onAll: () => undefined,
- onFilterAdd: () => undefined,
- onFilterDelete: () => undefined,
- onFilterSave: () => undefined,
- onSearchChange: () => undefined,
- onTabChange: () => undefined,
+ ...filterPageProps,
products
};
@@ -101,7 +30,7 @@ storiesOf("Views / Products / Product list", module)
.addDecorator(Decorator)
.add("default", () => <ProductListCard {...props} />)
.add("with custom filters", () => (
- <ProductListCard {...props} filtersList={filtersList} />
+ <ProductListCard {...props} filtersList={filters} />
))
.add("loading", () => (
<ProductListCard