Skip to content

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

Add filter tab callbacks

Lukasz Szewczyk5f4be8ec0e97
diff --git a/saleor/static/dashboard-next/orders/components/OrderListFilter/OrderListFilter.tsx b/saleor/static/dashboard-next/orders/components/OrderListFilter/OrderListFilter.tsx
index 468af8f040..229bb45799 100644
--- a/saleor/static/dashboard-next/orders/components/OrderListFilter/OrderListFilter.tsx
+++ b/saleor/static/dashboard-next/orders/components/OrderListFilter/OrderListFilter.tsx
@@ -11,6 +11,9 @@ import { Filter } from "../../../products/components/ProductListCard";
interface OrderListFilterProps {
currentTab: number;
filtersList: Filter[];
+ onAllProducts: () => void;
+ onToFulfill: () => void;
+ onToCapture: () => void;
}
const decorate = withStyles(theme => ({
@@ -58,23 +61,33 @@ const decorate = withStyles(theme => ({
}));
const OrderListFilter = decorate<OrderListFilterProps>(
- ({ classes, filtersList, currentTab }) => (
+ ({
+ classes,
+ filtersList,
+ currentTab,
+ onAllProducts,
+ onToFulfill,
+ onToCapture
+ }) => (
<>
<Tabs className={classes.tabsRoot} value={0} indicatorColor={"primary"}>
<Tab
disableRipple
classes={{ root: classes.tabRoot, label: classes.tabLabel }}
label={i18n.t("All Products")}
+ onClick={onAllProducts}
/>
<Tab
disableRipple
classes={{ root: classes.tabRoot, label: classes.tabLabel }}
label={i18n.t("Ready to fulfill")}
+ onClick={onToFulfill}
/>
<Tab
disableRipple
classes={{ root: classes.tabRoot, label: classes.tabLabel }}
label={i18n.t("Ready to capture")}
+ onClick={onToCapture}
/>
{(currentTab === 0 || undefined) &&
filtersList &&
diff --git a/saleor/static/dashboard-next/orders/components/OrderListPage/OrderListPage.tsx b/saleor/static/dashboard-next/orders/components/OrderListPage/OrderListPage.tsx
index c0f53a60ff..3d1558317b 100644
--- a/saleor/static/dashboard-next/orders/components/OrderListPage/OrderListPage.tsx
+++ b/saleor/static/dashboard-next/orders/components/OrderListPage/OrderListPage.tsx
@@ -16,6 +16,9 @@ interface OrderListPageProps extends PageListProps {
orders: OrderList_orders_edges_node[];
currentTab: number;
filtersList: Filter[];
+ onAllProducts: () => void;
+ onToFulfill: () => void;
+ onToCapture: () => void;
}
const OrderListPage: React.StatelessComponent<OrderListPageProps> = ({
@@ -27,7 +30,10 @@ const OrderListPage: React.StatelessComponent<OrderListPageProps> = ({
onPreviousPage,
onRowClick,
currentTab,
- filtersList
+ filtersList,
+ onAllProducts,
+ onToFulfill,
+ onToCapture
}) => (
<Container width="md">
<PageHeader title={i18n.t("Orders")}>
@@ -41,7 +47,13 @@ const OrderListPage: React.StatelessComponent<OrderListPageProps> = ({
</Button>
</PageHeader>
<Card>
- <OrderListFilter currentTab={currentTab} filtersList={filtersList} />
+ <OrderListFilter
+ currentTab={currentTab}
+ filtersList={filtersList}
+ onAllProducts={onAllProducts}
+ onToFulfill={onToFulfill}
+ onToCapture={onToCapture}
+ />
<OrderList
disabled={disabled}
onRowClick={onRowClick}
diff --git a/saleor/static/dashboard-next/orders/views/OrderList.tsx b/saleor/static/dashboard-next/orders/views/OrderList.tsx
index 69b2bc6ec5..60f8d4f957 100644
--- a/saleor/static/dashboard-next/orders/views/OrderList.tsx
+++ b/saleor/static/dashboard-next/orders/views/OrderList.tsx
@@ -68,6 +68,9 @@ export const OrderList: React.StatelessComponent<OrderListProps> = ({
onPreviousPage={loadPreviousPage}
onRowClick={id => () =>
navigate(orderUrl(encodeURIComponent(id)))}
+ onAllProducts={() => undefined}
+ onToFulfill={() => undefined}
+ onToCapture={() => undefined}
/>
)}
</Paginator>
diff --git a/saleor/static/dashboard-next/products/components/ProductListCard/ProductListCard.tsx b/saleor/static/dashboard-next/products/components/ProductListCard/ProductListCard.tsx
index 6d65ad938a..7da9df4ec4 100644
--- a/saleor/static/dashboard-next/products/components/ProductListCard/ProductListCard.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductListCard/ProductListCard.tsx
@@ -19,6 +19,9 @@ interface ProductListCardProps extends PageListProps {
currentTab: number;
filtersList: Filter[];
products: CategoryDetails_category_products_edges_node[];
+ onAllProducts: () => void;
+ onAvailable: () => void;
+ onOfStock: () => void;
}
export const ProductListCard: React.StatelessComponent<
@@ -32,7 +35,10 @@ export const ProductListCard: React.StatelessComponent<
onPreviousPage,
onRowClick,
filtersList,
- currentTab
+ currentTab,
+ onAllProducts,
+ onAvailable,
+ onOfStock
}) => (
<Container width="md">
<PageHeader title={i18n.t("Products")}>
@@ -41,7 +47,13 @@ export const ProductListCard: React.StatelessComponent<
</Button>
</PageHeader>
<Card>
- <ProductListFilter currentTab={currentTab} filtersList={filtersList} />
+ <ProductListFilter
+ currentTab={currentTab}
+ filtersList={filtersList}
+ onAllProducts={onAllProducts}
+ onAvailable={onAvailable}
+ onOfStock={onOfStock}
+ />
<ProductList
products={products}
disabled={disabled}
diff --git a/saleor/static/dashboard-next/products/components/ProductListFilter/ProductListFilter.tsx b/saleor/static/dashboard-next/products/components/ProductListFilter/ProductListFilter.tsx
index e73715e380..175a12718e 100644
--- a/saleor/static/dashboard-next/products/components/ProductListFilter/ProductListFilter.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductListFilter/ProductListFilter.tsx
@@ -10,6 +10,9 @@ import { Filter } from "../ProductListCard";
interface ProductListFilterProps {
currentTab: number;
filtersList: Filter[];
+ onAllProducts: () => void;
+ onAvailable: () => void;
+ onOfStock: () => void;
}
const decorate = withStyles(theme => ({
@@ -57,23 +60,33 @@ const decorate = withStyles(theme => ({
}));
const ProductListFilter = decorate<ProductListFilterProps>(
- ({ classes, filtersList, currentTab }) => (
+ ({
+ classes,
+ filtersList,
+ currentTab,
+ onAllProducts,
+ onAvailable,
+ onOfStock
+ }) => (
<>
<Tabs className={classes.tabsRoot} value={0} indicatorColor={"primary"}>
<Tab
disableRipple
classes={{ root: classes.tabRoot, label: classes.tabLabel }}
label={i18n.t("All Products")}
+ onClick={onAllProducts}
/>
<Tab
disableRipple
classes={{ root: classes.tabRoot, label: classes.tabLabel }}
label={i18n.t("Available")}
+ onClick={onAvailable}
/>
<Tab
disableRipple
classes={{ root: classes.tabRoot, label: classes.tabLabel }}
label={i18n.t("Out of stock")}
+ onClick={onOfStock}
/>
{(currentTab === 0 || undefined) &&
filtersList &&
diff --git a/saleor/static/dashboard-next/products/views/ProductList.tsx b/saleor/static/dashboard-next/products/views/ProductList.tsx
index 468341a215..4d72f1829b 100644
--- a/saleor/static/dashboard-next/products/views/ProductList.tsx
+++ b/saleor/static/dashboard-next/products/views/ProductList.tsx
@@ -59,6 +59,9 @@ export const ProductList: React.StatelessComponent<ProductListProps> = ({
pageInfo={pageInfo}
onRowClick={id => () =>
navigate(productUrl(encodeURIComponent(id)))}
+ onAllProducts={() => undefined}
+ onToFulfill={() => undefined}
+ onToCapture={() => undefined}
/>
)}
</Paginator>
diff --git a/saleor/static/dashboard-next/storybook/stories/orders/OrderListPage.tsx b/saleor/static/dashboard-next/storybook/stories/orders/OrderListPage.tsx
index b3bb3687f6..0c66f819d5 100644
--- a/saleor/static/dashboard-next/storybook/stories/orders/OrderListPage.tsx
+++ b/saleor/static/dashboard-next/storybook/stories/orders/OrderListPage.tsx
@@ -29,7 +29,10 @@ storiesOf("Views / Orders / Order list", module)
orders={orders}
{...pageListProps.default}
filtersList={[]}
+ onAllProducts={() => undefined}
currentTab={0}
+ onToFulfill={() => undefined}
+ onToCapture={() => undefined}
/>
))
.add("with custom filters", () => (
@@ -38,6 +41,9 @@ storiesOf("Views / Orders / Order list", module)
{...pageListProps.loading}
filtersList={filtersList}
currentTab={0}
+ onAllProducts={() => undefined}
+ onToFulfill={() => undefined}
+ onToCapture={() => undefined}
/>
))
.add("loading", () => (
@@ -46,6 +52,9 @@ storiesOf("Views / Orders / Order list", module)
{...pageListProps.loading}
filtersList={undefined}
currentTab={undefined}
+ onAllProducts={() => undefined}
+ onToFulfill={() => undefined}
+ onToCapture={() => undefined}
/>
))
.add("when no data", () => (
@@ -54,5 +63,8 @@ storiesOf("Views / Orders / Order list", module)
{...pageListProps.default}
filtersList={[]}
currentTab={0}
+ onAllProducts={() => undefined}
+ onToFulfill={() => undefined}
+ onToCapture={() => undefined}
/>
));
diff --git a/saleor/static/dashboard-next/storybook/stories/products/ProductListCard.tsx b/saleor/static/dashboard-next/storybook/stories/products/ProductListCard.tsx
index e749eba2b3..7e7ba35ace 100644
--- a/saleor/static/dashboard-next/storybook/stories/products/ProductListCard.tsx
+++ b/saleor/static/dashboard-next/storybook/stories/products/ProductListCard.tsx
@@ -36,6 +36,9 @@ storiesOf("Views / Products / Product list", module)
currentTab={0}
products={products}
{...pageListProps.default}
+ onAllProducts={() => undefined}
+ onAvailable={() => undefined}
+ onOfStock={() => undefined}
/>
))
.add("with custom filters", () => (
@@ -44,6 +47,9 @@ storiesOf("Views / Products / Product list", module)
{...pageListProps.default}
filtersList={filtersList}
currentTab={0}
+ onAllProducts={() => undefined}
+ onAvailable={() => undefined}
+ onOfStock={() => undefined}
/>
))
.add("loading", () => (
@@ -52,6 +58,9 @@ storiesOf("Views / Products / Product list", module)
products={undefined}
filtersList={undefined}
currentTab={undefined}
+ onAllProducts={() => undefined}
+ onAvailable={() => undefined}
+ onOfStock={() => undefined}
/>
))
.add("no data", () => (
@@ -60,5 +69,8 @@ storiesOf("Views / Products / Product list", module)
{...pageListProps.default}
filtersList={[]}
currentTab={0}
+ onAllProducts={() => undefined}
+ onAvailable={() => undefined}
+ onOfStock={() => undefined}
/>
));