From 8221224255e8c918777423053fadf9ad5055e6e4 Mon Sep 17 00:00:00 2001 From: Josh Creek <8179928+jcreek@users.noreply.github.com> Date: Tue, 15 Oct 2024 19:31:37 +0100 Subject: [PATCH] feat(#6): Add proper pagination support --- package.json | 3 +- pnpm-lock.yaml | 8 ++ src/routes/products/+page.svelte | 180 +++++++++++++++++++++++++++---- 3 files changed, 169 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index 51e89f3..6dd387c 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,8 @@ "dependencies": { "@supabase/ssr": "^0.4.0", "@supabase/supabase-js": "^2.44.2", - "stripe": "^15.4.0" + "stripe": "^15.4.0", + "ts-debounce": "^4.0.0" }, "engines": { "node": ">=18.13.0" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 93412db..437f249 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17,6 +17,9 @@ importers: stripe: specifier: ^15.4.0 version: 15.12.0 + ts-debounce: + specifier: ^4.0.0 + version: 4.0.0 devDependencies: '@sveltejs/adapter-auto': specifier: ^3.0.0 @@ -3051,6 +3054,9 @@ packages: peerDependencies: typescript: '>=4.2.0' + ts-debounce@4.0.0: + resolution: {integrity: sha512-+1iDGY6NmOGidq7i7xZGA4cm8DAa6fqdYcvO5Z6yBevH++Bdo9Qt/mN0TzHUgcCcKv1gmh9+W5dHqz8pMWbCbg==} + ts-interface-checker@0.1.13: resolution: {integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==} @@ -6580,6 +6586,8 @@ snapshots: dependencies: typescript: 5.6.2 + ts-debounce@4.0.0: {} + ts-interface-checker@0.1.13: {} tslib@2.7.0: {} diff --git a/src/routes/products/+page.svelte b/src/routes/products/+page.svelte index 18feb8c..f7112f2 100644 --- a/src/routes/products/+page.svelte +++ b/src/routes/products/+page.svelte @@ -1,17 +1,108 @@
@@ -21,20 +112,67 @@ > Available Products -
- {#each products as product (product.id)} - - {/each} -
- {#if enablePagination} -
-
- - - - -
+ + {#if isLoading} +

Loading products...

+ {:else if errorMessage} +

{errorMessage}

+ {:else} +
+ {#each products as product (product.id)} + + {/each}
+ + {#if enablePagination} +
+
+ + + + + {#each getPageNumbers() as pageNumber} + {#if pageNumber === '...'} + ... + {:else} + + {/if} + {/each} + + + +
+
+ {/if} {/if}
+ +