PageSourceSearch

https://www.strangeadv.com/assets/ProductsPage-o_UOtgrK.js

js strangeadv.com collected 2026-10-09 23:31:13 UTC 13,204 bytes, 1 lines download raw bytes

1import{j as e}from"./radix-D5qHxdhA.js";import{f as V,r as i}from"./react-vendor-CVZ_YpZg.js";import{P as W}from"./ProductGrid-H4Ciu8Nr.js";import{s as v}from"./storefront.service-DVovzLo8.js";import{m as R}from"./mockProducts-_Kps9tcf.js";import{U as p,a as l,k as C,L as X,G as Y,S as ee}from"./index-BLRe0tvd.js";import{S as te}from"./select-native-DepdU5an.js";import{F as se}from"./AdjustmentsHorizontalIcon-DfZz5MFf.js";import"./storefrontCartStore-BQ7X9Gll.js";import"./data-BGl8MEun.js";import"./tiptap-ClXTdT6A.js";import"./select-DAmR4lR_.js";function fe(){const[r,a]=V(),[c,f]=i.useState(r.get("search")||""),[k,L]=i.useState("relevance"),[P,m]=i.useState(!1),[D,U]=i.useState([]),[w,B]=i.useState([]),[y,z]=i.useState([]),[j,G]=i.useState([]),[E,F]=i.useState(!0),[O,H]=i.useState(0),[x,Q]=i.useState({page:1,totalPages:1}),[M,Z]=i.useState({categories:!0,availability:!0,productTypes:!1,publishers:!1}),n=r.get("category")||"",h=r.get("collection")||"",g=r.get("type")||"",b=r.get("publisher")||"",d=r.get("stockStatus")||"",$=parseInt(r.get("page")||"1",10);i.useEffect(()=>{(async()=>{try{F(!0);let s;switch(k){case"newest":s="newest";break;case"price-low":s="price-asc";break;case"price-high":s="price-desc";break;case"title":s="title-asc";break}const o=await v.getProducts({search:c||void 0,category:n||void 0,collection:h||void 0,productType:g||void 0,publisher:b||void 0,stockStatus:d||void 0,sort:s,page:$,limit:20});U(o.products),H(o.pagination.total),Q({page:o.pagination.page,totalPages:o.pagination.totalPages})}catch(s){console.error("Error fetching products:",s)}finally{F(!1)}})()},[n,h,g,b,d,c,k,$]),i.useEffect(()=>{(async()=>{try{const[s,o,N]=await Promise.all([v.getCategories(),v.getPublishers(),v.getProductTypes()]);B(s),z(o),G(N)}catch(s){console.error("Error fetching filters:",s)}})()},[]);const q=()=>h||(n?(w.find(s=>s.slug===n)||R.find(s=>s.slug===n))?.name||"Shop":c?`Search Results for "${c}"`:"Shop All Products"),T=()=>{a({}),f("")},_=t=>{t.preventDefault(),c.trim()&&a({search:c})},S=n||h||b||g||d||c,J=t=>{Z(s=>({...s,[t]:!s[t]}))},A=w.length>0?w:R.map(t=>({id:t.id,name:t.name,slug:t.slug,description:t.description,imageUrl:t.image||null,parentId:null,productCount:t.productCount})),I=A.filter(t=>!t.parentId),K=t=>A.filter(s=>s.parentId===t),u=({title:t,sectionKey:s,children:o})=>{const N=M[s];return e.jsxs("div",{className:"mb-6 border-b border-border pb-4",children:[e.jsxs(l,{onClick:()=>J(s),className:"flex items-center justify-between w-full mb-3",children:[e.jsx("h3",{className:"font-semibold text-sm",children:t}),N?e.jsx(Y,{className:"w-4 h-4 text-text-subtle"}):e.jsx(ee,{className:"w-4 h-4 text-text-subtle"})]}),N&&e.jsx("div",{children:o})]})};return e.jsx("div",{className:"min-h-screen bg-surface-2",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 py-8",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-text mb-2",children:q()}),e.jsx("p",{className:"text-text-muted",children:E?"Loading...":`${O} ${O===1?"product":"products"}`})]}),e.jsxs("div",{className:"flex flex-col lg:flex-row gap-8",children:[e.jsx("aside",{className:"hidden lg:block w-64 flex-shrink-0",children:e.jsxs("div",{className:"bg-surface rounded-lg shadow-sm p-6 sticky top-24",children:[e.jsx("h2",{className:"font-bold text-lg mb-4",children:"Filters"}),e.jsxs("form",{onSubmit:_,className:"mb-6",children:[e.jsx("label",{className:"block text-sm font-medium text-text mb-2",children:"Search"}),e.jsxs("div",{className:"relative",children:[e.jsx(p,{type:"text",value:c,onChange:t=>f(t.target.value),placeholder:"Search products...",className:"w-full px-3 py-2 pr-8 border border-border rounded-md focus:ring-ring focus:border-primary"}),c&&e.jsx(l,{type:"button",onClick:()=>f(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-muted",children:e.jsx(C,{className:"w-4 h-4"})})]})]}),e.jsx(u,{title:"Availability",sectionKey:"availability",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"flex items-center",children:[e.jsx(p,{type:"radio",name:"stockStatus",checked:!d,onChange:()=>{const t=Object.fromEntries(r);delete t.stockStatus,a(t)},className:"mr-2 text-primary focus:ring-ring"}),e.jsx("span",{className:"text-sm text-text",children:"All Products"})]}),e.jsxs("label",{className:"flex items-center",children:[e.jsx(p,{type:"radio",name:"stockStatus",checked:d==="in_stock",onChange:()=>a({...Object.fromEntries(r),stockStatus:"in_stock"}),className:"mr-2 text-primary focus:ring-ring"}),e.jsx("span",{className:"text-sm text-text",children:"In Stock"})]}),e.jsxs("label",{className:"flex items-center",children:[e.jsx(p,{type:"radio",name:"stockStatus",checked:d==="out_of_stock",onChange:()=>a({...Object.fromEntries(r),stockStatus:"out_of_stock"}),className:"mr-2 text-primary focus:ring-ring"}),e.jsx("span",{className:"text-sm text-text",children:"Out of Stock"})]})]})}),e.jsx(u,{title:"Categories",sectionKey:"categories",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx(l,{onClick:()=>{const t=Object.fromEntries(r);delete t.category,a(t)},className:`block w-full text-left px-3 py-2 rounded-md text-sm ${n?"text-text hover:bg-surface-2":"bg-primary-soft text-primary font-medium"}`,children:"All Categories"}),I.map(t=>{const s=K(t.id);return e.jsxs("div",{children:[e.jsx(l,{onClick:()=>a({...Object.fromEntries(r),category:t.slug}),className:`block w-full text-left px-3 py-2 rounded-md text-sm font-medium ${n===t.slug?"bg-primary-soft text-primary":"text-text hover:bg-surface-2"}`,children:t.name}),s.length>0&&e.jsx("div",{className:"ml-3 border-l border-border pl-2 space-y-1",children:s.map(o=>e.jsx(l,{onClick:()=>a({...Object.fromEntries(r),category:o.slug}),className:`block w-full text-left px-3 py-1.5 rounded-md text-sm ${n===o.slug?"bg-primary-soft text-primary font-medium":"text-text-muted hover:bg-surface-2"}`,children:o.name},o.id))})]},t.id)})]})}),j.length>0&&e.jsx(u,{title:"Product Type",sectionKey:"productTypes",children:e.jsx("div",{className:"space-y-2 max-h-48 overflow-y-auto",children:j.map(t=>e.jsxs(l,{onClick:()=>a({...Object.fromEntries(r),type:t.type}),className:`block w-full text-left px-3 py-2 rounded-md text-sm ${g===t.type?"bg-primary-soft text-primary font-medium":"text-text hover:bg-surface-2"}`,children:[t.type,e.jsx("span",{className:"float-right text-text-muted text-xs",children:t.count})]},t.type))})}),y.length>0&&e.jsx(u,{title:"Publishers",sectionKey:"publishers",children:e.jsx("div",{className:"space-y-2 max-h-48 overflow-y-auto",children:y.map(t=>e.jsxs(l,{onClick:()=>a({...Object.fromEntries(r),publisher:t.slug}),className:`block w-full text-left px-3 py-2 rounded-md text-sm ${b===t.slug?"bg-primary-soft text-primary font-medium":"text-text hover:bg-surface-2"}`,children:[t.name,e.jsx("span",{className:"float-right text-text-muted text-xs",children:t.productC
1ount})]},t.id))})}),S&&e.jsx(l,{onClick:T,className:"w-full text-sm text-primary hover:text-primary font-medium mt-4",children:"Clear All Filters"})]})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"bg-surface rounded-lg shadow-sm p-4 mb-6 flex flex-col sm:flex-row gap-4 justify-between items-start sm:items-center",children:[e.jsx("form",{onSubmit:_,className:"w-full sm:w-auto sm:flex-1 sm:max-w-md lg:hidden",children:e.jsxs("div",{className:"relative",children:[e.jsx(p,{type:"text",value:c,onChange:t=>f(t.target.value),placeholder:"Search products...",className:"w-full pl-3 pr-8 py-2 border border-border rounded-md focus:ring-ring focus:border-primary"}),c&&e.jsx(l,{type:"button",onClick:()=>f(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-muted",children:e.jsx(C,{className:"w-4 h-4"})})]})}),e.jsxs("div",{className:"flex items-center gap-4 w-full sm:w-auto",children:[e.jsxs(l,{onClick:()=>m(!P),className:"lg:hidden flex items-center gap-2 px-4 py-2 border border-border rounded-md hover:bg-surface-2",children:[e.jsx(se,{className:"w-[18px] h-[18px]"}),"Filters"]}),e.jsxs(te,{value:k,onChange:t=>L(t.target.value),className:"px-4 py-2 border border-border rounded-md focus:ring-ring focus:border-primary",children:[e.jsx("option",{value:"relevance",children:"Sort by Relevance"}),e.jsx("option",{value:"newest",children:"Newest First"}),e.jsx("option",{value:"price-low",children:"Price: Low to High"}),e.jsx("option",{value:"price-high",children:"Price: High to Low"}),e.jsx("option",{value:"title",children:"Title: A to Z"})]})]})]}),P&&e.jsx("div",{className:"lg:hidden fixed inset-0 z-50 bg-black/50",onClick:()=>m(!1),children:e.jsxs("div",{className:"absolute right-0 top-0 bottom-0 w-full max-w-sm bg-surface p-6 overflow-y-auto",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsx("h2",{className:"font-bold text-lg",children:"Filters"}),e.jsx(l,{onClick:()=>m(!1),className:"text-text-subtle hover:text-text",children:e.jsx(C,{className:"w-6 h-6"})})]}),e.jsx(u,{title:"Availability",sectionKey:"availability",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"flex items-center",children:[e.jsx(p,{type:"radio",name:"stockStatus-mobile",checked:!d,onChange:()=>{const t=Object.fromEntries(r);delete t.stockStatus,a(t)},className:"mr-2 text-primary focus:ring-ring"}),e.jsx("span",{className:"text-sm text-text",children:"All Products"})]}),e.jsxs("label",{className:"flex items-center",children:[e.jsx(p,{type:"radio",name:"stockStatus-mobile",checked:d==="in_stock",onChange:()=>a({...Object.fromEntries(r),stockStatus:"in_stock"}),className:"mr-2 text-primary focus:ring-ring"}),e.jsx("span",{className:"text-sm text-text",children:"In Stock"})]}),e.jsxs("label",{className:"flex items-center",children:[e.jsx(p,{type:"radio",name:"stockStatus-mobile",checked:d==="out_of_stock",onChange:()=>a({...Object.fromEntries(r),stockStatus:"out_of_stock"}),className:"mr-2 text-primary focus:ring-ring"}),e.jsx("span",{className:"text-sm text-text",children:"Out of Stock"})]})]})}),e.jsx(u,{title:"Categories",sectionKey:"categories",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx(l,{onClick:()=>{const t=Object.fromEntries(r);delete t.category,a(t),m(!1)},className:`block w-full text-left px-3 py-2 rounded-md text-sm ${n?"text-text hover:bg-surface-2":"bg-primary-soft text-primary font-medium"}`,children:"All Categories"}),I.map(t=>{const s=K(t.id);return e.jsxs("div",{children:[e.jsx(l,{onClick:()=>{a({...Object.fromEntries(r),category:t.slug}),m(!1)},className:`block w-full text-left px-3 py-2 rounded-md text-sm font-medium ${n===t.slug?"bg-primary-soft text-primary":"text-text hover:bg-surface-2"}`,children:t.name}),s.length>0&&e.jsx("div",{className:"ml-3 border-l border-border pl-2 space-y-1",children:s.map(o=>e.jsx(l,{onClick:()=>{a({...Object.fromEntries(r),category:o.slug}),m(!1)},className:`block w-full text-left px-3 py-1.5 rounded-md text-sm ${n===o.slug?"bg-primary-soft text-primary font-medium":"text-text-muted hover:bg-surface-2"}`,children:o.name},o.id))})]},t.id)})]})}),j.length>0&&e.jsx(u,{title:"Product Type",sectionKey:"productTypes",children:e.jsx("div",{className:"space-y-2 max-h-48 overflow-y-auto",children:j.map(t=>e.jsxs(l,{onClick:()=>{a({...Object.fromEntries(r),type:t.type}),m(!1)},className:`block w-full text-left px-3 py-2 rounded-md text-sm ${g===t.type?"bg-primary-soft text-primary font-medium":"text-text hover:bg-surface-2"}`,children:[t.type,e.jsx("span",{className:"float-right text-text-muted text-xs",children:t.count})]},t.type))})}),y.length>0&&e.jsx(u,{title:"Publishers",sectionKey:"publishers",children:e.jsx("div",{className:"space-y-2 max-h-48 overflow-y-auto",children:y.map(t=>e.jsxs(l,{onClick:()=>{a({...Object.fromEntries(r),publisher:t.slug}),m(!1)},className:`block w-full text-left px-3 py-2 rounded-md text-sm ${b===t.slug?"bg-primary-soft text-primary font-medium":"text-text hover:bg-surface-2"}`,children:[t.name,e.jsx("span",{className:"float-right text-text-muted text-xs",children:t.productC
1ount})]},t.id))})}),S&&e.jsx(l,{onClick:()=>{T(),m(!1)},className:"w-full text-sm text-primary hover:text-primary font-medium mt-4",children:"Clear All Filters"})]})}),E?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(X,{size:"lg"})}):e.jsxs(e.Fragment,{children:[e.jsx(W,{products:D,emptyMessage:c?`No products found for "${c}"`:S?"No products match your filters":"No products available"}),x.totalPages>1&&e.jsxs("div",{className:"mt-8 flex justify-center gap-2",children:[e.jsx(l,{onClick:()=>a({...Object.fromEntries(r),page:String(x.page-1)}),disabled:x.page===1,className:"px-4 py-2 border border-border rounded-md hover:bg-surface-2 disabled:opacity-50 disabled:cursor-not-allowed",children:"Previous"}),e.jsxs("span",{className:"px-4 py-2",children:["Page ",x.page," of ",x.totalPages]}),e.jsx(l,{onClick:()=>a({...Object.fromEntries(r),page:String(x.page+1)}),disabled:x.page===x.totalPages,className:"px-4 py-2 border border-border rounded-md hover:bg-surface-2 disabled:opacity-50 disabled:cursor-not-allowed",children:"Next"})]})]})]})]})]})})}export{fe as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.