diff --git a/src/components/Pagination/Pagination.tsx b/src/components/Pagination/Pagination.tsx index 2a236643fe..1d2b23a64b 100644 --- a/src/components/Pagination/Pagination.tsx +++ b/src/components/Pagination/Pagination.tsx @@ -18,8 +18,6 @@ import {getResultPage, getResultTotal} from './utils'; import './Pagination.scss'; const b = blockNew('pagination'); -const DEFAULT_TOTAL = 1; -const DEFAULT_PAGE = 1; export const Pagination = ({ page, @@ -38,12 +36,11 @@ export const Pagination = ({ const size = mobile ? 'l' : 'm'; const compact = mobile ? true : propCompact; - const resultTotal = getResultTotal(total, DEFAULT_TOTAL); + const resultTotal = getResultTotal(total); const resultPage = getResultPage({ page, total: resultTotal, pageSize, - defaultPage: DEFAULT_PAGE, }); const {items, numberOfPages} = usePagination({ diff --git a/src/components/Pagination/utils.ts b/src/components/Pagination/utils.ts index 6bf098ba7c..d950bd7ebb 100644 --- a/src/components/Pagination/utils.ts +++ b/src/components/Pagination/utils.ts @@ -52,22 +52,20 @@ export function getNumberOfPages(pageSize: number, total = 0) { return Math.floor((total - 1) / pageSize) + 1; } -export function getResultTotal(total: number | undefined, defaultTotal: number) { - return total === undefined || total > 0 ? total : defaultTotal; +export function getResultTotal(total: number | undefined) { + return total === undefined || total > 0 ? total : 1; } export function getResultPage({ page, total, pageSize, - defaultPage, }: { page: number; total: number | undefined; pageSize: number; - defaultPage: number; }) { return page > 0 && (total === undefined || page <= getNumberOfPages(pageSize, total)) ? page - : defaultPage; + : 1; }