mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-07-10 11:06:30 +00:00
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
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 7m35s
This commit is contained in:
@ -52,7 +52,6 @@ export async function DevicesTable({
|
||||
}
|
||||
apiParams.limit = limit;
|
||||
apiParams.offset = offset;
|
||||
console.log("API Params:", apiParams);
|
||||
const [error, devices] = await tryCatch(
|
||||
getDevices(apiParams),
|
||||
);
|
||||
|
@ -28,12 +28,17 @@ export async function PaymentsTable({
|
||||
}>;
|
||||
}) {
|
||||
const resolvedParams = await searchParams;
|
||||
const page = Number.parseInt(resolvedParams.page as string) || 1;
|
||||
const limit = 10;
|
||||
const offset = (page - 1) * limit;
|
||||
const apiParams: Record<string, string | number | undefined> = {};
|
||||
for (const [key, value] of Object.entries(resolvedParams)) {
|
||||
if (value !== undefined && value !== "") {
|
||||
apiParams[key] = typeof value === "number" ? value : String(value);
|
||||
}
|
||||
}
|
||||
apiParams.limit = limit;
|
||||
apiParams.offset = offset;
|
||||
const [error, payments] = await tryCatch(getPayments(apiParams));
|
||||
|
||||
if (error) {
|
||||
@ -166,7 +171,7 @@ export async function PaymentsTable({
|
||||
</TableFooter>
|
||||
</Table>
|
||||
<Pagination
|
||||
totalPages={meta.total / meta.per_page}
|
||||
totalPages={meta.last_page}
|
||||
currentPage={meta.current_page}
|
||||
/>
|
||||
</div>
|
||||
|
@ -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}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
Reference in New Issue
Block a user