Skip to content

Commit 6207e99

Browse files
fix: pagination issue
1 parent df91363 commit 6207e99

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

apps/OpenSign/src/constant/Utils.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,19 @@ export async function fetchSubscriptionInfo() {
100100
const planId =
101101
tenatRes.data?.result?.result?.SubscriptionDetails?.data?.subscription
102102
?.subscription_id;
103-
const plan_code =
104-
tenatRes.data?.result?.result?.SubscriptionDetails?.data?.subscription
105-
?.plan?.plan_code;
103+
const plan_code = tenatRes.data?.result?.result?.PlanCode;
106104
const totalAllowedUser = tenatRes.data?.result?.result?.AllowedUsers || 0;
105+
const adminId =
106+
tenatRes?.data?.result?.result?.ExtUserPtr?.objectId || "";
107+
107108
return {
108109
status: "success",
109110
price: price,
110111
totalPrice: totalPrice,
111112
planId: planId,
112113
plan_code: plan_code,
113-
totalAllowedUser: totalAllowedUser
114+
totalAllowedUser: totalAllowedUser,
115+
adminId: adminId
114116
};
115117
}
116118
} catch (err) {

apps/OpenSign/src/pages/TeamList.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ const TeamList = () => {
135135
const handleFormModal = () => {
136136
setIsModal(!isModal);
137137
};
138-
// Get current list
138+
// to slice out 10 objects from array for current page
139139
const indexOfLastDoc = currentPage * recordperPage;
140140
const indexOfFirstDoc = indexOfLastDoc - recordperPage;
141141
const currentList = teamList?.slice(indexOfFirstDoc, indexOfLastDoc);
@@ -147,7 +147,8 @@ const TeamList = () => {
147147

148148
// Change page
149149
const paginateFront = () => {
150-
if (currentPage < Math.max(...pageNumbers)) {
150+
const lastValue = pageNumbers?.[pageNumbers?.length - 1];
151+
if (currentPage < lastValue) {
151152
setCurrentPage(currentPage + 1);
152153
}
153154
};

apps/OpenSign/src/pages/UserList.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ const UserList = () => {
8585
return pages;
8686
};
8787
const pageNumbers = getPaginationRange();
88+
// to slice out 10 objects from array for current page
89+
const indexOfLastDoc = currentPage * recordperPage;
90+
const indexOfFirstDoc = indexOfLastDoc - recordperPage;
91+
const currentList = userList?.slice(indexOfFirstDoc, indexOfLastDoc);
8892
useEffect(() => {
8993
fetchUserList();
9094
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -129,7 +133,8 @@ const UserList = () => {
129133

130134
// Change page
131135
const paginateFront = () => {
132-
if (currentPage < Math.max(...pageNumbers)) {
136+
const lastValue = pageNumbers?.[pageNumbers?.length - 1];
137+
if (currentPage < lastValue) {
133138
setCurrentPage(currentPage + 1);
134139
}
135140
};
@@ -237,7 +242,7 @@ const UserList = () => {
237242
<tbody className="text-[12px]">
238243
{userList?.length > 0 && (
239244
<>
240-
{userList.map((item, index) => (
245+
{currentList.map((item, index) => (
241246
<tr className="border-y-[1px]" key={index}>
242247
{heading.includes("Sr.No") && (
243248
<th className="px-4 py-2">

apps/OpenSign/src/primitives/GetReportDisplay.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,8 @@ const ReportTable = (props) => {
373373

374374
// Change page
375375
const paginateFront = () => {
376-
if (currentPage < Math.max(...pageNumbers)) {
376+
const lastValue = pageNumbers?.[pageNumbers?.length - 1];
377+
if (currentPage < lastValue) {
377378
setCurrentPage(currentPage + 1);
378379
}
379380
};

0 commit comments

Comments
 (0)