PageSourceSearch

https://tailwindadmin-tanstack-pro-dark.netlify.app/assets/index-DNLMR-id.js

js tailwindadmin-tanstack-pro-dark.netlify.app collected 2026-10-03 11:30:37 UTC 2,877 bytes, 1 lines download raw bytes

1import{r,j as se}from"./main-BkpAS6Tt.js";import{u as v,g as F,p as ce,d as ae,b as N}from"./index-Q9o1Xzwm.js";const oe=r.createContext({}),de=({children:B})=>{const[o,n]=r.useState([]),[x,D]=r.useState(""),[u,p]=r.useState("All"),[L,g]=r.useState("newest"),[a,C]=r.useState("All"),[S,f]=r.useState("All"),[y,h]=r.useState("All"),[G,c]=r.useState(!0),[b,R]=r.useState(null),[i,w]=r.useState(()=>{if(typeof window<"u"){const e=localStorage.getItem("cartItems");return e?JSON.parse(e):[]}else return[]}),{data:A,isLoading:d,error:P}=v("/api/data/eCommerce/ProductsData",F);r.useEffect(()=>{A?(n(A.data),c(d)):(P&&R(P),c(d))},[A,P,d]);const{data:E,isLoading:l,error:I,mutate:m}=v("/api/eCommerce/carts",F);r.useEffect(()=>{E?(w(E.data),c(l)):(I&&R(I),c(l))},[E,I,l]),r.useEffect(()=>{i&&localStorage.setItem("cartItems",JSON.stringify(i))},[i]),r.useEffect(()=>{const e=localStorage.getItem("cartItems");e&&w(JSON.parse(e))},[]);const j=e=>{const t=e.title.toLowerCase().includes(x.toLowerCase()),s=u==="All"||e.category.includes(u),ee=a==="All"||a==="0-50"&&e.price<=50||a==="50-100"&&e.price>50&&e.price<=100||a==="100-200"&&e.price>100&&e.price<=200||a==="200-99999"&&e.price>200,te=S==="All"||e.gender===S,re=y==="All"||e.colors.includes(y);return t&&s&&ee&&te&&re},J=e=>{switch(L){case"newest":return e.sort((t,s)=>new Date(s.created).getTime()-new Date(t.created).getTime());case"priceDesc":return e.sort((t,s)=>s.price-t.price);case"priceAsc":return e.sort((t,s)=>t.price-s.price);case"discount":return e.sort((t,s)=>(s.discount||0)-(t.discount||0));default:return e}},O=e=>o.find(s=>s.id===Number(e)),T=o.filter(j),q=J(T),Q=e=>p(e),M=e=>g(e),W=e=>C(e),k=e=>f(e),z=e=>h(e),H=e=>D(e),K=async e=>{try{await m(ce("/api/data/eCommerce/add",{productId:e}))}catch(t){console.error("Error adding product to cart:",t)}},U=async e=>
1{await m(ae("/api/eCommerce/remove-item-carts",{id:e,action:"Increment"}))},V=async e=>{await m(N("/api/eCommerce/carts/increment-decrementqty",{id:e,action:"Increment"}))},X=async e=>{await m(N("/api/eCommerce/carts/increment-decrementqty",{id:e,action:"Decrement"}))},Y=e=>{n(o.filter(t=>t.id!==e))},Z=()=>{n([])},_=(e,t)=>{n(o.map(s=>s.id===Number(e)?t:s))},$=()=>{p("All"),h("All"),f("All"),C("All"),g("newest")};return se.jsx(oe.Provider,{value:{products:o,searchProduct:x,selectedCategory:u,sortBy:L,priceRange:a,selectedGender:S,selectedColor:y,loading:G,error:b,cartItems:i,setProducts:n,setSearchProduct:D,setSelectedCategory:p,setSortBy:g,setPriceRange:C,setSelectedGender:f,setSelectedColor:h,setLoading:c,setCartItems:w,deleteProduct:Y,searchProducts:H,updateSortBy:M,updatePriceRange:W,selectCategory:Q,selectGender:k,selectColor:z,incrementQuantity:V,decrementQuantity:X,removeFromCart:U,addToCart:K,deleteAllProducts:Z,filteredAndSortedProducts:q,filterReset:$,getProductById:O,updateProduct:_},children:B})};export{oe as E,de as a};

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.