Skip to content

Commit

Permalink
add a comment
Browse files Browse the repository at this point in the history
  • Loading branch information
ronlavi2412 committed Jan 1, 2024
1 parent ab195df commit c0f829b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions webpack/helpers/pageParamsHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ export const useCurrentPagination = (history) => {
};
};

/**
* Since there is no easy way to do pagination with Graphql at the moment,
* we are using `first` and `last` variables in the query.
* 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,
Expand Down

0 comments on commit c0f829b

Please sign in to comment.