Skip to content

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

Extract pagination state to constant type

dominik-zeglen50def001fc85
diff --git a/saleor/static/dashboard-next/categories/views/CategoryList.tsx b/saleor/static/dashboard-next/categories/views/CategoryList.tsx
index 168ac7b692..8f49619656 100644
--- a/saleor/static/dashboard-next/categories/views/CategoryList.tsx
+++ b/saleor/static/dashboard-next/categories/views/CategoryList.tsx
@@ -3,14 +3,12 @@ import * as React from "react";
import Navigator from "../../components/Navigator";
import { createPaginationState, Paginator } from "../../components/Paginator";
import { maybe } from "../../misc";
+import { Pagination } from "../../types";
import { CategoryListPage } from "../components/CategoryListPage/CategoryListPage";
import { TypedRootCategoriesQuery } from "../queries";
import { categoryAddUrl, categoryUrl } from "../urls";
-export type CategoryListQueryParams = Partial<{
- after: string;
- before: string;
-}>;
+export type CategoryListQueryParams = Pagination;
interface CategoryListProps {
params: CategoryListQueryParams;
diff --git a/saleor/static/dashboard-next/collections/views/CollectionDetails.tsx b/saleor/static/dashboard-next/collections/views/CollectionDetails.tsx
index 7efa8c099c..67a52ddf57 100644
--- a/saleor/static/dashboard-next/collections/views/CollectionDetails.tsx
+++ b/saleor/static/dashboard-next/collections/views/CollectionDetails.tsx
@@ -12,6 +12,7 @@ import { SearchProductsProvider } from "../../containers/SearchProducts";
import i18n from "../../i18n";
import { getMutationState, maybe } from "../../misc";
import { productUrl } from "../../products/urls";
+import { Pagination } from "../../types";
import { CollectionInput } from "../../types/globalTypes";
import CollectionDetailsPage, {
CollectionDetailsPageFormData
@@ -33,10 +34,7 @@ import {
collectionUrl
} from "../urls";
-export type CollectionDetailsQueryParams = Partial<{
- after: string;
- before: string;
-}>;
+export type CollectionDetailsQueryParams = Pagination;
interface CollectionDetailsProps {
id: string;
diff --git a/saleor/static/dashboard-next/collections/views/CollectionList.tsx b/saleor/static/dashboard-next/collections/views/CollectionList.tsx
index a13f6d45c7..ac43250b7d 100644
--- a/saleor/static/dashboard-next/collections/views/CollectionList.tsx
+++ b/saleor/static/dashboard-next/collections/views/CollectionList.tsx
@@ -3,14 +3,12 @@ import * as React from "react";
import Navigator from "../../components/Navigator";
import { createPaginationState, Paginator } from "../../components/Paginator";
import { maybe } from "../../misc";
+import { Pagination } from "../../types";
import CollectionListPage from "../components/CollectionListPage/CollectionListPage";
import { TypedCollectionListQuery } from "../queries";
import { collectionAddUrl, collectionUrl } from "../urls";
-export type CollectionListQueryParams = Partial<{
- after: string;
- before: string;
-}>;
+export type CollectionListQueryParams = Pagination;
interface CollectionListProps {
params: CollectionListQueryParams;
diff --git a/saleor/static/dashboard-next/customers/views/CustomerList.tsx b/saleor/static/dashboard-next/customers/views/CustomerList.tsx
index 3f7c458880..200f4f4c05 100644
--- a/saleor/static/dashboard-next/customers/views/CustomerList.tsx
+++ b/saleor/static/dashboard-next/customers/views/CustomerList.tsx
@@ -3,16 +3,14 @@ import * as React from "react";
import Navigator from "../../components/Navigator";
import { createPaginationState, Paginator } from "../../components/Paginator";
import { maybe } from "../../misc";
+import { Pagination } from "../../types";
import CustomerListPage from "../components/CustomerListPage";
import { TypedCustomerListQuery } from "../queries";
import { customerAddUrl, customerUrl } from "../urls";
const PAGINATE_BY = 20;
-export type CustomerListQueryParams = Partial<{
- after: string;
- before: string;
-}>;
+export type CustomerListQueryParams = Pagination;
interface CustomerListProps {
params: CustomerListQueryParams;
diff --git a/saleor/static/dashboard-next/discounts/views/SaleDetails/index.tsx b/saleor/static/dashboard-next/discounts/views/SaleDetails/index.tsx
index 72839424e7..458bd09d7f 100644
--- a/saleor/static/dashboard-next/discounts/views/SaleDetails/index.tsx
+++ b/saleor/static/dashboard-next/discounts/views/SaleDetails/index.tsx
@@ -23,6 +23,7 @@ import { SearchProductsProvider } from "../../../containers/SearchProducts";
import i18n from "../../../i18n";
import { decimal, getMutationState, maybe } from "../../../misc";
import { productUrl } from "../../../products/urls";
+import { Pagination } from "../../../types";
import { DiscountValueTypeEnum, SaleType } from "../../../types/globalTypes";
import SaleDetailsPage, {
SaleDetailsPageTab
@@ -51,11 +52,10 @@ import {
const PAGINATE_BY = 20;
-export type SaleDetailsQueryParams = Partial<{
- after: string;
- before: string;
- tab: SaleDetailsPageTab;
-}>;
+export type SaleDetailsQueryParams = Pagination &
+ Partial<{
+ tab: SaleDetailsPageTab;
+ }>;
interface SaleDetailsProps {
id: string;
diff --git a/saleor/static/dashboard-next/discounts/views/SaleList.tsx b/saleor/static/dashboard-next/discounts/views/SaleList.tsx
index 3eeb9f240f..aa03bcf290 100644
--- a/saleor/static/dashboard-next/discounts/views/SaleList.tsx
+++ b/saleor/static/dashboard-next/discounts/views/SaleList.tsx
@@ -6,16 +6,14 @@ import Shop from "../../components/Shop";
import { WindowTitle } from "../../components/WindowTitle";
import i18n from "../../i18n";
import { maybe } from "../../misc";
+import { Pagination } from "../../types";
import SaleListPage from "../components/SaleListPage";
import { TypedSaleList } from "../queries";
import { saleAddUrl, saleUrl } from "../urls";
const PAGINATE_BY = 20;
-export type SaleListQueryParams = Partial<{
- after: string;
- before: string;
-}>;
+export type SaleListQueryParams = Pagination;
interface SaleListProps {
params: SaleListQueryParams;
diff --git a/saleor/static/dashboard-next/discounts/views/VoucherDetails/index.tsx b/saleor/static/dashboard-next/discounts/views/VoucherDetails/index.tsx
index e89d4e6288..5876df18fb 100644
--- a/saleor/static/dashboard-next/discounts/views/VoucherDetails/index.tsx
+++ b/saleor/static/dashboard-next/discounts/views/VoucherDetails/index.tsx
@@ -23,6 +23,7 @@ import { SearchProductsProvider } from "../../../containers/SearchProducts";
import i18n from "../../../i18n";
import { decimal, getMutationState, maybe } from "../../../misc";
import { productUrl } from "../../../products/urls";
+import { Pagination } from "../../../types";
import {
DiscountValueTypeEnum,
VoucherDiscountValueType
@@ -57,11 +58,10 @@ import {
const PAGINATE_BY = 20;
-export type VoucherDetailsQueryParams = Partial<{
- after: string;
- before: string;
- tab: VoucherDetailsPageTab;
-}>;
+export type VoucherDetailsQueryParams = Pagination &
+ Partial<{
+ tab: VoucherDetailsPageTab;
+ }>;
interface VoucherDetailsProps {
id: string;
diff --git a/saleor/static/dashboard-next/discounts/views/VoucherList.tsx b/saleor/static/dashboard-next/discounts/views/VoucherList.tsx
index 6025afca4e..2e44a6f56e 100644
--- a/saleor/static/dashboard-next/discounts/views/VoucherList.tsx
+++ b/saleor/static/dashboard-next/discounts/views/VoucherList.tsx
@@ -6,16 +6,14 @@ import Shop from "../../components/Shop";
import { WindowTitle } from "../../components/WindowTitle";
import i18n from "../../i18n";
import { maybe } from "../../misc";
+import { Pagination } from "../../types";
import VoucherListPage from "../components/VoucherListPage";
import { TypedVoucherList } from "../queries";
import { voucherAddUrl, voucherUrl } from "../urls";
const PAGINATE_BY = 20;
-export type VoucherListQueryParams = Partial<{
- after: string;
- before: string;
-}>;
+export type VoucherListQueryParams = Pagination;
interface VoucherListProps {
params: VoucherListQueryParams;
diff --git a/saleor/static/dashboard-next/productTypes/views/ProductTypeList.tsx b/saleor/static/dashboard-next/productTypes/views/ProductTypeList.tsx
index 6e8f023599..60e88dbdca 100644
--- a/saleor/static/dashboard-next/productTypes/views/ProductTypeList.tsx
+++ b/saleor/static/dashboard-next/productTypes/views/ProductTypeList.tsx
@@ -4,14 +4,12 @@ import ErrorMessageCard from "../../components/ErrorMessageCard";
import Navigator from "../../components/Navigator";
import { createPaginationState, Paginator } from "../../components/Paginator";
import { maybe } from "../../misc";
+import { Pagination } from "../../types";
import ProductTypeListPage from "../components/ProductTypeListPage";
import { TypedProductTypeListQuery } from "../queries";
import { productTypeAddUrl, productTypeUrl } from "../urls";
-export type ProductTypeListQueryParams = Partial<{
- after: string;
- before: string;
-}>;
+export type ProductTypeListQueryParams = Pagination;
interface ProductTypeListProps {
params: ProductTypeListQueryParams;
diff --git a/saleor/static/dashboard-next/staff/views/StaffList.tsx b/saleor/static/dashboard-next/staff/views/StaffList.tsx
index 3b4807b539..e200810f69 100644
--- a/saleor/static/dashboard-next/staff/views/StaffList.tsx
+++ b/saleor/static/dashboard-next/staff/views/StaffList.tsx
@@ -6,6 +6,7 @@ import Navigator from "../../components/Navigator";
import { createPaginationState, Paginator } from "../../components/Paginator";
import i18n from "../../i18n";
import { getMutationState, maybe } from "../../misc";
+import { Pagination } from "../../types";
import StaffAddMemberDialog, {
FormData as AddStaffMemberForm
} from "../components/StaffAddMemberDialog";
@@ -20,10 +21,7 @@ import {
staffMemberDetailsUrl
} from "../urls";
-export type StaffListQueryParams = Partial<{
- after: string;
- before: string;
-}>;
+export type StaffListQueryParams = Pagination;
interface StaffListProps {
params: StaffListQueryParams;
diff --git a/saleor/static/dashboard-next/types.ts b/saleor/static/dashboard-next/types.ts
index fd5f5446d5..0d645fe1bf 100644
--- a/saleor/static/dashboard-next/types.ts
+++ b/saleor/static/dashboard-next/types.ts
@@ -28,3 +28,8 @@ export interface PartialMutationProviderOutput<
}
export type FormErrors<TKeys extends string> = Partial<Record<TKeys, string>>;
+
+export type Pagination = Partial<{
+ after: string;
+ before: string;
+}>;