fix: pagination in PaymentsTable and TopupsTable components 🐛
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 7m35s

This commit is contained in:
2025-07-08 22:39:59 +05:00
parent fa12cd74d7
commit 783d4b360d
4 changed files with 33 additions and 27 deletions

View File

@ -27,7 +27,9 @@ export async function TopupsTable({
}>;
}) {
const resolvedParams = await searchParams;
const page = Number.parseInt(resolvedParams.page as string) || 1;
const limit = 10;
const offset = (page - 1) * limit;
// Build params object
const apiParams: Record<string, string | number | undefined> = {};
for (const [key, value] of Object.entries(resolvedParams)) {
@ -35,7 +37,8 @@ export async function TopupsTable({
apiParams[key] = typeof value === "number" ? value : String(value);
}
}
apiParams.limit = limit;
apiParams.offset = offset;
const [error, topups] = await tryCatch(getTopups(apiParams));
if (error) {
@ -151,8 +154,8 @@ export async function TopupsTable({
))}
</div>
<Pagination
totalPages={meta.total / meta.per_page}
currentPage={meta.current_page}
totalPages={meta?.last_page}
currentPage={meta?.current_page}
/>
</>
)}