Skip to content

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

Move order views urls to separate file

dominik-zeglenac5361f6f810
diff --git a/saleor/static/dashboard-next/AppRoot.tsx b/saleor/static/dashboard-next/AppRoot.tsx
index 8e0884bb78..1667e54298 100644
--- a/saleor/static/dashboard-next/AppRoot.tsx
+++ b/saleor/static/dashboard-next/AppRoot.tsx
@@ -36,7 +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 { orderListUrl } from "./orders/urls";
import { productListUrl } from "./products";
import { PermissionEnum } from "./types/globalTypes";
diff --git a/saleor/static/dashboard-next/customers/views/CustomerDetails.tsx b/saleor/static/dashboard-next/customers/views/CustomerDetails.tsx
index d391f11ead..428f6baf14 100644
--- a/saleor/static/dashboard-next/customers/views/CustomerDetails.tsx
+++ b/saleor/static/dashboard-next/customers/views/CustomerDetails.tsx
@@ -8,7 +8,7 @@ import Navigator from "../../components/Navigator";
import { WindowTitle } from "../../components/WindowTitle";
import i18n from "../../i18n";
import { maybe } from "../../misc";
-import { orderUrl } from "../../orders";
+import { orderUrl } from "../../orders/urls";
import CustomerDetailsPage from "../components/CustomerDetailsPage/CustomerDetailsPage";
import {
TypedRemoveCustomerMutation,
diff --git a/saleor/static/dashboard-next/home/views/index.tsx b/saleor/static/dashboard-next/home/views/index.tsx
index c9649c1bfc..bb030d93f1 100644
--- a/saleor/static/dashboard-next/home/views/index.tsx
+++ b/saleor/static/dashboard-next/home/views/index.tsx
@@ -3,7 +3,7 @@ import * as React from "react";
import { UserContext } from "../../auth";
import Navigator from "../../components/Navigator";
import { maybe } from "../../misc";
-import { orderListUrl } from "../../orders";
+import { orderListUrl } from "../../orders/urls";
import { productListUrl, productVariantEditUrl } from "../../products";
import { OrderStatusFilter, StockAvailability } from "../../types/globalTypes";
import HomePage from "../components/HomePage";
diff --git a/saleor/static/dashboard-next/orders/index.tsx b/saleor/static/dashboard-next/orders/index.tsx
index b4f0e23916..9639040507 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, stringify as stringifyQs } from "qs";
+import { parse as parseQs } from "qs";
import * as React from "react";
import { Route, RouteComponentProps, Switch } from "react-router-dom";
@@ -35,17 +35,4 @@ const Component = ({ match }) => (
</>
);
-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}/`;
-};
-
export default Component;
diff --git a/saleor/static/dashboard-next/orders/urls.ts b/saleor/static/dashboard-next/orders/urls.ts
new file mode 100644
index 0000000000..dba954c49b
--- /dev/null
+++ b/saleor/static/dashboard-next/orders/urls.ts
@@ -0,0 +1,15 @@
+import { stringify as stringifyQs } from "qs";
+import * as urlJoin from "url-join";
+
+import { OrderListQueryParams } from "./views/OrderList";
+
+const orderSectionUrl = "/orders/";
+export const orderListUrl = (params?: OrderListQueryParams): string => {
+ const orderList = orderSectionUrl;
+ if (params === undefined) {
+ return orderList;
+ } else {
+ return urlJoin(orderList, "?" + stringifyQs(params));
+ }
+};
+export const orderUrl = (id: string) => urlJoin(orderSectionUrl, id);
diff --git a/saleor/static/dashboard-next/orders/views/OrderDetails.tsx b/saleor/static/dashboard-next/orders/views/OrderDetails.tsx
index 06517ba625..d4978a49c0 100644
--- a/saleor/static/dashboard-next/orders/views/OrderDetails.tsx
+++ b/saleor/static/dashboard-next/orders/views/OrderDetails.tsx
@@ -1,6 +1,5 @@
import * as React from "react";
-import { orderListUrl } from "..";
import ErrorMessageCard from "../../components/ErrorMessageCard";
import Messages from "../../components/messages";
import Navigator from "../../components/Navigator";
@@ -29,6 +28,7 @@ import { OrderMarkAsPaid } from "../types/OrderMarkAsPaid";
import { OrderRefund } from "../types/OrderRefund";
import { OrderShippingMethodUpdate } from "../types/OrderShippingMethodUpdate";
import { OrderUpdate } from "../types/OrderUpdate";
+import { orderListUrl } from "../urls";
interface OrderDetailsProps {
id: string;
diff --git a/saleor/static/dashboard-next/orders/views/OrderList.tsx b/saleor/static/dashboard-next/orders/views/OrderList.tsx
index 704023dff0..f262e9641a 100644
--- a/saleor/static/dashboard-next/orders/views/OrderList.tsx
+++ b/saleor/static/dashboard-next/orders/views/OrderList.tsx
@@ -1,7 +1,6 @@
import { stringify as stringifyQs } from "qs";
import * as React from "react";
-import { orderUrl } from "..";
import Messages from "../../components/messages";
import Navigator from "../../components/Navigator";
import { createPaginationState, Paginator } from "../../components/Paginator";
@@ -13,6 +12,7 @@ import { getTabName } from "../misc";
import { TypedOrderDraftCreateMutation } from "../mutations";
import { TypedOrderListQuery } from "../queries";
import { OrderDraftCreate } from "../types/OrderDraftCreate";
+import { orderUrl } from "../urls";
export interface OrderListFilters {
status: OrderStatusFilter;