PageSourceSearch

https://faforlifeherbal.lovable.app/assets/CategoryPage-wNXDQ8eB.js

js faforlifeherbal.lovable.app collected 2026-10-03 03:31:12 UTC 5,364 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-ui-BANI6a6F.js";import{v as B,L as c}from"./vendor-react-DJ3yxPNe.js";import{u as v}from"./vendor-query-CcRWWvw_.js";import{u as I,d as S,a as d,g as A,h as F,i as h,j as _,k as y,l as H,I as M,s as g}from"./index-DwXv1ZZr.js";import{u as T}from"./useTablePagination-De7D4hEA.js";import{P as $,a as D,b as p,c as E,e as K,d as Q}from"./pagination-Bg5X2AFW.js";import{H as R}from"./HeadMeta-MKh6JWUj.js";import"./vendor-supabase-D-vHfFRB.js";function Y(){var b;const{slug:l}=B(),{formatPrice:f}=I(),{settings:m}=S(),w=((b=m==null?void 0:m.general)==null?void 0:b.store_name)||"FaforLife Herbal",{data:a,isLoading:P}=v({queryKey:["category",l],queryFn:async()=>{const{data:s,error:r}=await g.from("categories").select("*").eq("slug",l).single();if(r)throw r;return s},enabled:!!l}),{data:j=[],isLoading:L}=v({queryKey:["category-products",a==null?void 0:a.id],queryFn:async()=>{const{data:s}=await g.from("product_categories").select("product_id").eq("category_id",a.id);if(!s||s.length===0)return[];const r=s.map(u=>u.product_id),{data:o,error:i}=await g.from("products").select("*, product_images(image_url, image_type, display_order)").in("id",r).eq("status","active").order("created_at",{ascending:!1});if(i)throw i;return o||[]},enabled:!!(a!=null&&a.id)}),C=(a==null?void 0:a.meta_title)||(a!=null&&a.name?`${a.name} | ${w}`:void 0),k=(a==null?void 0:a.meta_description)||(a==null?void 0:a.description)||void 0,{currentPage:t,setCurrentPage:x,totalPages:n,paginatedItems:q}=T(j,12),N=s=>{var i;const r=s.product_images||[],o=r.find(u=>u.image_type==="product");return o?o.image_url:(i=r[0])==null?void 0:i.image_url};return P?e.jsx("section",{className:"py-16",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4",children:[e.jsx(d,{className:"h-8 w-48 mb-4"}),e.jsx(d,{className:"h-4 w-96 mb-8"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-6",children:Array.from({length:8}).map((s,r)=>e.jsx(d,{className:"h-64 rounded-xl"},r))})]})}):a?e.jsxs("section",{className:"py-12 md:py-16",children:[e.jsx(R,{title:C,description:k}),e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[e.jsx("nav",{"aria-label":"breadcrumb",className:"mb-6",children:e.jsx(A,{children:e.jsxs(F,{children:[e.jsx(h,{children:e.jsx(_,{asChild:!0,children:e.jsx(c,{to:"/",children:"Home"})})}),e.jsx(y,{}),e.jsx(h,{children:e.jsx(_,{asChild:!0,children:e.jsx(c,{to:"/store",children:"Store"})})}),e.jsx(y,{}),e.jsx(h,{children:e.jsx(H,{children:a.name})})]})})}),e.jsxs("div",{className:"mb-10",children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-heading font-bold text-foreground mb-2",children:a.name}),a.description&&e.jsx("p",{className:"text-muted-foreground font-body max-w-2xl",children:a.description})]}),L?e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-6",children:Array.from({length:8}).map((s,r)=>e.jsx(d,{className:"h-64 rounded-xl"},r))}):j.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-16",children:"No products in this category yet."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-6",children:q.map(s=>e.jsxs(c,{to:`/products/${s.slug}`,className:"group bg-card rounded-xl overflow-hidden shadow-sm hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"aspect-square bg-muted relative overflow-hidden",children:[N(s)?e.jsx("img",{src:N(s),alt:s.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(M,{className:"h-10 w-10 text-muted-foreground/30"})}),s.compare_at_price&&s.compare_at_price>s.price&&e.jsx("span",{className:"absolute top-2 left-2 bg-destructive text-destructive-foreground text-xs font-bold px-2 py-0.5 rounded-full",children:"SALE"})]}),e.jsxs("div",{className:"p-3",children:[e.jsx("h3",{className:"font-heading font-semibold text-foreground line-clamp-1 text-sm",children:s.name}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("span",{className:"font-heading font-bold text-secondary",children:f(s.price)}),s.compare_at_price&&s.compare_at_price>s.price&&e.jsx("span",{className:"text-muted-foreground line-through text-xs",children:f(s.compare_at_price)})]})]})]},s.id))}),n>1&&e.jsx("div",{className:"flex justify-center mt-10",children:e.jsx($,{children:e.jsxs(D,{children:[e.jsx(p,{children:e.jsx(E,{onClick:()=>x(Math.max(1,t-1)),className:t===1?"pointer-events-none opacity-50":"cursor-pointer"})}),Array.from({length:n},(s,r)=>r+1).map(s=>e.jsx(p,{children:e.jsx(K,{isActive:s===t,onClick:()=>x(s),className:"cursor-pointer",children:s})}
1,s)),e.jsx(p,{children:e.jsx(Q,{onClick:()=>x(Math.min(n,t+1)),className:t===n?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})]})]}):e.jsx("section",{className:"py-16 text-center",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4",children:[e.jsx("h1",{className:"text-2xl font-heading font-bold text-foreground mb-2",children:"Category Not Found"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"The category you're looking for doesn't exist."}),e.jsx(c,{to:"/store",className:"text-primary hover:underline font-heading font-semibold",children:"Browse Store"})]})})}export{Y 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.