From 6207e99cc0f67c8bee742c3ab42d169e3cfb23e9 Mon Sep 17 00:00:00 2001 From: prafull-opensignlabs Date: Wed, 11 Sep 2024 12:23:09 +0530 Subject: [PATCH] fix: pagination issue --- apps/OpenSign/src/constant/Utils.js | 10 ++++++---- apps/OpenSign/src/pages/TeamList.js | 5 +++-- apps/OpenSign/src/pages/UserList.js | 9 +++++++-- apps/OpenSign/src/primitives/GetReportDisplay.js | 3 ++- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/apps/OpenSign/src/constant/Utils.js b/apps/OpenSign/src/constant/Utils.js index 4ec3c35d0..54b96e993 100644 --- a/apps/OpenSign/src/constant/Utils.js +++ b/apps/OpenSign/src/constant/Utils.js @@ -100,17 +100,19 @@ export async function fetchSubscriptionInfo() { const planId = tenatRes.data?.result?.result?.SubscriptionDetails?.data?.subscription ?.subscription_id; - const plan_code = - tenatRes.data?.result?.result?.SubscriptionDetails?.data?.subscription - ?.plan?.plan_code; + const plan_code = tenatRes.data?.result?.result?.PlanCode; const totalAllowedUser = tenatRes.data?.result?.result?.AllowedUsers || 0; + const adminId = + tenatRes?.data?.result?.result?.ExtUserPtr?.objectId || ""; + return { status: "success", price: price, totalPrice: totalPrice, planId: planId, plan_code: plan_code, - totalAllowedUser: totalAllowedUser + totalAllowedUser: totalAllowedUser, + adminId: adminId }; } } catch (err) { diff --git a/apps/OpenSign/src/pages/TeamList.js b/apps/OpenSign/src/pages/TeamList.js index 4919aaaba..1e8092983 100644 --- a/apps/OpenSign/src/pages/TeamList.js +++ b/apps/OpenSign/src/pages/TeamList.js @@ -135,7 +135,7 @@ const TeamList = () => { const handleFormModal = () => { setIsModal(!isModal); }; - // Get current list + // to slice out 10 objects from array for current page const indexOfLastDoc = currentPage * recordperPage; const indexOfFirstDoc = indexOfLastDoc - recordperPage; const currentList = teamList?.slice(indexOfFirstDoc, indexOfLastDoc); @@ -147,7 +147,8 @@ const TeamList = () => { // Change page const paginateFront = () => { - if (currentPage < Math.max(...pageNumbers)) { + const lastValue = pageNumbers?.[pageNumbers?.length - 1]; + if (currentPage < lastValue) { setCurrentPage(currentPage + 1); } }; diff --git a/apps/OpenSign/src/pages/UserList.js b/apps/OpenSign/src/pages/UserList.js index 3c0513324..1359e0261 100644 --- a/apps/OpenSign/src/pages/UserList.js +++ b/apps/OpenSign/src/pages/UserList.js @@ -85,6 +85,10 @@ const UserList = () => { return pages; }; const pageNumbers = getPaginationRange(); + // to slice out 10 objects from array for current page + const indexOfLastDoc = currentPage * recordperPage; + const indexOfFirstDoc = indexOfLastDoc - recordperPage; + const currentList = userList?.slice(indexOfFirstDoc, indexOfLastDoc); useEffect(() => { fetchUserList(); // eslint-disable-next-line react-hooks/exhaustive-deps @@ -129,7 +133,8 @@ const UserList = () => { // Change page const paginateFront = () => { - if (currentPage < Math.max(...pageNumbers)) { + const lastValue = pageNumbers?.[pageNumbers?.length - 1]; + if (currentPage < lastValue) { setCurrentPage(currentPage + 1); } }; @@ -237,7 +242,7 @@ const UserList = () => { {userList?.length > 0 && ( <> - {userList.map((item, index) => ( + {currentList.map((item, index) => ( {heading.includes("Sr.No") && ( diff --git a/apps/OpenSign/src/primitives/GetReportDisplay.js b/apps/OpenSign/src/primitives/GetReportDisplay.js index ad182d9df..c36fc1733 100644 --- a/apps/OpenSign/src/primitives/GetReportDisplay.js +++ b/apps/OpenSign/src/primitives/GetReportDisplay.js @@ -373,7 +373,8 @@ const ReportTable = (props) => { // Change page const paginateFront = () => { - if (currentPage < Math.max(...pageNumbers)) { + const lastValue = pageNumbers?.[pageNumbers?.length - 1]; + if (currentPage < lastValue) { setCurrentPage(currentPage + 1); } };