Your IP : 216.73.216.93


Current Path : /home/users/unlimited/www/web.medimeet.codeskitter.site/assets/
Upload File :
Current File : /home/users/unlimited/www/web.medimeet.codeskitter.site/assets/Products-DKNy10AK.js

import{d as f,j as e,O as y,E as k,B as s,T as o,F as C,G as h,e as S,i as w,ad as P,ai as T,a5 as q,aF as A,ah as m,a7 as d,ac as b,l as L,aG as E,aH as Q,av as R,f as F}from"./index-CDlA-3aM.js";import{u as W}from"./CartData-DNPZNQPL.js";import{G as j}from"./grid-item-abo2V3UN.js";const v=async()=>(await F("get_product_cat")).data,B=async()=>(await F("get_product")).data;function I(){const{isLoading:t,data:l}=f({queryKey:["categories"],queryFn:v}),{isLoading:p,data:n,error:x}=f({queryKey:["products"],queryFn:B});return t||p?e.jsx(y,{}):x?e.jsx(k,{}):e.jsxs(s,{children:[e.jsx(s,{bg:"primary.main",p:4,py:{base:"4",md:"10"},children:e.jsx(s,{className:"container",children:e.jsx(o,{fontSize:{base:28,md:40},fontWeight:700,textAlign:"center",mt:0,color:"#fff",children:"Products"})})}),e.jsx(s,{className:"container",children:e.jsx(s,{children:e.jsxs(C,{mt:5,gap:5,flexDir:{base:"column",md:"row"},children:[e.jsx(s,{w:{base:"100%",md:"70%"},children:e.jsx(h,{templateColumns:{base:"repeat(2, 1fr)",md:"repeat(3, 1fr)",lg:"repeat(3, 1fr)"},gap:6,children:n==null?void 0:n.map(a=>e.jsx(j,{backgroundColor:"#FFF",borderRadius:10,cursor:"pointer",boxShadow:"2px 2px 20px 0 rgb(82 66 47 / 12%)",_hover:{border:"1px solid #0032ff"},transition:"border 0.1s ease",border:"1px solid #fff",children:e.jsx(G,{data:a},a==null?void 0:a.id)},a.id))})}),e.jsxs(s,{w:{base:"100%",md:"30%"},bg:"#fff",borderRadius:8,h:"fit-content",p:4,boxShadow:"2px 2px 20px 0 rgb(82 66 47 / 12%)",children:[e.jsx(o,{fontSize:20,textAlign:"center",fontWeight:500,children:"Explore Other Categories"}),e.jsx(s,{mt:10,children:e.jsx(h,{templateColumns:{base:"repeat(3, 1fr)",md:"repeat(3, 1fr)",lg:"repeat(3, 1fr)"},gap:6,children:l.map(a=>e.jsx(j,{w:"100%",mb:5,size:"sm",colorScheme:"blue",_hover:{border:"1px solid #0032ff"},transition:"border 0.1s ease",border:"1px solid",borderColor:"gray.200",p:2,borderRadius:4,cursor:"pointer",boxShadow:"lg",children:e.jsxs(s,{align:"center",children:[" ",e.jsx(S,{src:`${w}/department/2024-01-11-65a01d934267d.png`,w:"50px",fallbackSrc:"/imagePlaceholder.png"}),e.jsx(o,{fontSize:"xs",textAlign:"center",fontWeight:500,textTransform:"capitalize",children:a.title})]})},a.id))})})]})]})})})]})}const G=({data:t})=>{const{cartData:l,cartLoading:p}=W(),n=P(),x=T(),a=q(),_=(r,c)=>{const i=r/100*c;return parseFloat(r)+parseFloat(i)},z=async r=>{let c={user_id:d.id,product_id:r.id,price:r.price??"",total_price:_(r.price,r.tax)??"",mrp:r.mrp??"",tax:r.tax??"",qty:1,qty_text:r.qty_text??"",lab_test_id:null};try{const i=await R(d.token,"add_cart",c);if(i.response===200)return m(n,"success","Added to cart!"),x.invalidateQueries("cartdata"),i;m(n,"error",i.message)}catch(i){return i}},u=A({mutationFn:async r=>{await z(r)},onSuccess:()=>{x.invalidateQueries("cartdata")},onError:r=>{m(n,"error",JSON.stringify(r))}}),g=r=>{if(d){let c=!1;return l==null||l.forEach(i=>{i.product_id===r.id&&(c=!0)}),c}else return!1};return d&&p||u.isPending?e.jsx(y,{}):e.jsxs(s,{cursor:"pointer",padding:5,px:3,onClick:()=>{a(`/product/${t.title}/${t.id}`)},children:[" ",e.jsxs(s,{gap:5,children:[" ",e.jsxs(s,{align:"center",children:[" ",e.jsx(S,{fallbackSrc:"/imagePlaceholder.png",w:{base:"auto",md:"auto"},src:`${w}/${t.image}`,h:"80px"})]}),e.jsxs(s,{mt:2,children:[" ",e.jsx(o,{mt:5,fontSize:{base:"sm",md:"md"},fontWeight:500,m:0,isTruncated:!0,maxWidth:{base:"140px",md:"240px"},children:t.title}),e.jsxs(o,{mt:"2px",fontSize:{base:"11px",md:"12px",lg:"12px"},fontWeight:600,m:0,color:"gray.600",fontFamily:"Quicksand, sans-serif",children:["QTY : ",t.qty_text]}),e.jsxs(C,{gap:2,align:"center",children:[" ",e.jsxs(o,{textDecor:"line-through",mt:"2px",fontSize:{base:"xs",md:"sm",lg:"sm"},m:0,color:"primary.text",fontWeight:600,fontFamily:"Quicksand, sans-serif",children:[b," ",t.mrp]}),e.jsxs(o,{mt:"2px",fontSize:{base:"xs",md:"sm",lg:"sm"},m:0,color:"primary.text",fontWeight:600,fontFamily:"Quicksand, sans-serif",children:[b," ",t.price]})]}),e.jsx(L,{colorScheme:"blue",size:"xs",w:"full",mt:2,onClick:r=>{if(r.stopPropagation(),!d)return m(n,"error","Please Login First");u.mutate(t)},leftIcon:g(t)?e.jsx(E,{fontSize:20,style:{marginRight:"5px"}}):e.jsx(Q,{fontSize:20,style:{marginRight:"5px"}}),children:g(t)?"Added To Cart":"Add to Cart"})]})]})]})};export{I as default};