Skip to content

Commit

Permalink
Fixes #36469 - fix the pagination algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
ronlavi2412 committed Jan 2, 2024
1 parent b486520 commit 9ac5382
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions webpack/helpers/pageParamsHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ export const useCurrentPagination = history => {
* to make the pagination work on tables where `page * per_page > totalCount`,
* we needed to add the following calculation for the `last` variable
*/
export const pageToVars = ({ page, per_page }, totalCount = 0) => ({
first: page * per_page,
last: page > 1 && totalCount > 0 ? totalCount - per_page : per_page,
});
export const pageToVars = ({ page, per_page }, totalCount = 0) => {
totalCount = totalCount || per_page;
return ({

Check failure on line 34 in webpack/helpers/pageParamsHelper.js

View workflow job for this annotation

GitHub Actions / test_js (12)

Delete `(`

Check failure on line 34 in webpack/helpers/pageParamsHelper.js

View workflow job for this annotation

GitHub Actions / test_js (14)

Delete `(`
first: Math.min(page * per_page, totalCount),
last: Math.min(per_page, totalCount - (page - 1) * per_page),
});

Check failure on line 37 in webpack/helpers/pageParamsHelper.js

View workflow job for this annotation

GitHub Actions / test_js (12)

Delete `)`

Check failure on line 37 in webpack/helpers/pageParamsHelper.js

View workflow job for this annotation

GitHub Actions / test_js (14)

Delete `)`
}

Check failure on line 38 in webpack/helpers/pageParamsHelper.js

View workflow job for this annotation

GitHub Actions / test_js (12)

Insert `;`

Check failure on line 38 in webpack/helpers/pageParamsHelper.js

View workflow job for this annotation

GitHub Actions / test_js (14)

Insert `;`

export const useParamsToVars = (history, totalCount) =>
pageToVars(useCurrentPagination(history), totalCount);

0 comments on commit 9ac5382

Please sign in to comment.