[object Object]

← back to Healthcarewallpaper

wire sort select to API: add state.sort + pass sort param in product fetch

dfe8084da8e89e297c02756bc2ca6e575d15cbf9 · 2026-05-18 20:40:35 -0700 · Steve Abrams

Files touched

Diff

commit dfe8084da8e89e297c02756bc2ca6e575d15cbf9
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Mon May 18 20:40:35 2026 -0700

    wire sort select to API: add state.sort + pass sort param in product fetch
---
 public/index.html | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/public/index.html b/public/index.html
index 39e6d23..7b49c86 100644
--- a/public/index.html
+++ b/public/index.html
@@ -430,7 +430,7 @@ textarea:focus-visible,
 </script>
 
 <script>
-const state = { q:'', facet:'all', page:1, pages:1, total:0, loading:false, exhausted:false };
+const state = { q:'', facet:'all', sort:'newest', page:1, pages:1, total:0, loading:false, exhausted:false };
 const LABELS = {"all":"All"};
 
 function escAttr(s) { return String(s == null ? '' : s).replace(/[&<>"']/g, c => ({ '&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;' }[c])); }
@@ -543,6 +543,7 @@ async function loadGridPage() {
   const params = new URLSearchParams({ page:state.page, limit:24 });
   if (state.q) params.set('q', state.q);
   if (state.facet !== 'all') params.set('aesthetic', state.facet);
+  if (state.sort && state.sort !== 'newest') params.set('sort', state.sort);
   let data;
   try {
     const r = await fetch('/api/products?' + params);

← 98aa5c0 fix /api/facets total to report niche-filtered count not pre  ·  back to Healthcarewallpaper  ·  untrack 19 stale .bak/.pre-* snapshot files + gitignore the 89abc1d →