1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[190],{7314:function(e,t,a){"use strict";a.d(t,{Z:function(){return l}});let l=(0,a(1373).Z)("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]])},1012:function(e,t,a){"use strict";a.d(t,{Z:function(){return l}});let l=(0,a(1373).Z)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},4476:function(e,t,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/cart",function(){return a(3558)}])},6146:function(e,t,a){"use strict";var l=a(5893),s=a(1664),r=a.n(s);let n=(e,t)=>{let a=e.split(" ");return a.length>t?a.slice(0,t).join(" ")+"...":e};t.Z=e=>{let{items:t}=e;return(0,l.jsx)("nav",{className:"py-2",children:(0,l.jsx)("div",{className:"container mx-auto",children:(0,l.jsx)("ul",{className:"flex space-x-2 text-gray-600 flex-wrap",children:t.map((e,t)=>(0,l.jsxs)("li",{className:"flex items-center",children:[t>0&&(0,l.jsx)("span",{className:"mx-2",children:"|"}),e.isActive?(0,l.jsx)("span",{className:"text-gray-900",children:n(e.name,5)}):(0,l.jsx)(r(),{href:e.href,children:(0,l.jsx)("span",{className:"hover:text-gray-900",children:n(e.name,5)})})]},e.name))})})})}},3558:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return F}});var l=a(5893),s=a(5314),r=a(7973),n=a(6852),i={src:"/_next/static/media/character 1.8aaa7a5c.png",height:1536,width:1024,blurDataURL:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAICAMAAAAGL8UJAAAAQlBMVEWVVDRzMg1gLhDajEuwiVNgNRa0bzusWCNMaXFoMg98UipEKhGvTxyeVyfAazLAZCdQLBFEJxFkMg+6ZzDiklFTLhS0CIu3AAAAEnRSTlMKHqNiGrzHQwDOWlrayd65zloNruvGAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAMUlEQVR4nBXEWxbAEAxAwUuRxFtb+9+qYz4GRCVAqv3+D2W1zwrO3phh7vig3rwDQTge1AExcmRnVAAAAABJRU5ErkJggg==",blurWidth:5,blurHeight:8},d=a(202),o=a(7314),c=a(1012),u=a(5675),m=a.n(u),x=a(7294),h=a(1869),p=a(3934),v=a(7066),g=a(1352),b=a(4976);let y=(0,a(1373).Z)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);var f=a(1163),j=a(8031),A=a(8611),N={src:"/_next/static/media/check.cc54cf48.png",height:512,width:512,blurDataURL:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAMAAADz0U65AAAAG1BMVEUgwFUdvVQfv1Ufv1RMaXEgv1QKv0Agv1QfwFTwNUNOAAAACXRSTlNzGEkoAGMFiVZoabQbAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAMklEQVR4nCXLuRGAAAzEQN1ju/+OGSDWiq7BLWWUxHi6zQlCcgpIdyveJHX8YQ3l37cPGpYAu2jHa0AAAAAASUVORK5CYII=",blurWidth:8,blurHeight:8},w=a(9463),C=e=>{var t,a,n,i,o,c,u,C,_,k,E;let{isOpen:S,onClose:D,subtotal:M}=e,[F,z]=(0,x.useState)(null),[R,U]=(0,x.useState)(null),[I,Q]=(0,x.useState)(),[O,Z]=(0,x.useState)(""),[V,W]=(0,x.useState)(null),[B,T]=(0,x.useState)(!1),[G,X]=(0,x.useState)(!1),L=(0,d.NL)(),P=(0,f.useRouter)(),{vendorId:q}=(0,j.a)(),{user:K}=(0,A.a)(),[Y,H]=(0,x.useState)(""),[J,$]=(0,x.useState)(!1),[ee,et]=(0,x.useState)(""),{refetchCart:ea}=(0,r.B)(),[el,es]=(0,x.useState)(null),[er,en]=(0,x.useState)("");(0,x.useEffect)(()=>{var e,t;z(null==K?void 0:null===(e=K.data)||void 0===e?void 0:e.name),es(null==K?void 0:null===(t=K.data)||void 0===t?void 0:t.id)},[K]);let{data:ei,isLoading:ed}=(0,p.a)({queryKey:["getAddressData",el],queryFn:()=>(0,s.zM)("user/".concat(el))});(0,x.useEffect)(()=>{var e,t;if(null==ei?void 0:null===(e=ei.data)||void 0===e?void 0:e.length){let e=null==ei?void 0:null===(t=ei.data)||void 0===t?void 0:t.find(e=>(null==e?void 0:e.selected_address)===!0);(null==e?void 0:e.id)&&Q(String(null==e?void 0:e.id))}},[ei]);let eo=async e=>{try{await (0,h.fO)("user/".concat(el,"/address/").concat(null==e?void 0:e.id),{updated_by:F})&&L.invalidateQueries(["getAddressData"])}catch(e){console.log(e)}},ec=async()=>{try{var e,t;if(!(null==K?void 0:null===(e=K.data)||void 0===e?void 0:e.id))throw Error("User ID not found");let a=await v.Z.get("".concat(w.F,"/vendor-site-payment-delivery-partner-details/").concat(q,"/"));W(a.data[0]),console.log(null==a?void 0:null===(t=a.data[0])||void 0===t?void 0:t.own_delivery_charge,"delivery")}catch(e){console.error("Error fetching delivery charge:",e)}};(0,x.useEffect)(()=>{ec()},[er]);let eu=(0,p.a)({queryKey:["getAppliedCouponDataData",el],queryFn:()=>(0,s.UN)("?user_id=".concat(el)),enabled:!!el}),em=async e=>{e.preventDefault(),et(""),$(!0);let t={user_id:Number(el),coupon_code:Y,vendor_id:q,updated_by:F||"user"};try{await (0,s.Ps)("",t)&&ec()}catch(e){var a,l;et((null==e?void 0:null===(l=e.response)||void 0===l?void 0:null===(a=l.data)||void 0===a?void 0:a.error)||"Failed to apply coupon. Please try again.")}finally{$(!1)}},ex=async()=>{try{var e,t;let a=null==K?void 0:null===(e=K.data)||void 0===e?void 0:e.id;if(!a)throw Error("User ID not found");if(!I)throw Error("No address selected");let l={user_id:parseInt(a),vendor_id:q,customer_phone:null==K?void 0:null===(t=K.data)||void 0===t?void 0:t.contact_number};if("cod"===er){let e=await v.Z.post("".concat(w.F,"/cod-pay-now/"),l);console.log("COD Order placed:",e.data),ea(),T(!0),setTimeout(()=>{T(!1),P.push("/profile?tab=Orders")},5e3)}else{let{payment_order_id:e,final_price:t}=(await v.Z.post("".concat(w.F,"/prepaid-pay-now/"),l)).data,a={key:"rzp_live_zprl8eteDSWOEX",amount:100*t,currency:"INR",name:"Brilliant Memory Computers",description:"Order Payment",order_id:e,handler:function(e){console.log("Payment Success:",e),ea(),T(!0),setTimeout(()=>{T(!1),P.push("/orders")},5e3)},prefill:{name:null==K?void 0:K.name,email:null==K?void 0:K.email,contact:null==K?void 0:K.contact_number},notes:{address:"Selected Address"},theme:{color:"#2563EB"}};new window.Razorpay(a).open()}}catch(e){console.error("Error placing order:",e),X(!0),setTimeout(()=>{X(!1),P.push("/cart")},5e3)}};function eh(e){return new Intl.NumberFormat("en-IN",{style:"currency",currency:"INR",minimumFractionDigits:2}).format(e)}return S?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"fixed overflow-x-scroll top-0 right-0 h-full w-full sm:w-[400px] bg-white shadow-lg transform transition-transform duration-300 z-[10001] ".concat(S?"translate-x-0":"translate-x-full"),children:[(0,l.jsxs)("div",{className:"flex justify-between items-center p-4 border-b",children:[(0,l.jsx)("h2",{className:"text-lg font-semibold",children:"Checkout"}),(0,l.jsx)(g.Z,{className:"cursor-pointer",onClick:D})]}),(0,l.jsxs)("div",{className:"p-4 space-y-6",children:[(null==ei?void 0:null===(t=ei.data)||void 0===t?void 0:t.length)?(0,l.jsxs)("div",{className:"space-y-2",children:[(0,l.jsx)("p",{className:"mt-2 inline-block text-sm text-blue-600 hover:text-blue-700 cursor-pointer flex justify-end",onClick:()=>{P.push("/profile?tab=Address")},children:"Manage address"}
1),null==ei?void 0:null===(a=ei.data)||void 0===a?void 0:a.map(e=>(0,l.jsxs)("label",{className:"flex items-start p-3 rounded-lg border cursor-pointer\n ".concat(I===e.id?"border-blue-500 bg-blue-50":"border-gray-200 hover:bg-gray-50"),children:[(0,l.jsx)("input",{type:"radio",name:"deliveryAddress",value:e.id,checked:I===String(e.id),onChange:()=>{eo(e)},className:"mt-1 h-4 w-4 text-blue-600 border-gray-300 focus:ring-blue-500"}),(0,l.jsxs)("div",{className:"ml-3",children:[(0,l.jsxs)("p",{className:"text-sm font-medium text-gray-900",children:[e.street,e.isDefault&&(0,l.jsx)("span",{className:"ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-blue-100 text-blue-800",children:"Default"})]}),(0,l.jsx)("p",{className:"text-sm text-gray-800",children:e.address_type}),(0,l.jsxs)("p",{className:"text-sm text-gray-800",children:[e.email_address," | ",e.contact_number]}),(0,l.jsxs)("p",{className:"text-sm text-black",children:[e.city,", ",e.state," ",e.zipCode]})]})]},e.id))]}):(0,l.jsxs)("div",{className:"text-center p-4 bg-gray-50 rounded-lg mb-3",children:[(0,l.jsx)(b.Z,{className:"mx-auto h-8 w-8 text-gray-400"}),(0,l.jsx)("p",{className:"mt-2 text-sm text-gray-600",children:"No delivery address found"}),(0,l.jsx)("p",{className:"mt-2 inline-block text-sm text-blue-600 hover:text-blue-700 cursor-pointer",onClick:()=>{P.push("/profile?tab=addresses")},children:"Add a delivery address"})]}),(0,l.jsxs)("div",{className:"mb-4",children:[(0,l.jsx)("label",{className:"block text-black mb-2 font-medium text-sm font-squares",children:"Payment Method"}),(0,l.jsxs)("select",{value:er,onChange:e=>en(e.target.value),className:"w-full p-2 rounded-md border border-gray-600",children:[(0,l.jsx)("option",{value:"",children:"Prepaid"}),(0,l.jsx)("option",{value:"cod",children:"Cash on Delivery (COD)"})]})]}),(null==eu?void 0:null===(o=eu.data)||void 0===o?void 0:null===(i=o.data)||void 0===i?void 0:null===(n=i.applied_coupons)||void 0===n?void 0:n.length)?(0,l.jsx)(l.Fragment,{children:(0,l.jsxs)("div",{className:"bg-green-50 p-4 rounded-lg space-y-2 flex justify-between",children:[(0,l.jsxs)("div",{className:"",children:[(0,l.jsxs)("p",{className:"text-sm text-green-700 font-bold mb-2",children:["Applied Coupon: ",null==eu?void 0:null===(C=eu.data)||void 0===C?void 0:null===(u=C.data)||void 0===u?void 0:null===(c=u.data[0])||void 0===c?void 0:c.code]}),(0,l.jsxs)("p",{className:"text-sm text-green-700 font-bold",children:["Discount Amount: â¹",(null==eu?void 0:null===(E=eu.data)||void 0===E?void 0:null===(k=E.data)||void 0===k?void 0:null===(_=k.applied_coupons[0])||void 0===_?void 0:_.discount)||0]})]}),(0,l.jsx)("button",{className:"text-[#a5291b] border-red-300 hover:bg-red-50",children:"Remove Coupon"})]})}):(0,l.jsxs)("div",{children:[(0,l.jsx)("h2",{className:"text-lg font-semibold mb-1",children:"Coupon"}),(0,l.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,l.jsx)("input",{type:"text",placeholder:"Discount code",className:"bg-white w-full p-2",value:Y,onChange:e=>H(e.target.value.toUpperCase())}),(0,l.jsx)("button",{disabled:!Y||J,onClick:em,className:"whitespace-nowrap bg-blue-600 hover:bg-blue-700 p-2 rounded-md text-white font-bold ",children:J?(0,l.jsx)(y,{className:"h-4 w-4 animate-spin"}):"Apply"})]}),ee&&(0,l.jsx)("p",{className:"text-sm text-[#a5291b]",children:"Coupon not found!"})]}),(0,l.jsx)("div",{className:"border-t pt-4",children:(0,l.jsxs)("p",{className:"text-sm",children:["Delivery Charges: ",(0,l.jsx)("span",{className:"font-semibold",children:eh(Number(null==V?void 0:V.own_delivery_charge))})]})}),(0,l.jsxs)("span",{children:["Total ",(0,l.jsx)("span",{className:"text-sm",children:"(final price including delivery):"})," "]}),(0,l.jsx)("span",{children:eh(Number(null==V?void 0:V.own_delivery_charge)+Number(M))}),(0,l.jsx)("button",{onClick:ex,disabled:!I,className:"w-full bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-md font-medium transition",children:"Place Order"})]})]}),S&&(0,l.jsx)("div",{className:"fixed inset-0 bg-black/50 z-40",onClick:()=>D()}),B&&(0,l.jsx)("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center bg-black/50",children:(0,l.jsxs)("div",{className:"bg-white p-6 rounded-lg shadow-lg text-center max-w-sm ",children:[(0,l.jsx)(m(),{alt:"image",className:"mx-auto mb-3",src:N,width:100,height:100}),(0,l.jsx)("h2",{className:"text-lg font-bold text-green-600 mb-2",children:"Order Placed Successfully!"}),(0,l.jsx)("p",{className:"text-gray-600",children:"You will be redirected to your orders shortly..."})]})}),G&&(0,l.jsx)("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center bg-black/50",children:(0,l.jsxs)("div",{className:"bg-white p-6 rounded-lg shadow-lg text-center max-w-sm",children:[(0,l.jsx)("h2",{className:"text-lg font-bold text-red-600 mb-2",children:"Order Failed"}),(0,l.jsx)("p",{className:"text-gray-600",children:"You will be redirected back to your cart."})]})})]}):null},_=a(1664),k=a.n(_),E=a(6146);function S(){var e,t;let[a,u]=(0,x.useState)(!1),h=(0,d.NL)(),{cartItem:p}=(0,r.B)(),{products:v}=(0,n.r)(),g=null==p?void 0:null===(t=p.data)||void 0===t?void 0:null===(e=t.map((e,t)=>{var a;let l=null==v?void 0:null===(a=v.data)||void 0===a?void 0:a.find(t=>
1t.id===e.product);return{Aid:t,cartId:null==e?void 0:e.id,cartQty:null==e?void 0:e.quantity,...l}}))||void 0===e?void 0:e.sort((e,t)=>{var a;return null===(a=e.name)||void 0===a?void 0:a.localeCompare(t.name)}),b=null==g?void 0:g.reduce((e,t)=>{var a,l,s;return e+(null!==(s=null!==(l=null!==(a=t.price)&&void 0!==a?a:null==t?void 0:t.product_variant_price)&&void 0!==l?l:null==t?void 0:t.product_size_price)&&void 0!==s?s:0)*(t.cartQty||1)},0),y=async(e,t,a)=>{try{1===a&&"decrease"===t?await (0,s.uA)("".concat(e))&&h.invalidateQueries(["getCartitemsData"]):await (0,s.pT)("".concat(e,"/").concat(t,"/"))&&h.invalidateQueries(["getCartitemsData"])}catch(e){console.error("Failed to update cart:",e)}};function f(e){return new Intl.NumberFormat("en-IN",{style:"currency",currency:"INR",minimumFractionDigits:2}).format(e)}return(0,l.jsxs)("div",{className:"min-h-screen bg-gray-50 py-4",children:[(0,l.jsx)("div",{className:"container mx-auto px-4 py-6",children:(0,l.jsx)(E.Z,{items:[{name:"Home",href:"/"},{name:"Cart",href:"/cart",isActive:!0}]})}),(0,l.jsxs)("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[(0,l.jsx)("h1",{className:"text-3xl font-bold text-blue-600 text-center mb-4",children:"Your Shopping Cart"}),(null==g?void 0:g.length)===0||void 0===g?(0,l.jsxs)("div",{className:"flex flex-col items-center justify-center space-y-6 py-10",children:[(0,l.jsx)(m(),{src:i,alt:"Empty Cart",height:150,width:150,className:"object-contain"}),(0,l.jsx)("p",{className:"text-center text-gray-600 text-lg",children:"Your cart is empty."}),(0,l.jsx)(k(),{href:"/products",children:(0,l.jsx)("span",{className:"inline-block bg-blue-600 text-white px-6 py-3 rounded-lg shadow-md hover:bg-blue-700 transition duration-300 ease-in-out transform hover:scale-105",children:"Shop Now"})})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{className:"grid grid-cols-1 gap-6",children:null==g?void 0:g.map(e=>{var t;return(0,l.jsxs)("div",{className:"bg-white p-6 rounded-lg shadow-md hover:shadow-lg transition-shadow duration-300 flex flex-col sm:flex-row items-center justify-between gap-4",children:[(0,l.jsxs)("div",{className:"flex items-center gap-4 flex-1",children:[(0,l.jsx)(m(),{src:null==e?void 0:null===(t=e.image_urls)||void 0===t?void 0:t[0],alt:null==e?void 0:e.name,width:100,height:100,className:"object-cover rounded-lg h-28"}),(0,l.jsxs)("div",{children:[(0,l.jsx)("h4",{className:"text-lg font-semibold text-gray-800 line-clamp-2 overflow-hidden",children:null==e?void 0:e.name}),(0,l.jsx)("p",{className:"text-lg text-blue-600 font-medium mt-1",children:f(null==e?void 0:e.price)})]})]}),(0,l.jsxs)("div",{className:"flex items-center gap-6 mt-4 sm:mt-0",children:[(0,l.jsxs)("div",{className:"flex items-center border border-gray-300 rounded-md overflow-hidden",children:[(0,l.jsx)("button",{className:"h-10 w-10 flex items-center justify-center bg-blue-100 hover:bg-gray-200 transition",onClick:()=>y(null==e?void 0:e.cartId,"decrease",null==e?void 0:e.cartQty),children:(0,l.jsx)(o.Z,{className:"h-5 w-5 text-gray-700"})}),(0,l.jsx)("div",{className:"w-12 text-center text-sm font-medium",children:null==e?void 0:e.cartQty}),(0,l.jsx)("button",{className:"h-10 w-10 flex items-center justify-center bg-blue-100 hover:bg-gray-200 transition",onClick:()=>y(null==e?void 0:e.cartId,"increase",null==e?void 0:e.cartQty),children:(0,l.jsx)(c.Z,{className:"h-5 w-5 text-gray-700"})})]}),(0,l.jsx)("div",{className:"text-right text-md font-semibold text-gray-800 min-w-[100px]",children:f((null==e?void 0:e.price)*(null==e?void 0:e.cartQty))})]})]},e.cartId)})}),(0,l.jsxs)("div",{className:"mt-8 bg-white p-6 rounded-lg shadow-md ",children:[(0,l.jsxs)("div",{className:"flex justify-between items-center text-2xl font-bold text-gray-800 border-b pb-4 mb-4",children:[(0,l.jsx)("span",{children:"Total Amount"}),(0,l.jsx)("span",{children:f(b)})]}),(0,l.jsx)("div",{className:"flex justify-end text-xl font-bold text-gray-800 border-b pb-4 mb-4",children:(0,l.jsx)("button",{className:"ml-auto bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-lg text-lg font-medium transition duration-300 ease-in-out transform",onClick:()=>u(!0),children:"Proceed to Checkout"})})]})]}),(0,l.jsx)(C,{isOpen:a,onClose:()=>u(!1),subtotal:b})]})]})}var D=a(9008),M=a.n(D);function F(){return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(M(),{children:[(0,l.jsx)("title",{children:"Computer Wholesale Market Chennai | Shopping Cart"}),(0,l.jsx)("meta",{name:"description",content:"Explore great computer deals in Chennaiâs wholesale market. Check your selected products, manage your cart, and place your order with ease."}),(0,l.jsx)("link",{rel:"canonical",href:"https://www.brilliantmemorycomputers.in/cart"}),(0,l.jsx)("meta",{name:"robots",content:"index, follow"}),(0,l.jsx)("meta",{property:"og:type",content:"website"}),(0,l.jsx)("meta",{property:"og:title",content:"Computer Wholesale Market Chennai | Shopping Cart"}),(0,l.jsx)("meta",{property:"og:description",content:"Explore great computer deals in Chennaiâs wholesale market. Check your selected products, manage your cart, and place your order with ease."}),(0,l.jsx)("meta",{property:"og:url",content:"https://www.brilliantmemorycomputers.in/cart"}),(0,l.jsx)("meta",{property:"og:site_name",content:"Brilliant Memory Computers"}),(0,l.jsx)("meta",{name:"twitter:card",content:"summary_large_image"}),(0,l.jsx)("meta",{name:"twitter:title",content:"Computer Wholesale Market Chennai | Shopping Cart"}),(0,l.jsx)("meta",{name:"twitter:description",content:"Explore great computer deals in Chennaiâs wholesale market. Check your selected products, manage your cart, and place your order with ease."})]}),(0,l.jsx)(S,{})]})}}},function(e){e.O(0,[888,774,179],function(){return e(e.s=4476)}),_N_E=e.O()}]);
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.