fix: pagination issue

This commit is contained in:
prafull-opensignlabs
2024-09-11 12:23:09 +05:30
parent df91363ff4
commit 6207e99cc0
4 changed files with 18 additions and 9 deletions
+6 -4
View File
@@ -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) {
+3 -2
View File
@@ -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);
}
};
+7 -2
View File
@@ -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 = () => {
<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">
@@ -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);
}
};