Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Update frontend/src/pages/ReportsHistory.jsx
Browse files
frontend/src/pages/ReportsHistory.jsx
CHANGED
|
@@ -418,33 +418,70 @@ export const ReportsHistory = () => {
|
|
| 418 |
)}
|
| 419 |
</div>
|
| 420 |
|
| 421 |
-
{/* Pagination footer */}
|
| 422 |
-
<div className="px-lg py-md border-t border-outline-variant bg-surface-container-low flex flex-col sm:flex-row justify-between items-center gap-sm">
|
| 423 |
-
<
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 432 |
</span>
|
|
|
|
|
|
|
|
|
|
| 433 |
<button
|
| 434 |
onClick={() => setCurrentPage(prev => Math.max(prev - 1, 1))}
|
| 435 |
disabled={currentPage === 1}
|
| 436 |
-
className="
|
| 437 |
-
title="Previous Page"
|
| 438 |
>
|
| 439 |
-
|
| 440 |
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 441 |
<button
|
| 442 |
onClick={() => setCurrentPage(prev => Math.min(prev + 1, totalPages))}
|
| 443 |
disabled={currentPage >= totalPages}
|
| 444 |
-
className="
|
| 445 |
-
title="Next Page"
|
| 446 |
>
|
| 447 |
-
|
| 448 |
</button>
|
| 449 |
</div>
|
| 450 |
</div>
|
|
|
|
| 418 |
)}
|
| 419 |
</div>
|
| 420 |
|
| 421 |
+
{/* Standard Pagination footer */}
|
| 422 |
+
<div className="px-lg py-md border-t border-outline-variant bg-surface-container-low flex flex-col sm:flex-row justify-between items-center gap-sm text-[13px] text-on-surface-variant">
|
| 423 |
+
<div className="flex items-center gap-2">
|
| 424 |
+
<span className="font-body-sm text-body-sm text-on-surface-variant">Rows per page:</span>
|
| 425 |
+
<select
|
| 426 |
+
value={itemsPerPage}
|
| 427 |
+
onChange={(e) => {
|
| 428 |
+
setItemsPerPage(Number(e.target.value));
|
| 429 |
+
setCurrentPage(1);
|
| 430 |
+
}}
|
| 431 |
+
className="bg-surface border border-outline-variant text-on-surface rounded px-2 py-1 text-xs font-bold focus:outline-none cursor-pointer"
|
| 432 |
+
>
|
| 433 |
+
<option value={10}>10</option>
|
| 434 |
+
<option value={15}>15</option>
|
| 435 |
+
<option value={25}>25</option>
|
| 436 |
+
<option value={50}>50</option>
|
| 437 |
+
<option value={100}>100</option>
|
| 438 |
+
</select>
|
| 439 |
+
<span className="font-body-sm text-body-sm text-on-surface-variant ml-2 font-medium">
|
| 440 |
+
{totalItems > 0
|
| 441 |
+
? `${startIndex + 1} - ${endIndex} of ${totalItems} records`
|
| 442 |
+
: `0 of 0 records`
|
| 443 |
+
}
|
| 444 |
</span>
|
| 445 |
+
</div>
|
| 446 |
+
|
| 447 |
+
<div className="flex items-center gap-1.5">
|
| 448 |
<button
|
| 449 |
onClick={() => setCurrentPage(prev => Math.max(prev - 1, 1))}
|
| 450 |
disabled={currentPage === 1}
|
| 451 |
+
className="px-3 py-1.5 rounded-lg border border-outline-variant bg-surface hover:bg-surface-variant text-on-surface font-bold text-xs disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer transition-colors"
|
|
|
|
| 452 |
>
|
| 453 |
+
Previous
|
| 454 |
</button>
|
| 455 |
+
|
| 456 |
+
<div className="flex items-center gap-1 px-1">
|
| 457 |
+
{Array.from({ length: totalPages }, (_, i) => i + 1)
|
| 458 |
+
.filter(p => p === 1 || p === totalPages || Math.abs(p - currentPage) <= 1)
|
| 459 |
+
.map((page, idx, arr) => {
|
| 460 |
+
const prev = arr[idx - 1];
|
| 461 |
+
return (
|
| 462 |
+
<React.Fragment key={page}>
|
| 463 |
+
{prev && page - prev > 1 && <span className="px-1 text-on-surface-variant text-xs">...</span>}
|
| 464 |
+
<button
|
| 465 |
+
onClick={() => setCurrentPage(page)}
|
| 466 |
+
className={`w-7 h-7 rounded text-xs font-bold transition-colors cursor-pointer ${
|
| 467 |
+
currentPage === page
|
| 468 |
+
? 'bg-primary text-on-primary'
|
| 469 |
+
: 'bg-surface hover:bg-surface-variant border border-outline-variant text-on-surface'
|
| 470 |
+
}`}
|
| 471 |
+
>
|
| 472 |
+
{page}
|
| 473 |
+
</button>
|
| 474 |
+
</React.Fragment>
|
| 475 |
+
);
|
| 476 |
+
})}
|
| 477 |
+
</div>
|
| 478 |
+
|
| 479 |
<button
|
| 480 |
onClick={() => setCurrentPage(prev => Math.min(prev + 1, totalPages))}
|
| 481 |
disabled={currentPage >= totalPages}
|
| 482 |
+
className="px-3 py-1.5 rounded-lg border border-outline-variant bg-surface hover:bg-surface-variant text-on-surface font-bold text-xs disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer transition-colors"
|
|
|
|
| 483 |
>
|
| 484 |
+
Next
|
| 485 |
</button>
|
| 486 |
</div>
|
| 487 |
</div>
|