Skip to content

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

Use url-join lib to create urls

dominik-zeglen21e4cdd2cd13
diff --git a/saleor/static/dashboard-next/staff/index.tsx b/saleor/static/dashboard-next/staff/index.tsx
index d8b145a1fb..6d9b75a7a1 100644
--- a/saleor/static/dashboard-next/staff/index.tsx
+++ b/saleor/static/dashboard-next/staff/index.tsx
@@ -4,6 +4,7 @@ import { Route, RouteComponentProps, Switch } from "react-router-dom";
import { WindowTitle } from "../components/WindowTitle";
import i18n from "../i18n";
+import { staffListUrl, staffMemberDetailsUrl } from "./urls";
import StaffDetailsComponent from "./views/StaffDetails";
import StaffListComponent, { StaffListQueryParams } from "./views/StaffList";
@@ -27,12 +28,16 @@ const StaffDetails: React.StatelessComponent<
<StaffDetailsComponent id={decodeURIComponent(match.params.id)} />
);
-const Component = ({ match }) => (
+const Component = () => (
<>
<WindowTitle title={i18n.t("Staff")} />
<Switch>
- <Route exact path={match.url} component={StaffList} />
- <Route exact path={`${match.url}/:id/`} component={StaffDetails} />
+ <Route exact path={staffListUrl} component={StaffList} />
+ <Route
+ exact
+ path={staffMemberDetailsUrl(":id")}
+ component={StaffDetails}
+ />
</Switch>
</>
);
diff --git a/saleor/static/dashboard-next/staff/urls.ts b/saleor/static/dashboard-next/staff/urls.ts
index ac921d7565..c8e00fbbb0 100644
--- a/saleor/static/dashboard-next/staff/urls.ts
+++ b/saleor/static/dashboard-next/staff/urls.ts
@@ -1,4 +1,5 @@
-export const staffListUrl = "/staff/";
-export const staffMemberDetailsUrl = (id: string) => {
- return `/staff/${id}/`;
-};
+import * as urlJoin from "url-join";
+
+const staffSection = "/staff/";
+export const staffListUrl = staffSection;
+export const staffMemberDetailsUrl = (id: string) => urlJoin(staffSection, id);