OwlCyberSecurity - MANAGER
Edit File: 6553-ec917d0c445cd3e2.js
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6553],{56553:function(e,s,t){t.d(s,{Z:function(){return u}});var a=t(57437),n=t(99376),c=t(2265),l=t(32603),i=t(59964),o=t(88735),r=t(50400),d=t(14438),h=t(69064),x=t(27648),p=t(67066),m=function(e){let{creditsCart:s,removeItemFromBasket:t}=e,n=(0,l.I0)(),r=(0,i.Z)();return(0,c.useEffect)(()=>{setTimeout(()=>{var e=new Headers;e.append("Accept","application/json");let t=new FormData;for(let e=0;e<s.length;e++)t.append("cart[".concat(e,"][slug]"),s[e].slug);fetch("".concat("https://app.charsooq.com/api/v1/","tara-count"),{method:"POST",headers:e,body:t}).then(e=>e.json()).then(e=>{200===e.status&&e.data.map(e=>n((0,o.pV)({slug:e.slug,inventory:e.count,weight:e.weight,singleitemfullprice:e.price,item_price:e.item_price,shipping_cost:e.shipping_cost})))}).catch(e=>console.error(e))},500)},[]),(0,a.jsxs)("div",{className:"checkout-content-right-section",children:[(0,a.jsx)("div",{className:"flex items-center justify-between border-b pb-3",children:(0,a.jsxs)("div",{className:"flex items-center justify-between w-full",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-[18px]",children:[(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5",children:(0,a.jsx)("path",{"fill-rule":"evenodd",d:"M7.5 6v.75H5.513c-.96 0-1.764.724-1.865 1.679l-1.263 12A1.875 1.875 0 0 0 4.25 22.5h15.5a1.875 1.875 0 0 0 1.865-2.071l-1.263-12a1.875 1.875 0 0 0-1.865-1.679H16.5V6a4.5 4.5 0 1 0-9 0ZM12 3a3 3 0 0 0-3 3v.75h6V6a3 3 0 0 0-3-3Zm-3 8.25a3 3 0 1 0 6 0v-.75a.75.75 0 0 1 1.5 0v.75a4.5 4.5 0 1 1-9 0v-.75a.75.75 0 0 1 1.5 0v.75Z","clip-rule":"evenodd"})}),(0,a.jsx)("h3",{className:"font-IRANSansBold",children:"فاکتور خرید اقساطی"})]}),(0,a.jsx)(x.default,{className:"text-[var(--base-blue)] text-[14px] underline cursor-pointer font-IRANSansBold",href:"/credits/products?page=1",children:"ثبت سفارش جدید"})]})}),(0,a.jsx)("div",{className:"checkout-contents-container",children:(0,a.jsx)("div",{className:"checkout-contents",children:s.map(e=>(0,a.jsxs)("div",{className:"checkout-content-single",children:[(0,a.jsxs)("div",{className:"checkout-content-single-img",children:[(0,a.jsx)(x.default,{href:"/credits/".concat(e.slug),children:(0,a.jsx)("img",{src:e.image,alt:""})}),r?(0,a.jsxs)("div",{className:"set-count-basket-border",children:[(0,a.jsx)("button",{disabled:e.inventory<=e.count,onClick:()=>{n((0,o.ew)(e.id))},children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",className:"w-5 h-5 ".concat(e.inventory<=e.count?"text-[var(--text-gray)]":"text-[var(--light-blue)]"),children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v12m6-6H6"})})}),(0,a.jsx)("span",{children:e.count}),(0,a.jsx)("button",{disabled:e.count<2,onClick:()=>{n((0,o.Zp)(e.id))},children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",className:"w-5 h-5 ".concat(e.count>1&&"text-[var(--light-blue)]"),children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M18 12H6"})})})]}):null]}),(0,a.jsxs)("div",{className:"checkout-content-single-detail",children:[(0,a.jsx)(x.default,{href:"/credits/".concat(e.slug),children:(0,a.jsx)("p",{className:"font-IRANSansBold ltr line-clamp-4 md:line-clamp-none",children:e.name})}),(0,a.jsxs)("div",{className:"flex items-center text-[var(--text-gray)] text-[14px]",children:[(0,a.jsxs)("span",{children:["قیمت واحد به ","تومان",":"]}),(0,a.jsxs)("span",{children:[e.singleitemfullprice.toLocaleString(),(0,a.jsxs)("span",{children:[" ","تومان"]})]})]}),(0,a.jsxs)("div",{className:"flex items-center text-[var(--text-gray)] text-[14px]",children:[(0,a.jsx)("span",{children:"وزن کل:"}),(0,a.jsxs)("span",{children:[(e.weight*e.count).toFixed(3)," ","گرم"]})]}),(0,a.jsxs)("div",{className:"flex flex-col md:flex-row items-start md:items-center gap-3 justify-between w-full",children:[(0,a.jsxs)("div",{className:"set-count-basket-border desktop",children:[(0,a.jsx)("button",{disabled:e.inventory<=e.count,onClick:()=>{n((0,o.ew)(e.id))},children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",className:"w-5 h-5 ".concat(e.inventory<=e.count?"text-[var(--text-gray)]":"text-[var(--light-blue)]"),children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v12m6-6H6"})})}),(0,a.jsx)("span",{children:e.count}),(0,a.jsx)("button",{disabled:e.count<2,onClick:()=>{n((0,o.Zp)(e.id))},children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",className:"w-5 h-5 ".concat(e.count>1&&"text-[var(--light-blue)]"),children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M18 12H6"})})})]}),(0,a.jsx)("div",{className:"w-full flex justify-end",children:(0,a.jsxs)("button",{onClick:()=>t(e.id),className:"checkout-remove-button",children:[(0,a.jsx)("svg",{width:"17",height:"20",viewBox:"0 0 17 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,a.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.9486 3.33333H13.3652C13.1718 2.39284 12.6601 1.54779 11.9163 0.940598C11.1725 0.333408 10.2421 0.0012121 9.2819 0H7.61523C6.65506 0.0012121 5.72467 0.333408 4.98086 0.940598C4.23705 1.54779 3.72531 2.39284 3.5319 3.33333H0.948568C0.727554 3.33333 0.515592 3.42113 0.359312 3.57741C0.203032 3.73369 0.115234 3.94565 0.115234 4.16667C0.115234 4.38768 0.203032 4.59964 0.359312 4.75592C0.515592 4.9122 0.727554 5 0.948568 5H1.7819V15.8333C1.78322 16.938 2.22264 17.997 3.00375 18.7782C3.78487 19.5593 4.84391 19.9987 5.94857 20H10.9486C12.0532 19.9987 13.1123 19.5593 13.8934 18.7782C14.6745 17.997 15.1139 16.938 15.1152 15.8333V5H15.9486C16.1696 5 16.3815 4.9122 16.5378 4.75592C16.6941 4.59964 16.7819 4.38768 16.7819 4.16667C16.7819 3.94565 16.6941 3.73369 16.5378 3.57741C16.3815 3.42113 16.1696 3.33333 15.9486 3.33333ZM7.61523 1.66667H9.2819C9.7988 1.6673 10.3028 1.82781 10.7249 2.1262C11.147 2.42459 11.4664 2.84624 11.6394 3.33333H5.25773C5.43072 2.84624 5.75015 2.42459 6.17222 2.1262C6.5943 1.82781 7.09834 1.6673 7.61523 1.66667ZM13.4486 15.8333C13.4486 16.4964 13.1852 17.1323 12.7163 17.6011C12.2475 18.0699 11.6116 18.3333 10.9486 18.3333H5.94857C5.28553 18.3333 4.64964 18.0699 4.1808 17.6011C3.71196 17.1323 3.44857 16.4964 3.44857 15.8333V5H13.4486V15.8333ZM6.7819 14.9996C7.00291 14.9996 7.21487 14.9118 7.37115 14.7555C7.52743 14.5992 7.61523 14.3873 7.61523 14.1662V9.16626C7.61523 8.94524 7.52743 8.73328 7.37115 8.577C7.21487 8.42072 7.00291 8.33293 6.7819 8.33293C6.56089 8.33293 6.34892 8.42072 6.19264 8.577C6.03636 8.73328 5.94857 8.94524 5.94857 9.16626V14.1662C5.94857 14.3873 6.03636 14.5992 6.19264 14.7555C6.34892 14.9118 6.56089 14.9996 6.7819 14.9996ZM10.7045 14.7555C10.5482 14.9118 10.3363 14.9996 10.1152 14.9996C9.89422 14.9996 9.68226 14.9118 9.52598 14.7555C9.3697 14.5992 9.2819 14.3873 9.2819 14.1662V9.16626C9.2819 8.94524 9.3697 8.73328 9.52598 8.577C9.68226 8.42072 9.89422 8.33293 10.1152 8.33293C10.3363 8.33293 10.5482 8.42072 10.7045 8.577C10.8608 8.73328 10.9486 8.94524 10.9486 9.16626V14.1662C10.9486 14.3873 10.8608 14.5992 10.7045 14.7555Z",fill:"#F44336"})}),(0,a.jsxs)("p",{className:"font-IRANSansBold whitespace-nowrap",children:[" ","حذف از سبد خرید"]})]})})]})]})]},e.asin))})})]})},u=function(){let e=(0,l.I0)(),s=(0,n.useRouter)(),t=(0,i.Z)(),u=(0,l.v9)(o.Zr),f=(0,l.v9)(o.TM),j=(0,l.v9)(o.hG),v=(0,l.v9)(o.vf),g=(0,l.v9)(r.lw),N=(0,l.v9)(r.p5),[w,b]=(0,c.useState)(!1),[C,k]=(0,c.useState)(!1),[S,y]=(0,c.useState)(!1),[A,B]=(0,c.useState)(),[I,R]=(0,c.useState)(""),[H,Z]=(0,c.useState)(""),[L,M]=(0,c.useState)(""),[_,V]=(0,c.useState)(!1),[E,T]=(0,c.useState)(!1),[D,F]=(0,c.useState)(!1),z=()=>{fetch("https://api.ipify.org/?format=json",{method:"GET"}).then(e=>e.json()).then(e=>{Z(e.ip)}).catch(e=>console.error(e))};function O(){if(g){if(u.map(e=>e.count).includes(0))d.Am.error("ابتدا محصول با تعداد صفر را از سبد خود حذف کنید.");else{var s;let t=null===(s=JSON)||void 0===s?void 0:s.parse(JSON.parse(localStorage.getItem("persist:root")).creditsBasket).cart;setTimeout(()=>{e((0,o.Fo)(t))},500),setTimeout(()=>{y(!0)},1e3)}}else d.Am.error("ابتدا وارد شوید")}function W(){if(g){if(A){b(!0);let c=localStorage.getItem("token");var t=new Headers;t.append("Accept","application/json"),t.append("Authorization","Bearer ".concat(c));var n=new FormData;n.append("address_id",A),n.append("description",I),n.append("totalprice",f),n.append("ip",H);for(let e=0;e<u.length;e++)n.append("cart[".concat(e,"][id]"),u[e].id),n.append("cart[".concat(e,"][slug]"),u[e].slug),n.append("cart[".concat(e,"][image]"),u[e].image),n.append("cart[".concat(e,"][name]"),u[e].name),n.append("cart[".concat(e,"][count]"),u[e].count),n.append("cart[".concat(e,"][price]"),u[e].singleitemfullprice),n.append("cart[".concat(e,"][weight]"),u[e].weight),n.append("cart[".concat(e,"][category_id]"),u[e].category_id);fetch("".concat("https://app.charsooq.com/api/v1/","tara-store"),{method:"POST",headers:t,body:n}).then(e=>e.json()).then(t=>{200===t.status&&(d.Am.success("در حال انتقال شما به درگاه، لطفا کمی صبر کنید."),e((0,o.z$)([])),s.push(t.data.link_gateway)),401===t.status&&h.Am.custom(e=>(0,a.jsxs)("div",{className:"".concat(e.visible?"animate-enter":"animate-leave"," max-w-md w-full bg-white shadow-lg rounded-lg pointer-events-auto flex ring-1 ring-black ring-opacity-5"),children:[(0,a.jsx)("div",{className:"flex-1 w-0 p-4",children:(0,a.jsxs)("div",{className:"flex items-start",children:[(0,a.jsx)("div",{className:"flex-shrink-0 pt-0.5",children:(0,a.jsx)("img",{className:"h-10 w-10 rounded-full",src:"/assets/images/icons/logo2.png",alt:""})}),(0,a.jsxs)("div",{className:"ml-3 flex-1",children:[(0,a.jsx)("p",{className:"text-sm font-IRANSansBold",children:"کاربر گرامی!"}),(0,a.jsx)("p",{className:"mt-1 text-sm",children:t.message})]})]})}),(0,a.jsx)("div",{className:"flex border-l border-gray-200",children:(0,a.jsx)(x.default,{href:"/dashboard/profile?callbackRoute=checkout",onClick:()=>{d.Am.dismiss(e.id)},className:"text-sm text-[var(--base-blue)] font-IRANSansBold underline ml-4 flex items-center justify-center",children:"برو به پروفایل"})})]})),422===t.status&&d.Am.error(t.message),403===t.status&&(d.Am.error(t.message),location.reload())}).catch(e=>console.log("error",e)).finally(()=>b(!1))}else d.Am.error("یک آدرس انتخاب کنید")}else d.Am.error("ابتدا وارد شوید")}return((0,c.useEffect)(()=>{z()},[]),(0,c.useEffect)(()=>{window.scrollTo({top:0,left:0,behavior:"smooth"})},[S]),0===u.length)?(0,a.jsxs)("div",{className:"flex flex-col gap-[20px] items-center justify-center m-auto",children:[(0,a.jsx)("img",{src:"/assets/images/icons/ghost-404.png",alt:""}),(0,a.jsx)("p",{children:" سبد اقساطی شما خالی می باشد."})]}):(0,a.jsxs)("div",{className:"flex flex-col md:flex-row bg-white rounded-2xl shadow-lg",children:[S?(0,a.jsx)(p.Z,{setChooseAddress:B,setShowAddress:y,chooseAddress:A,amazonCart:u,descInput:I,setDescInput:R,userAddress:N,checkout:"credits",setDiscountInput:M,setShowDiscountInput:V,setDiscountCodeError:T,setDiscountCheck:F}):(0,a.jsx)(m,{creditsCart:u,removeItemFromBasket:function(s){e((0,o.Ew)({id:s}))}}),(0,a.jsx)("div",{className:"checkout-content-single-payments",children:(0,a.jsxs)("div",{className:"product-invoice-container sticky top-[140px]",children:[(0,a.jsx)("div",{className:"product-invoice-content-top",children:(0,a.jsxs)("div",{className:"flex flex-col gap-[10px] px-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("p",{className:"font-IRANSansBold",children:["قیمت کل",(0,a.jsxs)("span",{className:"font-IRANSansBold",children:[" ","(",u.length,")"]})]}),(0,a.jsxs)("span",{className:"flex items-center gap-7 font-IRANSansBold",children:[C?(0,a.jsx)("span",{className:"dot-loader active"}):f.toLocaleString()," ","تومان"]})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between text-[14px] text-[var(--text-gray)]",children:[(0,a.jsx)("p",{children:"قیمت کالاها"}),(0,a.jsxs)("span",{className:"flex items-center gap-7",children:[C?(0,a.jsx)("span",{className:"dot-loader active"}):j.toLocaleString()," ","تومان"]})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between text-[14px] text-[var(--text-gray)]",children:[(0,a.jsx)("p",{children:"هزینه ارسال"}),(0,a.jsxs)("span",{className:"flex items-center gap-7",children:[C?(0,a.jsx)("span",{className:"dot-loader active"}):v.toLocaleString()," ","تومان"]})]})]})}),(0,a.jsx)("div",{className:"product-invoice-content-bottom",children:(0,a.jsxs)("div",{className:"flex flex-col gap-[10px] px-2",children:[t?S?(0,a.jsxs)("div",{className:"flex flex-col bg-white border-t border-[var(--light-border)] fixed bottom-0 w-full right-0 h-28 z-20",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-6 pt-3",children:[(0,a.jsxs)("p",{className:"font-IRANSansBold",children:["قیمت کالا ها",(0,a.jsxs)("span",{className:"font-IRANSansBold",children:[" ","(",u.length,")"]})]}),(0,a.jsxs)("span",{className:"flex items-center gap-7 font-IRANSansBold",children:[C?(0,a.jsx)("span",{className:"dot-loader active"}):f.toLocaleString()," ","تومان"]})]}),(0,a.jsxs)("button",{onClick:W,className:"add-checkout-button",disabled:w,children:[w?(0,a.jsx)("span",{className:w?"button-loader-white active":"button-loader-white"}):null,(0,a.jsx)("p",{children:" ثبت و نهایی کردن سفارش"})]})]}):(0,a.jsxs)("div",{className:"flex flex-col bg-white border-t border-[var(--light-border)] fixed bottom-0 w-full right-0 h-28 z-20",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-6 pt-3",children:[(0,a.jsxs)("p",{className:"font-IRANSansBold",children:["قیمت کل",(0,a.jsxs)("span",{className:"font-IRANSansBold",children:[" ","(",u.length,")"]})]}),(0,a.jsxs)("span",{className:"flex items-center gap-7 font-IRANSansBold",children:[C?(0,a.jsx)("span",{className:"dot-loader active"}):f.toLocaleString()," ","تومان"]})]}),(0,a.jsx)("button",{onClick:O,className:"add-checkout-button",children:(0,a.jsx)("p",{children:"ادامه ثبت سفارش"})})]}):S?(0,a.jsxs)("button",{onClick:W,className:"add-checkout-button",disabled:w,children:[w?(0,a.jsx)("span",{className:w?"button-loader-white active":"button-loader-white"}):null,(0,a.jsx)("p",{children:" ثبت و نهایی کردن سفارش"})]}):(0,a.jsx)("button",{onClick:O,className:"add-checkout-button",children:(0,a.jsx)("p",{children:"ادامه ثبت سفارش"})}),(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)(x.default,{href:"/help?tab=credit",className:"text-sm underline text-[var(--base-blue)] font-IRANSansBold",children:"راهنمای خرید اقساطی از چارسوق"})})]})})]})})]})}}}]);