Added paging to accounts table

This commit is contained in:
2025-03-02 20:45:44 -05:00
parent d06d421d03
commit 7c3b462651
14 changed files with 266 additions and 67 deletions

View File

@@ -0,0 +1,29 @@
export function generatePagination(currentPage: number, totalPages: number){
//If the total number of pages is 7 or less, display all pages without any ellipsis
if(totalPages <= 7){
return Array.from({length: totalPages}, (_, i) => i + 1);
}
//If the current page is among the first 3 pages, show the first 3, an ellipsis, and the last 2 pages.
else if(currentPage <= 3){
return [1, 2, 3, '...', totalPages - 1, totalPages];
}
//If the current page is among the last 3 pages, show the first 2, an ellipsis, and the last 3 pages
else if(currentPage >= totalPages - 2){
return [1, 2, '...', totalPages - 2, totalPages - 1, totalPages];
}
//If the current page is somewhere in the middle, show the first page, and ellipsis, the current page and its neighbors, another ellipsis, and the last page
else{
return [
1,
'...',
currentPage - 1,
currentPage,
currentPage + 1,
'...',
totalPages
];
}
}