Skip to content

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

Apply fixes pointed out in review

dominik-zeglenbd0b03cf2179
diff --git a/saleor/static/dashboard-next/categories/index.tsx b/saleor/static/dashboard-next/categories/index.tsx
index 1373eed933..d40326a39d 100644
--- a/saleor/static/dashboard-next/categories/index.tsx
+++ b/saleor/static/dashboard-next/categories/index.tsx
@@ -11,7 +11,11 @@ const CategoryPaginator: React.StatelessComponent<RouteComponentProps<any>> = ({
match
}) => {
const qs = parseQs(location.search.substr(1));
- return <CategoryDetails id={match.params.id} params={qs} />;
+ const params = {
+ after: qs.after,
+ before: qs.before
+ };
+ return <CategoryDetails id={match.params.id} params={params} />;
};
const SubcategoryCreateForm: React.StatelessComponent<
RouteComponentProps<any>
diff --git a/saleor/static/dashboard-next/categories/views/CategoryDetails.tsx b/saleor/static/dashboard-next/categories/views/CategoryDetails.tsx
index d4321b0a28..635d590cbd 100644
--- a/saleor/static/dashboard-next/categories/views/CategoryDetails.tsx
+++ b/saleor/static/dashboard-next/categories/views/CategoryDetails.tsx
@@ -31,6 +31,13 @@ interface CategoryDeleteProviderProps {
| React.ReactNode;
}
+interface QueryParams {
+ after?: string;
+ before?: string;
+}
+
+const PAGINATE_BY = 20;
+
const CategoryDeleteProvider: React.StatelessComponent<
CategoryDeleteProviderProps
> = ({ category, children }) => (
@@ -78,13 +85,12 @@ interface CategoryPaginationProviderProps {
| React.ReactNode;
id?: string;
navigate: (url: string, push: boolean) => void;
- params: any;
+ params: QueryParams;
}
const CategoryPaginationProvider: React.StatelessComponent<
CategoryPaginationProviderProps
> = ({ children, id, navigate, params }) => {
- const PAGINATE_BY = 20;
const paginationState = createPaginationState(PAGINATE_BY, params);
return (
<TypedCategoryPropertiesQuery
@@ -133,7 +139,7 @@ const CategoryPaginationProvider: React.StatelessComponent<
};
interface CategoryDetailsProps {
- params: any;
+ params: QueryParams;
id: string;
}
diff --git a/saleor/static/dashboard-next/misc.ts b/saleor/static/dashboard-next/misc.ts
index 4f32ba9653..fe95e78c05 100644
--- a/saleor/static/dashboard-next/misc.ts
+++ b/saleor/static/dashboard-next/misc.ts
@@ -1,4 +1,4 @@
-import { stringify } from "querystring";
+import { stringify } from "qs";
export interface PageInfo {
endCursor: string;
diff --git a/saleor/static/dashboard-next/pages/index.tsx b/saleor/static/dashboard-next/pages/index.tsx
index f66e00beda..a8291bd33f 100644
--- a/saleor/static/dashboard-next/pages/index.tsx
+++ b/saleor/static/dashboard-next/pages/index.tsx
@@ -7,11 +7,14 @@ import PageDetailsComponent from "./views/PageDetails";
import PageListComponent from "./views/PageList";
const PageList: React.StatelessComponent<RouteComponentProps<any>> = ({
- location,
- match
+ location
}) => {
const qs = parseQs(location.search.substr(1));
- return <PageListComponent params={qs} />;
+ const params = {
+ after: qs.after,
+ before: qs.before
+ };
+ return <PageListComponent params={params} />;
};
const PageDetails: React.StatelessComponent<RouteComponentProps<any>> = ({
match
diff --git a/saleor/static/dashboard-next/pages/views/PageList.tsx b/saleor/static/dashboard-next/pages/views/PageList.tsx
index c600481aba..6a0f07c6e1 100644
--- a/saleor/static/dashboard-next/pages/views/PageList.tsx
+++ b/saleor/static/dashboard-next/pages/views/PageList.tsx
@@ -1,4 +1,3 @@
-import { stringify } from "querystring";
import * as React from "react";
import ErrorMessageCard from "../../components/ErrorMessageCard";
@@ -6,22 +5,22 @@ import Navigator from "../../components/Navigator";
import i18n from "../../i18n";
import { createPaginationData, createPaginationState } from "../../misc";
import PageListPage from "../components/PageListPage/PageListPage";
-import {
- pageAddUrl,
- pageEditUrl,
- pageListUrl,
- pageStorefrontUrl
-} from "../index";
+import { pageAddUrl, pageEditUrl, pageListUrl } from "../index";
import { pageListQuery, TypedPageListQuery } from "../queries";
interface PageListProps {
- params: any;
+ params: {
+ after?: string;
+ before?: string;
+ };
}
interface PageListState {
isFilterMenuOpened: boolean;
}
+const PAGINATE_BY = 20;
+
export class PageList extends React.Component<PageListProps, PageListState> {
state = { isFilterMenuOpened: false };
handleFilterMenuOpen = () => {
@@ -31,7 +30,6 @@ export class PageList extends React.Component<PageListProps, PageListState> {
};
render() {
const { params } = this.props;
- const PAGINATE_BY = 20;
const paginationState = createPaginationState(PAGINATE_BY, params);
return (
<Navigator>
diff --git a/saleor/static/dashboard-next/products/index.tsx b/saleor/static/dashboard-next/products/index.tsx
index 61a8d60be1..0236cca7a6 100644
--- a/saleor/static/dashboard-next/products/index.tsx
+++ b/saleor/static/dashboard-next/products/index.tsx
@@ -10,7 +10,11 @@ const ProductList: React.StatelessComponent<RouteComponentProps<any>> = ({
location
}) => {
const qs = parseQs(location.search.substr(1));
- return <ProductListComponent params={qs} />;
+ const params = {
+ after: qs.after,
+ before: qs.before
+ };
+ return <ProductListComponent params={params} />;
};
const ProductUpdate: React.StatelessComponent<RouteComponentProps<any>> = ({
diff --git a/saleor/static/dashboard-next/products/views/ProductList.tsx b/saleor/static/dashboard-next/products/views/ProductList.tsx
index 230cb5fc27..5b0be8731a 100644
--- a/saleor/static/dashboard-next/products/views/ProductList.tsx
+++ b/saleor/static/dashboard-next/products/views/ProductList.tsx
@@ -9,7 +9,10 @@ import ProductListCard from "../components/ProductListCard";
import { productListQuery, TypedProductListQuery } from "../queries";
interface ProductListProps {
- params: any;
+ params: {
+ after?: string;
+ before?: string;
+ };
}
const decorate = withStyles(theme => ({
@@ -24,11 +27,12 @@ const decorate = withStyles(theme => ({
}
}));
+const PAGINATE_BY = 20;
+
export const ProductList = decorate<ProductListProps>(({ classes, params }) => (
<div className={classes.root}>
<Navigator>
{navigate => {
- const PAGINATE_BY = 20;
const paginationState = createPaginationState(PAGINATE_BY, params);
return (
<TypedProductListQuery