Skip to content

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

Enable links to filter tabs from homepage

dominik-zeglenc1b5e1aac434
diff --git a/saleor/static/dashboard-next/AppRoot.tsx b/saleor/static/dashboard-next/AppRoot.tsx
index f80d959610..f13123a161 100644
--- a/saleor/static/dashboard-next/AppRoot.tsx
+++ b/saleor/static/dashboard-next/AppRoot.tsx
@@ -36,6 +36,7 @@ import Home from "./icons/Home";
import Shop from "./icons/Shop";
import Truck from "./icons/Truck";
import { removeDoubleSlashes } from "./misc";
+import { orderListUrl } from "./orders";
import { productListUrl } from "./products";
import { PermissionEnum } from "./types/globalTypes";
@@ -56,7 +57,7 @@ const menuStructure: IMenuItem[] = [
ariaLabel: "products",
icon: <Shop />,
label: i18n.t("Products", { context: "Menu label" }),
- url: productListUrl
+ url: productListUrl()
},
{
ariaLabel: "categories",
@@ -80,7 +81,7 @@ const menuStructure: IMenuItem[] = [
icon: <Truck />,
label: i18n.t("Orders", { context: "Menu label" }),
permission: PermissionEnum.MANAGE_ORDERS,
- url: "/orders/"
+ url: orderListUrl()
},
{
ariaLabel: "customers",
diff --git a/saleor/static/dashboard-next/home/views/index.tsx b/saleor/static/dashboard-next/home/views/index.tsx
index e16b783f41..c9649c1bfc 100644
--- a/saleor/static/dashboard-next/home/views/index.tsx
+++ b/saleor/static/dashboard-next/home/views/index.tsx
@@ -5,6 +5,7 @@ import Navigator from "../../components/Navigator";
import { maybe } from "../../misc";
import { orderListUrl } from "../../orders";
import { productListUrl, productVariantEditUrl } from "../../products";
+import { OrderStatusFilter, StockAvailability } from "../../types/globalTypes";
import HomePage from "../components/HomePage";
import { HomePageQuery } from "../queries";
@@ -32,9 +33,27 @@ const HomeSection = () => (
)
)
}
- onOrdersToCaptureClick={() => navigate(orderListUrl)} // TODO: #3172
- onOrdersToFulfillClick={() => navigate(orderListUrl)} // TODO: #3172
- onProductsOutOfStockClick={() => navigate(productListUrl)} // TODO: #3184
+ onOrdersToCaptureClick={() =>
+ navigate(
+ orderListUrl({
+ status: OrderStatusFilter.READY_TO_CAPTURE
+ })
+ )
+ }
+ onOrdersToFulfillClick={() =>
+ navigate(
+ orderListUrl({
+ status: OrderStatusFilter.READY_TO_FULFILL
+ })
+ )
+ }
+ onProductsOutOfStockClick={() =>
+ navigate(
+ productListUrl({
+ status: StockAvailability.OUT_OF_STOCK
+ })
+ )
+ }
ordersToCapture={maybe(() => data.ordersToCapture.totalCount)}
ordersToFulfill={maybe(() => data.ordersToFulfill.totalCount)}
productsOutOfStock={maybe(
diff --git a/saleor/static/dashboard-next/orders/index.tsx b/saleor/static/dashboard-next/orders/index.tsx
index 096c4a6fe8..b4f0e23916 100644
--- a/saleor/static/dashboard-next/orders/index.tsx
+++ b/saleor/static/dashboard-next/orders/index.tsx
@@ -1,4 +1,4 @@
-import { parse as parseQs } from "qs";
+import { parse as parseQs, stringify as stringifyQs } from "qs";
import * as React from "react";
import { Route, RouteComponentProps, Switch } from "react-router-dom";
@@ -35,7 +35,14 @@ const Component = ({ match }) => (
</>
);
-export const orderListUrl = "/orders/";
+export const orderListUrl = (params?: OrderListQueryParams): string => {
+ const orderList = "/orders/";
+ if (params === undefined) {
+ return orderList;
+ } else {
+ return orderList + "?" + stringifyQs(params);
+ }
+};
export const orderUrl = (id: string) => {
return `/orders/${id}/`;
diff --git a/saleor/static/dashboard-next/orders/views/OrderDetails.tsx b/saleor/static/dashboard-next/orders/views/OrderDetails.tsx
index aff62b6f94..06517ba625 100644
--- a/saleor/static/dashboard-next/orders/views/OrderDetails.tsx
+++ b/saleor/static/dashboard-next/orders/views/OrderDetails.tsx
@@ -145,7 +145,7 @@ export const OrderDetails: React.StatelessComponent<OrderDetailsProps> = ({
context: "notification"
})
});
- navigate(orderListUrl);
+ navigate(orderListUrl());
};
const handleOrderVoid = () => {
pushMessage({
@@ -398,7 +398,7 @@ export const OrderDetails: React.StatelessComponent<OrderDetailsProps> = ({
order: id
})
}
- onBack={() => navigate(orderListUrl)}
+ onBack={() => navigate(orderListUrl())}
order={order}
countries={maybe(
() => data.shop.countries,
@@ -565,7 +565,7 @@ export const OrderDetails: React.StatelessComponent<OrderDetailsProps> = ({
}
})
}
- onBack={() => navigate(orderListUrl)}
+ onBack={() => navigate(orderListUrl())}
order={order}
countries={maybe(
() => data.shop.countries,
diff --git a/saleor/static/dashboard-next/products/index.tsx b/saleor/static/dashboard-next/products/index.tsx
index fa976a5609..6d84214da8 100644
--- a/saleor/static/dashboard-next/products/index.tsx
+++ b/saleor/static/dashboard-next/products/index.tsx
@@ -1,4 +1,4 @@
-import { parse as parseQs } from "qs";
+import { parse as parseQs, stringify as stringifyQs } from "qs";
import * as React from "react";
import { Route, RouteComponentProps, Switch } from "react-router-dom";
@@ -104,7 +104,14 @@ export const productVariantEditUrl = (productId: string, variantId: string) => {
export const productImageUrl = (productId: string, imageId: string) =>
`/products/${productId}/image/${imageId}/`;
-export const productListUrl = "/products/";
+export const productListUrl = (params?: ProductListQueryParams): string => {
+ const productList = "/products/";
+ if (params === undefined) {
+ return productList;
+ } else {
+ return productList + "?" + stringifyQs(params);
+ }
+};
export const productAddUrl = "/products/add/";
export interface AttributeType {
diff --git a/saleor/static/dashboard-next/products/views/ProductCreate.tsx b/saleor/static/dashboard-next/products/views/ProductCreate.tsx
index 9db00e79c2..cc6059b7cc 100644
--- a/saleor/static/dashboard-next/products/views/ProductCreate.tsx
+++ b/saleor/static/dashboard-next/products/views/ProductCreate.tsx
@@ -28,7 +28,7 @@ export const ProductUpdate: React.StatelessComponent<
<Navigator>
{navigate => {
const handleAttributesEdit = undefined;
- const handleBack = () => navigate(productListUrl);
+ const handleBack = () => navigate(productListUrl());
return (
<TypedProductCreateQuery query={productCreateQuery}>
diff --git a/saleor/static/dashboard-next/products/views/ProductUpdate.tsx b/saleor/static/dashboard-next/products/views/ProductUpdate.tsx
index 49494d215a..88fc2a53fa 100644
--- a/saleor/static/dashboard-next/products/views/ProductUpdate.tsx
+++ b/saleor/static/dashboard-next/products/views/ProductUpdate.tsx
@@ -44,7 +44,7 @@ export const ProductUpdate: React.StatelessComponent<ProductUpdateProps> = ({
const handleDelete = () => {
pushMessage({ text: i18n.t("Product removed") });
- navigate(productListUrl);
+ navigate(productListUrl());
};
const handleUpdate = () =>
pushMessage({ text: i18n.t("Saved changes") });
@@ -165,7 +165,7 @@ export const ProductUpdate: React.StatelessComponent<ProductUpdateProps> = ({
)
}
onBack={() => {
- navigate(productListUrl);
+ navigate(productListUrl());
}}
onDelete={() => deleteProduct.mutate({ id })}
onProductShow={() => {