From c0f829b960908b05a1b96b1be0ab99fa2e1069c0 Mon Sep 17 00:00:00 2001 From: Ron Lavi <1ronlavi@gmail.com> Date: Mon, 1 Jan 2024 09:10:38 +0000 Subject: [PATCH] add a comment --- webpack/helpers/pageParamsHelper.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/webpack/helpers/pageParamsHelper.js b/webpack/helpers/pageParamsHelper.js index 09f664cd..6abaa16b 100644 --- a/webpack/helpers/pageParamsHelper.js +++ b/webpack/helpers/pageParamsHelper.js @@ -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,