aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-11-06 15:42:24 -0800
committerAdam Soltys <[email protected]>2024-11-06 15:42:24 -0800
commit3dfa3eb19dbe8ea03dc7a8ae21c3233e22a47264 (patch)
tree5e8ec1934f5401ddeeb48cc2bf5502a1b2b6a131 /src
parentc0590ecb322007790df1ef74a5088ceca486ba50 (diff)
downloadcoinos-ui-3dfa3eb19dbe8ea03dc7a8ae21c3233e22a47264.tar.gz
coinos-ui-3dfa3eb19dbe8ea03dc7a8ae21c3233e22a47264.zip
fix pagination
Diffstat (limited to 'src')
-rw-r--r--src/routes/(app)/payments/[...page]/+page.svelte27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/routes/(app)/payments/[...page]/+page.svelte b/src/routes/(app)/payments/[...page]/+page.svelte
index 90245bb6..ba2e4992 100644
--- a/src/routes/(app)/payments/[...page]/+page.svelte
+++ b/src/routes/(app)/payments/[...page]/+page.svelte
@@ -128,8 +128,31 @@
}
};
- const showPage = (i) => i < 6 || i >= pages.length - 6;
- const isEllipsis = (i) => pages.length > 12 && i === 6;
+ $: showPage = (i) => {
+ const currentPage = parseInt(p);
+ const maxVisiblePages = 12;
+
+ if (i === 0 || i === pages.length - 1) return true;
+
+ let start = Math.max(
+ 1,
+ currentPage - Math.floor((maxVisiblePages - 4) / 2),
+ );
+ let end = start + maxVisiblePages - 5;
+
+ if (end >= pages.length - 1) {
+ end = pages.length - 2;
+ start = Math.max(1, end - (maxVisiblePages - 5));
+ }
+
+ return i >= start && i <= end;
+ };
+
+ $: isEllipsis = (i) => {
+ return (
+ (i === 1 && !showPage(i)) || (i === pages.length - 2 && !showPage(i))
+ );
+ };
</script>
<div class="space-y-5">