Reset pagination when guest change sorting
This commit is contained in:
parent
05078112da
commit
bf4d2495a1
3 changed files with 14 additions and 6 deletions
|
@ -1,6 +1,6 @@
|
|||
import packageInfo from "../package.json";
|
||||
import { SearchVariables } from "./hooks/makeSearch";
|
||||
import { ListSettings, ListViews } from "./types";
|
||||
import { ListSettings, ListViews, Pagination } from "./types";
|
||||
|
||||
export const APP_MOUNT_URI = process.env.APP_MOUNT_URI || "/";
|
||||
export const API_URI = process.env.API_URI;
|
||||
|
@ -11,6 +11,11 @@ export const DEFAULT_INITIAL_SEARCH_DATA: SearchVariables = {
|
|||
query: ""
|
||||
};
|
||||
|
||||
export const DEFAULT_INITIAL_PAGINATION_DATA: Pagination = {
|
||||
after: undefined,
|
||||
before: undefined
|
||||
};
|
||||
|
||||
export const PAGINATE_BY = 20;
|
||||
|
||||
export type ProductListColumns = "productType" | "isPublished" | "price";
|
||||
|
|
|
@ -13,7 +13,8 @@ import SaveFilterTabDialog, {
|
|||
import {
|
||||
defaultListSettings,
|
||||
ProductListColumns,
|
||||
DEFAULT_INITIAL_SEARCH_DATA
|
||||
DEFAULT_INITIAL_SEARCH_DATA,
|
||||
DEFAULT_INITIAL_PAGINATION_DATA
|
||||
} from "@saleor/config";
|
||||
import useBulkActions from "@saleor/hooks/useBulkActions";
|
||||
import useListSettings from "@saleor/hooks/useListSettings";
|
||||
|
@ -112,8 +113,7 @@ export const ProductList: React.FC<ProductListProps> = ({ params }) => {
|
|||
navigate(
|
||||
productListUrl({
|
||||
...params,
|
||||
after: undefined,
|
||||
before: undefined
|
||||
...DEFAULT_INITIAL_PAGINATION_DATA
|
||||
}),
|
||||
true
|
||||
),
|
||||
|
@ -172,7 +172,8 @@ export const ProductList: React.FC<ProductListProps> = ({ params }) => {
|
|||
productListUrl({
|
||||
...params,
|
||||
...getSortUrlVariables(field, params),
|
||||
attributeId
|
||||
attributeId,
|
||||
...DEFAULT_INITIAL_PAGINATION_DATA
|
||||
})
|
||||
);
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { UseNavigatorResult } from "@saleor/hooks/useNavigator";
|
||||
import { Sort } from "@saleor/types";
|
||||
import { DEFAULT_INITIAL_PAGINATION_DATA } from "@saleor/config";
|
||||
import { getSortUrlVariables } from "../sort";
|
||||
|
||||
type CreateUrl<T extends string> = (params: Sort<T>) => string;
|
||||
|
@ -13,7 +14,8 @@ function createSortHandler<T extends string>(
|
|||
navigate(
|
||||
createUrl({
|
||||
...params,
|
||||
...getSortUrlVariables(field, params)
|
||||
...getSortUrlVariables(field, params),
|
||||
...DEFAULT_INITIAL_PAGINATION_DATA
|
||||
}),
|
||||
true
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue