Skip to content

Commit

Permalink
fix: pagination issue
Browse files Browse the repository at this point in the history
  • Loading branch information
prafull-opensignlabs committed Sep 11, 2024
1 parent df91363 commit 6207e99
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
10 changes: 6 additions & 4 deletions apps/OpenSign/src/constant/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions apps/OpenSign/src/pages/TeamList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
};
Expand Down
9 changes: 7 additions & 2 deletions apps/OpenSign/src/pages/UserList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
};
Expand Down Expand Up @@ -237,7 +242,7 @@ const UserList = () => {
<tbody className="text-[12px]">
{userList?.length > 0 && (
<>
{userList.map((item, index) => (
{currentList.map((item, index) => (
<tr className="border-y-[1px]" key={index}>
{heading.includes("Sr.No") && (
<th className="px-4 py-2">
Expand Down
3 changes: 2 additions & 1 deletion apps/OpenSign/src/primitives/GetReportDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};
Expand Down

0 comments on commit 6207e99

Please sign in to comment.