From e914e50096d072148f7f8cdb42524ea70e6e9c79 Mon Sep 17 00:00:00 2001 From: Thad Miller Date: Mon, 23 Feb 2026 08:33:11 -0500 Subject: [PATCH] [feat] infinite scolling complete --- src/components/CardGrid.astro | 2 +- src/components/StickyFilter.astro | 16 +++++++++++++++- src/pages/partials/cards.astro | 15 ++++++++++++++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/components/CardGrid.astro b/src/components/CardGrid.astro index f5e989f..2bb1d53 100644 --- a/src/components/CardGrid.astro +++ b/src/components/CardGrid.astro @@ -4,7 +4,7 @@
-
Inventory management placeholder
+
Inventory management placeholder
diff --git a/src/components/StickyFilter.astro b/src/components/StickyFilter.astro index 9f29e88..0d36f72 100644 --- a/src/components/StickyFilter.astro +++ b/src/components/StickyFilter.astro @@ -1,12 +1,26 @@ --- --- +
-
+
+
diff --git a/src/pages/partials/cards.astro b/src/pages/partials/cards.astro index cc2aae9..cbc3efd 100644 --- a/src/pages/partials/cards.astro +++ b/src/pages/partials/cards.astro @@ -8,15 +8,18 @@ export const prerender = false; // get the query from post request using form data const formData = await Astro.request.formData(); const query = formData.get('q')?.toString() || ''; +const start = Number(formData.get('start')?.toString() || '0'); // use typesense to search for cards matching the query and return the productIds of the results const searchResults = await client.collections('cards').documents().search({ q: query, filter_by: 'sealed:false', query_by: 'productLineName,productName,setName,number,rarityName', - per_page: 250, + per_page: 20, + page: Math.floor(start / 20) + 1, }); const productIds = searchResults.hits?.map((hit: any) => hit.document.productId) ?? []; +const totalHits = searchResults.found; // get pokemon data with prices and set info using searchResults and then query the database for each card to get the prices and set info const pokemon = await db.query.cards.findMany({ @@ -39,6 +42,11 @@ const formatPrice = (price:any) => { const conditionOrder = ["Near Mint", "Lightly Played", "Moderately Played", "Heavily Played", "Damaged"]; --- +{(start === 0) && + +} {pokemon.map((card) => (
@@ -66,3 +74,8 @@ const conditionOrder = ["Near Mint", "Lightly Played", "Moderately Played", "Hea
))} +{start + 20 < totalHits && +
+ Loading... +
+}