File manager - Edit - /home/webapp69.cm.in.th/u69319090023/Shop23/_next/static/chunks/30hm22smfu14-.js
Back
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,69439,e=>{"use strict";var t=e.i(43476),s=e.i(71645),a=e.i(22016),r=e.i(57688),l=e.i(84026),n=e.i(70387),c=e.i(29210),i=e.i(67363),o=e.i(51757),d=e.i(8734),x=e.i(63448),m=e.i(55677),u=e.i(20865),h=e.i(32781),p=e.i(57657),g=e.i(63676),f=e.i(80799),b=e.i(82625),y=e.i(97923),j=e.i(6537),N=e.i(93123),v=e.i(96365),w=e.i(44779),S=e.i(86624),C=e.i(59544),k=e.i(39964),E=e.i(78344);function _({isOpen:e,onClose:a,onSelectAddress:r}){let l=(0,s.useRef)(null),[n,c]=(0,s.useState)("กำลังโหลดที่อยู่ตำแหน่งปัจจุบัน..."),[i,o]=(0,s.useState)(""),[d,x]=(0,s.useState)(""),[m,p]=(0,s.useState)(!1),[f,b]=(0,s.useState)({lat:18.7883,lng:98.9853}),[y,j]=(0,s.useState)(!1);(0,s.useEffect)(()=>{if(!e)return;let t=document.createElement("link");t.rel="stylesheet",t.href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css",document.head.appendChild(t);let s=document.createElement("script");return s.src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js",s.async=!0,s.onload=()=>{navigator.geolocation?navigator.geolocation.getCurrentPosition(e=>{let t={lat:e.coords.latitude,lng:e.coords.longitude};b(t),N(t.lat,t.lng)},()=>{N(18.7883,98.9853)}):N(18.7883,98.9853)},document.body.appendChild(s),()=>{l.current&&(l.current.remove(),l.current=null);try{document.head.removeChild(t),document.body.removeChild(s)}catch(e){}j(!1)}},[e]);let N=(e,t)=>{let s=window.L;if(!s||l.current)return;let a=s.map("map-container",{zoomControl:!1}).setView([e,t],15);s.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{maxZoom:19,attribution:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'}).addTo(a),s.control.zoom({position:"topright"}).addTo(a),l.current=a,j(!0),v(e,t),a.on("moveend",()=>{let e=a.getCenter();b({lat:e.lat,lng:e.lng}),v(e.lat,e.lng)})},v=async(e,t)=>{p(!0),c("กำลังค้นหาที่อยู่จากจุดกึ่งกลางแผนที่...");try{let s=await fetch(`https://nominatim.openstreetmap.org/reverse?format=json&lat=${e}&lon=${t}&accept-language=th`),a=await s.json();if(a&&a.address){let e=a.address,t=e.house_number||"",s=e.road||"",r=e.subdistrict||e.suburb||e.village||e.neighbourhood||"",l=e.district||e.city_district||e.city||"",n=e.province||e.state||"",i=e.postcode||"",d="";if(t&&(d+=`บ้านเลขที่ ${t} `),s&&(d+=`ถนน${s} `),r&&(d+=`ตำบล/แขวง${r} `),l){let e=l.replace(/อำเภอ|เขต/g,"").trim();d+=`อำเภอ/เขต${e} `}c(d.trim()||a.display_name||"ไม่พบชื่อที่อยู่จากพิกัดนี้"),n?o(n.replace("จังหวัด","").trim()):o(""),i?x(i):x("")}else c(`พิกัด ละติจูด: ${e.toFixed(6)}, ลองจิจูด: ${t.toFixed(6)}`),o(""),x("")}catch(s){console.error(s),c(`พิกัด ละติจูด: ${e.toFixed(6)}, ลองจิจูด: ${t.toFixed(6)}`)}finally{p(!1)}};return e?(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60",children:(0,t.jsxs)("div",{className:"bg-white rounded-3xl w-full max-w-2xl overflow-hidden shadow-2xl flex flex-col h-[550px] md:h-[600px] border border-gray-100 text-left",children:[(0,t.jsxs)("div",{className:"p-4 border-b border-gray-100 flex justify-between items-center bg-gray-50/50",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)(u.MapPin,{className:"w-5 h-5 text-accent"}),(0,t.jsx)("h3",{className:"text-base font-bold text-gray-900",children:"เลือกตำแหน่งที่อยู่จัดส่ง"})]}),(0,t.jsx)("button",{type:"button",onClick:a,className:"p-1.5 hover:bg-gray-200/50 text-gray-400 hover:text-gray-700 rounded-full transition-colors","aria-label":"Close map",children:(0,t.jsx)(g.X,{className:"w-5 h-5"})})]}),(0,t.jsxs)("div",{className:"relative flex-1 bg-gray-100 min-h-[300px]",children:[(0,t.jsx)("div",{id:"map-container",className:"w-full h-full z-10"}),(0,t.jsxs)("div",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-full z-20 pointer-events-none flex flex-col items-center select-none",children:[(0,t.jsx)("div",{className:"w-3 h-3 bg-accent rounded-full border-2 border-white shadow-md animate-ping absolute top-0"}),(0,t.jsxs)("div",{className:"relative bottom-4 drop-shadow-[0_4px_6px_rgba(0,0,0,0.3)] animate-bounce duration-1000",children:[(0,t.jsx)(u.MapPin,{className:"w-10 h-10 text-accent fill-accent/10"}),(0,t.jsx)("div",{className:"absolute inset-0 flex items-center justify-center pb-2",children:(0,t.jsx)("div",{className:"w-2.5 h-2.5 bg-white rounded-full"})})]}),(0,t.jsx)("div",{className:"w-5 h-1.5 bg-black/25 rounded-full blur-[1px] -mt-4"})]}),(0,t.jsx)("button",{type:"button",onClick:()=>{navigator.geolocation&&l.current&&navigator.geolocation.getCurrentPosition(e=>{let t=e.coords.latitude,s=e.coords.longitude;l.current.setView([t,s],16)})},className:"absolute bottom-4 right-4 z-20 p-3 bg-white hover:bg-gray-50 text-gray-700 hover:text-accent rounded-full shadow-lg border border-gray-200/60 transition-all duration-200 hover:scale-105 active:scale-95 flex items-center justify-center",title:"ระบุตำแหน่งพิกัดอุปกรณ์ของคุณ",children:(0,t.jsx)(E.Navigation,{className:"w-5 h-5 fill-current"})}),!y&&(0,t.jsxs)("div",{className:"absolute inset-0 bg-white/80 z-30 flex flex-col items-center justify-center space-y-3",children:[(0,t.jsx)(h.Loader2,{className:"w-10 h-10 animate-spin text-accent"}),(0,t.jsx)("span",{className:"text-sm font-medium text-gray-600",children:"กำลังโหลดแผนที่..."})]})]}),(0,t.jsxs)("div",{className:"p-5 border-t border-gray-100 space-y-4 bg-white",children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("span",{className:"text-xs font-bold text-gray-400",children:"ตำแหน่งที่เลือกในขณะนี้:"}),(0,t.jsx)("div",{className:"text-xs text-gray-700 bg-gray-50 rounded-2xl p-3.5 border border-gray-100 min-h-[56px] flex items-center leading-relaxed",children:m?(0,t.jsxs)("div",{className:"flex items-center space-x-2 text-gray-400 font-light",children:[(0,t.jsx)(h.Loader2,{className:"w-3.5 h-3.5 animate-spin text-accent"}),(0,t.jsx)("span",{children:n})]}):(0,t.jsx)("span",{className:"font-light",children:n})})]}),(0,t.jsxs)("div",{className:"flex space-x-3 justify-end pt-1",children:[(0,t.jsx)("button",{type:"button",onClick:a,className:"px-5 py-2.5 bg-gray-100 hover:bg-gray-200/60 text-gray-700 rounded-xl text-sm font-semibold transition-all duration-200",children:"ยกเลิก"}),(0,t.jsx)("button",{type:"button",onClick:()=>{r(n,i,d),a()},disabled:m||!y,className:"px-5 py-2.5 bg-accent hover:bg-accent/90 disabled:bg-accent/50 text-white rounded-xl text-sm font-semibold transition-all duration-200 flex items-center space-x-2",children:(0,t.jsx)("span",{children:"ยืนยันตำแหน่งนี้"})})]})]})]})}):null}var T=e.i(5470),L=e.i(46932);e.s(["default",0,function(){let{cartItems:e,cartTotal:E,clearCart:$}=(0,N.default)(),M="en"===localStorage.getItem("lang"),[P,O]=(0,s.useState)(null),[F,I]=(0,s.useState)(!1);(0,s.useEffect)(()=>{O(w.default.getCurrentUser()),I(!0);let e=()=>{O(w.default.getCurrentUser())};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[]),(0,s.useEffect)(()=>{P&&S.default.getAddresses(P.id).then(e=>{if(e.success&&e.data.length>0){let t=e.data.find(e=>e.isDefault)||e.data[0];t&&(H(t.fullName),R(t.phone),A(t.address),J(t.province),V(t.postalCode))}})},[P]);let[z,H]=(0,s.useState)(""),[q,R]=(0,s.useState)(""),[U,A]=(0,s.useState)(""),[D,J]=(0,s.useState)(""),[W,V]=(0,s.useState)(""),[B,G]=(0,s.useState)("bank_transfer"),[K,X]=(0,s.useState)(!1),[Z,Q]=(0,s.useState)(""),[Y,ee]=(0,s.useState)(null),[et,es]=(0,s.useState)(!1),[ea,er]=(0,s.useState)(!1),[el,en]=(0,s.useState)(!1),[ec,ei]=(0,s.useState)(!1),[eo,ed]=(0,s.useState)(""),[ex,em]=(0,s.useState)(null),[eu,eh]=(0,s.useState)(""),[ep,eg]=(0,s.useState)(0),[ef,eb]=(0,s.useState)([]),ey=()=>{let e=localStorage.getItem("collected_coupons");if(e)try{eb(JSON.parse(e))}catch(e){console.error(e)}};(0,s.useEffect)(()=>(ey(),window.addEventListener("storage",ey),()=>window.removeEventListener("storage",ey)),[]);let ej=e=>e.merchantEmail?e.merchantEmail:e.departmentSlugs?.includes("automotive")||e.departmentSlugs?.includes("mechanical")?"mech_cap@cmtc.ac.th":e.departmentSlugs?.includes("electrical-power")||e.departmentSlugs?.includes("electronics")?"elec_shop@cmtc.ac.th":"cat_tshirt"===e.categoryId||"cat_accessories"===e.categoryId?"tshirt_club@cmtc.ac.th":"crest_shop@cmtc.ac.th",eN=E>1e3||0===E?0:50,ev=Math.max(0,E+eN-ep);(0,s.useEffect)(()=>{e.length},[e,Y]);let ew=async t=>{if(t.preventDefault(),Q(""),!w.default.getCurrentUser())return void Q("กรุณาเข้าสู่ระบบก่อนทำการสั่งซื้อ");if(!z||!q||!U||!D||!W)return void Q("กรุณากรอกข้อมูลที่อยู่จัดส่งให้ครบถ้วน");X(!0);try{let t=await v.default.createOrder(e,ev,{fullName:z,phone:q,address:U,province:D,postalCode:W},B);ee(t),$()}catch(e){Q(e?.message||"เกิดข้อผิดพลาดในการส่งคำสั่งซื้อ กรุณาลองใหม่อีกครั้ง")}finally{X(!1)}};return F&&!P?(0,t.jsxs)("div",{className:"mx-auto max-w-2xl px-4 pt-[120px] pb-16 text-center",children:[(0,t.jsx)(T.default,{currentStep:1,className:"mb-10"}),(0,t.jsxs)(k.default,{variant:"white",className:"p-8 border border-gray-150 shadow-luxury bg-white flex flex-col items-center max-w-xl mx-auto animate-in fade-in duration-300",children:[(0,t.jsx)("div",{className:"w-16 h-16 rounded-full bg-amber-50 text-amber-500 flex items-center justify-center mb-6 shadow-sm border border-amber-100",children:(0,t.jsx)(j.Lock,{className:"w-8 h-8"})}),(0,t.jsx)("h1",{className:"text-2xl font-bold text-gray-900 mb-2",children:"กรุณาเข้าสู่ระบบก่อนทำการสั่งซื้อ"}),(0,t.jsx)("p",{className:"text-sm text-gray-500 font-light mb-8 max-w-md",children:"เพื่อความปลอดภัยของข้อมูลและสิทธิประโยชน์ในการตรวจสอบสถานะติดตามพัสดุของคุณ กรุณาเข้าสู่ระบบบัญชีผู้ใช้ของคุณก่อนชำระเงิน"}),(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row gap-3 w-full justify-center",children:[(0,t.jsx)(a.default,{href:"/login?redirect=/checkout",passHref:!0,className:"w-full sm:w-auto",children:(0,t.jsxs)(C.default,{variant:"primary",className:"w-full py-3 px-8 flex items-center justify-center space-x-2",children:[(0,t.jsx)(y.LogIn,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:"เข้าสู่ระบบ"})]})}),(0,t.jsx)(a.default,{href:"/register?redirect=/checkout",passHref:!0,className:"w-full sm:w-auto",children:(0,t.jsx)(C.default,{variant:"secondary",className:"w-full py-3 px-8",children:"สมัครสมาชิกใหม่"})})]})]})]}):Y?(0,t.jsxs)("div",{className:"mx-auto max-w-2xl px-4 pt-[120px] pb-16 text-center",children:[(0,t.jsx)(T.default,{currentStep:3,className:"mb-10"}),(0,t.jsxs)(k.default,{variant:"white",className:"p-8 border border-gray-150 shadow-luxury bg-white flex flex-col items-center max-w-xl mx-auto",children:[(0,t.jsx)("div",{className:"w-16 h-16 rounded-full bg-emerald-50 text-emerald-500 flex items-center justify-center mb-6 shadow-sm",children:(0,t.jsx)(o.CheckCircle2,{className:"w-10 h-10"})}),(0,t.jsx)("h1",{className:"text-2xl font-bold text-gray-900 mb-2",children:"สั่งซื้อสินค้าเสร็จสมบูรณ์!"}),(0,t.jsx)("p",{className:"text-sm text-gray-500 font-light mb-6",children:"ทางวิทยาลัยได้รับรายการคำสั่งซื้อของคุณเรียบร้อยแล้ว เจ้าหน้าที่กำลังดำเนินการจัดเตรียมพัสดุ"}),(0,t.jsxs)("div",{className:"w-full bg-gray-50 rounded-2xl p-5 border border-gray-200/60 mb-8 text-left space-y-4",children:[(0,t.jsxs)("div",{className:"flex justify-between items-center pb-3 border-b border-gray-200",children:[(0,t.jsx)("span",{className:"text-xs text-gray-400 font-medium",children:"หมายเลขคำสั่งซื้อ"}),(0,t.jsx)("span",{className:"text-sm font-bold text-gray-800",children:Y.id})]}),(0,t.jsxs)("div",{className:"flex justify-between items-center pt-1",children:[(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)("span",{className:"text-[10px] text-gray-400 font-medium",children:"รหัสติดตามพัสดุ (ใช้ค้นหาสถานะ)"}),(0,t.jsx)("span",{className:"text-base font-bold text-accent tracking-wide mt-0.5",children:Y.trackingCode})]}),(0,t.jsxs)("button",{onClick:()=>{var e;return Y.trackingCode&&(e=Y.trackingCode,void(navigator?.clipboard&&(navigator.clipboard.writeText(e),es(!0),setTimeout(()=>es(!1),2e3))))},className:"flex items-center space-x-1 py-1.5 px-3 rounded-full border border-gray-200 text-[10px] font-semibold text-gray-600 hover:bg-gray-100 transition-colors",children:[(0,t.jsx)(d.Copy,{className:"w-3 h-3"}),(0,t.jsx)("span",{children:et?"คัดลอกแล้ว!":"คัดลอก"})]})]})]}),(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row gap-3 w-full justify-center",children:[(0,t.jsx)(a.default,{href:"/tracking",passHref:!0,className:"w-full sm:w-auto",children:(0,t.jsxs)(C.default,{variant:"primary",className:"w-full flex items-center justify-center space-x-2 py-3 px-6",children:[(0,t.jsx)(m.ClipboardList,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:"ตรวจสอบสถานะพัสดุ"})]})}),(0,t.jsx)(a.default,{href:"/products",passHref:!0,className:"w-full sm:w-auto",children:(0,t.jsx)(C.default,{variant:"secondary",className:"w-full py-3 px-6",children:"ช้อปปิ้งต่อ"})})]})]})]}):(0,t.jsxs)("div",{className:"mx-auto max-w-5xl px-4 sm:px-6 lg:px-8 pt-[120px] pb-10",children:[(0,t.jsx)(T.default,{currentStep:2,className:"mb-7"}),(0,t.jsxs)("div",{className:"text-center mb-12",children:[(0,t.jsx)("h1",{className:"text-3xl font-extrabold text-gray-900 tracking-tight",children:"ทำการสั่งซื้อ"}),(0,t.jsx)("p",{className:"mt-3 text-sm text-gray-500 font-light max-w-lg mx-auto",children:"กรอกข้อมูลปลายทางจัดส่งสินค้าและเลือกรูปแบบช่องทางชำระเงินที่ท่านต้องการ"})]}),e.length>0?(0,t.jsxs)("form",{onSubmit:ew,className:"grid grid-cols-1 lg:grid-cols-3 gap-8 text-left",children:[(0,t.jsxs)("div",{className:"lg:col-span-2 space-y-6",children:[(0,t.jsxs)(k.default,{variant:"white",className:"p-6 bg-white border border-gray-100 space-y-5",children:[(0,t.jsxs)("h2",{className:"text-base font-bold text-gray-900 pb-3 border-b border-gray-100 flex items-center space-x-2",children:[(0,t.jsx)("span",{className:"w-1.5 h-4 bg-accent rounded-full"}),(0,t.jsx)("span",{children:"ข้อมูลที่อยู่จัดส่ง"})]}),Z&&(0,t.jsx)("div",{className:"p-3 bg-red-50 text-red-600 text-xs font-semibold rounded-xl border border-red-100",children:Z}),(0,t.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{className:"flex flex-col space-y-1.5",children:[(0,t.jsx)("label",{htmlFor:"name-input",className:"text-xs font-bold text-gray-700",children:"ชื่อ-นามสกุล ผู้รับ"}),(0,t.jsx)("input",{id:"name-input",type:"text",required:!0,placeholder:"กรอกชื่อและนามสกุลจริง...",value:z,onChange:e=>H(e.target.value),className:"border border-gray-200 rounded-xl px-4 py-2.5 text-sm transition-all duration-250 ease-out hover:border-gray-350 focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent text-gray-800 placeholder-gray-400 focus:placeholder-gray-300"})]}),(0,t.jsxs)("div",{className:"flex flex-col space-y-1.5",children:[(0,t.jsx)("label",{htmlFor:"phone-input",className:"text-xs font-bold text-gray-700",children:"เบอร์โทรศัพท์ติดต่อ"}),(0,t.jsx)("input",{id:"phone-input",type:"tel",required:!0,placeholder:"กรอกเบอร์โทรศัพท์...",value:q,onChange:e=>R(e.target.value),className:"border border-gray-200 rounded-xl px-4 py-2.5 text-sm transition-all duration-250 ease-out hover:border-gray-350 focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent text-gray-800 placeholder-gray-400 focus:placeholder-gray-300"})]})]}),(0,t.jsxs)("div",{className:"flex flex-col space-y-1.5",children:[(0,t.jsxs)("label",{htmlFor:"address-input",className:"text-xs font-bold text-gray-700 flex items-center space-x-1.5",children:[(0,t.jsx)(u.MapPin,{className:"w-3.5 h-3.5 text-accent"}),(0,t.jsx)("span",{children:"ที่อยู่ (บ้านเลขที่, ถนน, ตำบล, อำเภอ)"})]}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("textarea",{id:"address-input",required:!0,rows:3,placeholder:ea?"กำลังระบุตำแหน่งจาก GPS ของคุณ...":"กรอกรายละเอียดที่อยู่จัดส่งพัสดุ...",value:U,onChange:e=>A(e.target.value),disabled:ea,className:"border border-gray-200 rounded-xl pl-10 pr-12 py-2.5 text-sm transition-all duration-250 ease-out hover:border-gray-350 focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent text-gray-800 placeholder-gray-400 focus:placeholder-gray-300 resize-none w-full disabled:bg-gray-50 disabled:text-gray-400"}),(0,t.jsx)("div",{className:"absolute left-3.5 top-3.5 text-gray-400 pointer-events-none",children:ea?(0,t.jsx)(h.Loader2,{className:"w-4 h-4 animate-spin text-accent"}):(0,t.jsx)(u.MapPin,{className:"w-4 h-4"})}),(0,t.jsx)("button",{type:"button",onClick:()=>en(!0),title:"เปิดแผนที่เพื่อเลือกตำแหน่งจัดส่ง",className:"absolute right-3.5 top-3 p-1.5 bg-gray-50 hover:bg-accent hover:text-white rounded-lg border border-gray-200/80 text-gray-500 hover:scale-105 active:scale-95 transition-all duration-250 ease-out flex items-center justify-center cursor-pointer",children:(0,t.jsx)(u.MapPin,{className:"w-3.5 h-3.5"})})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{className:"flex flex-col space-y-1.5",children:[(0,t.jsx)("label",{htmlFor:"province-input",className:"text-xs font-bold text-gray-700",children:"จังหวัด"}),(0,t.jsx)("input",{id:"province-input",type:"text",required:!0,placeholder:"จังหวัด...",value:D,onChange:e=>J(e.target.value),className:"border border-gray-200 rounded-xl px-4 py-2.5 text-sm transition-all duration-250 ease-out hover:border-gray-350 focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent text-gray-800 placeholder-gray-400 focus:placeholder-gray-300"})]}),(0,t.jsxs)("div",{className:"flex flex-col space-y-1.5",children:[(0,t.jsx)("label",{htmlFor:"postal-input",className:"text-xs font-bold text-gray-700",children:"รหัสไปรษณีย์"}),(0,t.jsx)("input",{id:"postal-input",type:"text",required:!0,placeholder:"รหัสไปรษณีย์...",value:W,onChange:e=>V(e.target.value),className:"border border-gray-200 rounded-xl px-4 py-2.5 text-sm transition-all duration-250 ease-out hover:border-gray-350 focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent text-gray-800 placeholder-gray-400 focus:placeholder-gray-300"})]})]})]}),(0,t.jsxs)(k.default,{variant:"white",className:"p-6 bg-white border border-gray-100 space-y-4",children:[(0,t.jsxs)("h2",{className:"text-base font-bold text-gray-900 pb-3 border-b border-gray-100 flex items-center space-x-2",children:[(0,t.jsx)("span",{className:"w-1.5 h-4 bg-accent rounded-full"}),(0,t.jsx)("span",{children:"ช่องทางชำระเงิน"})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[(0,t.jsxs)(L.motion.button,{whileHover:{y:-2},whileTap:{scale:.98},type:"button",onClick:()=>G("bank_transfer"),className:`flex flex-col items-center p-5 border rounded-2xl text-center space-y-3 transition-all duration-250 ease-out cursor-pointer focus:outline-none focus-visible:ring-2 focus-visible:ring-accent ${"bank_transfer"===B?"border-accent bg-accent/5 text-accent shadow-sm":"border-gray-200 text-gray-600 hover:bg-gray-50/80 hover:border-gray-300"}`,children:[(0,t.jsx)(c.Landmark,{className:"w-7 h-7"}),(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)("span",{className:"text-sm font-bold",children:"โอนเงินเข้าบัญชี"}),(0,t.jsx)("span",{className:"text-[10px] text-gray-400 font-light mt-0.5",children:"ชำระผ่านพร้อมเพย์/แอปธนาคาร"})]})]}),(0,t.jsxs)(L.motion.button,{whileHover:{y:-2},whileTap:{scale:.98},type:"button",onClick:()=>G("cod"),className:`flex flex-col items-center p-5 border rounded-2xl text-center space-y-3 transition-all duration-250 ease-out cursor-pointer focus:outline-none focus-visible:ring-2 focus-visible:ring-accent ${"cod"===B?"border-accent bg-accent/5 text-accent shadow-sm":"border-gray-200 text-gray-600 hover:bg-gray-50/80 hover:border-gray-300"}`,children:[(0,t.jsx)(i.Truck,{className:"w-7 h-7"}),(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)("span",{className:"text-sm font-bold",children:"เก็บเงินปลายทาง"}),(0,t.jsx)("span",{className:"text-[10px] text-gray-400 font-light mt-0.5",children:"ชำระเงินเมื่อได้รับสินค้า"})]})]}),(0,t.jsxs)(L.motion.button,{whileHover:{y:-2},whileTap:{scale:.98},type:"button",onClick:()=>G("credit_card"),className:`flex flex-col items-center p-5 border rounded-2xl text-center space-y-3 transition-all duration-250 ease-out cursor-pointer focus:outline-none focus-visible:ring-2 focus-visible:ring-accent ${"credit_card"===B?"border-accent bg-accent/5 text-accent shadow-sm":"border-gray-200 text-gray-600 hover:bg-gray-50/80 hover:border-gray-300"}`,children:[(0,t.jsx)(n.CreditCard,{className:"w-7 h-7"}),(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)("span",{className:"text-sm font-bold",children:"บัตรเครดิต/เดบิต"}),(0,t.jsx)("span",{className:"text-[10px] text-gray-400 font-light mt-0.5",children:"ชำระผ่านช่องทางบัตรวีซ่า/มาสเตอร์"})]})]})]})]})]}),(0,t.jsx)("div",{className:"lg:sticky lg:top-28 space-y-6",children:(0,t.jsxs)(k.default,{variant:"white",className:"p-6 bg-white border border-gray-100 flex flex-col space-y-5",children:[(0,t.jsx)("h2",{className:"font-bold text-gray-900 border-b border-gray-150 pb-3",children:"รายการสั่งซื้อ"}),(0,t.jsx)("div",{className:"divide-y divide-gray-100 max-h-[220px] overflow-y-auto pr-1",children:e.map(e=>{let s,a;return(0,t.jsxs)("div",{className:"group/item py-3 flex items-center space-x-3 text-sm",children:[(0,t.jsx)("div",{className:"relative w-12 h-12 rounded-lg bg-gray-50 p-1 flex-shrink-0 border border-gray-100 overflow-hidden",children:(0,t.jsx)(r.default,{src:e.product.images[0],alt:e.product.name,fill:!0,className:"object-contain transition-transform duration-300 group-hover/item:scale-[1.05]"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("h4",{className:"font-semibold text-gray-800 text-xs truncate leading-snug",children:e.product.name}),(0,t.jsxs)("span",{className:"text-[10px] text-gray-400 font-medium block mt-0.5",children:["ไซส์: ",e.selectedSize," × ",e.quantity]}),0===(a=((s=localStorage.getItem("ctc_products"))?JSON.parse(s):[]).filter(t=>e.product.relatedProductIds?.includes(t.id))).length?null:(0,t.jsxs)("div",{className:"mt-1.5 p-1.5 bg-emerald-50/60 border border-emerald-100/40 rounded-lg space-y-1",children:[(0,t.jsxs)("span",{className:"text-[8px] font-extrabold text-emerald-700 block uppercase tracking-wide flex items-center gap-0.5",children:["🎁 ",M?"Free Gift":"ของแถมฟรี"," (",e.quantity," ชิ้น)"]}),a.map(e=>(0,t.jsxs)("div",{className:"flex items-center space-x-1.5 text-[9px] text-gray-500",children:[(0,t.jsx)("div",{className:"relative w-4 h-4 rounded border border-emerald-100 bg-white overflow-hidden flex-shrink-0",children:(0,t.jsx)(r.default,{src:e.images[0]||"/u69319090023/Shop23/images/products/placeholder.jpg",alt:e.name,fill:!0,className:"object-contain p-0.5"})}),(0,t.jsx)("span",{className:"font-medium truncate flex-1",children:e.name})]},e.id))]})]}),(0,t.jsxs)("span",{className:"font-bold text-accent text-xs",children:["฿",(e.product.price*e.quantity).toLocaleString()]})]},`${e.product.id}-${e.selectedSize}`)})}),(0,t.jsxs)("div",{className:"border-t border-gray-150 pt-4 space-y-2.5 text-sm text-gray-600 font-light",children:[(0,t.jsxs)("div",{className:"flex justify-between items-center py-1",children:[(0,t.jsx)("span",{className:"text-gray-500",children:"ยอดรวมสินค้า"}),(0,t.jsxs)("span",{className:"font-semibold text-gray-800",children:["฿",E.toLocaleString()]})]}),(0,t.jsxs)("div",{className:"flex justify-between items-center py-1 border-t border-gray-100",children:[(0,t.jsx)("span",{className:"text-gray-500",children:"ค่าบริการจัดส่ง"}),0===eN?(0,t.jsx)("span",{className:"font-semibold text-emerald-600 text-xs bg-emerald-50 px-2 py-0.5 rounded-md",children:"จัดส่งฟรี"}):(0,t.jsxs)("span",{className:"font-semibold text-gray-800",children:["฿",eN]})]}),ex&&(0,t.jsxs)("div",{className:"flex justify-between items-center py-1 border-t border-gray-100 text-emerald-600 font-medium",children:[(0,t.jsxs)("span",{children:["ส่วนลดคูปอง (",ex,")"]}),(0,t.jsxs)("span",{children:["-฿",ep.toLocaleString()]})]})]}),(0,t.jsxs)("div",{className:"border-t border-gray-100 pt-4 space-y-2",children:[(0,t.jsx)("span",{className:"text-xs font-bold text-gray-700 block",children:"คูปองส่วนลดร้านค้า"}),ex?(0,t.jsxs)("div",{className:"bg-emerald-50 border border-emerald-100 rounded-2xl p-4 flex justify-between items-center text-xs text-emerald-800",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2.5",children:[(0,t.jsx)(p.Ticket,{className:"w-5 h-5 text-emerald-600"}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("span",{className:"font-bold text-gray-800 block",children:["คูปอง: ",ex]}),(0,t.jsxs)("span",{className:"block text-[10px] text-emerald-600 font-light mt-0.5",children:["ส่วนลดประหยัดไป ฿",ep]})]})]}),(0,t.jsxs)("div",{className:"flex space-x-2",children:[(0,t.jsx)(L.motion.button,{whileTap:{scale:.95},type:"button",onClick:()=>ei(!0),className:"text-[10px] font-bold text-accent hover:text-highlight bg-white border border-gray-150 px-2.5 py-1.5 rounded-lg transition-colors duration-250 cursor-pointer focus:outline-none focus-visible:ring-2 focus-visible:ring-accent",children:"เปลี่ยน"}),(0,t.jsx)(L.motion.button,{whileTap:{scale:.95},type:"button",onClick:()=>{em(null),eg(0),ed(""),eh("")},className:"text-[10px] font-bold text-red-500 hover:text-red-700 bg-white border border-red-100 px-2.5 py-1.5 rounded-lg transition-colors duration-250 cursor-pointer focus:outline-none focus-visible:ring-2 focus-visible:ring-red-500",children:"ยกเลิก"})]})]}):(0,t.jsxs)(L.motion.button,{whileTap:{scale:.99},type:"button",onClick:()=>ei(!0),className:"w-full flex items-center justify-between border border-gray-200 hover:border-accent hover:shadow-sm rounded-xl px-4 py-3 text-left text-xs text-gray-500 hover:text-gray-900 bg-white hover:bg-gray-50 active:scale-[0.99] transition-all duration-250 ease-out cursor-pointer focus:outline-none focus-visible:ring-2 focus-visible:ring-accent",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)(p.Ticket,{className:"w-4 h-4 text-gray-400"}),(0,t.jsx)("span",{className:"font-light",children:"เลือกคูปองส่วนลดที่ใช้งานได้..."})]}),ef.length>0&&(0,t.jsxs)("span",{className:"bg-accent/10 text-accent font-bold text-[9px] px-2 py-0.5 rounded-full",children:[ef.length," คูปอง"]})]})]}),(0,t.jsxs)("div",{className:"border-t border-gray-100 pt-4 flex justify-between font-bold text-gray-900 text-base",children:[(0,t.jsx)("span",{children:"ยอดชำระสุทธิ"}),(0,t.jsxs)("span",{className:"text-accent text-lg",children:["฿",ev.toLocaleString()]})]}),(0,t.jsx)("div",{className:"pt-4",children:(0,t.jsxs)(C.default,{type:"submit",variant:"primary",isLoading:K,className:"w-full py-3.5 flex items-center justify-center space-x-2",children:[(0,t.jsx)(l.ShieldCheck,{className:"w-5 h-5"}),(0,t.jsx)("span",{children:"ยืนยันการชำระเงิน"})]})})]})})]}):(0,t.jsxs)("div",{className:"bg-white border border-gray-100 p-16 rounded-premium text-center shadow-card-soft max-w-xl mx-auto flex flex-col items-center",children:[(0,t.jsx)("div",{className:"w-16 h-16 rounded-full bg-red-50 flex items-center justify-center text-accent mb-6",children:(0,t.jsx)(x.ShoppingBag,{className:"w-8 h-8"})}),(0,t.jsx)("h2",{className:"text-xl font-bold text-gray-800 mb-1",children:"ยังไม่มีสินค้าที่จะดำเนินการสั่งชำระเงิน"}),(0,t.jsx)("p",{className:"text-sm text-gray-500 font-light mb-8",children:"กรุณากลับไปเลือกชมสินค้าและเพิ่มลงในตะกร้าก่อนเข้าสู่หน้านี้"}),(0,t.jsx)(a.default,{href:"/products",passHref:!0,children:(0,t.jsx)(C.default,{variant:"primary",className:"px-8 py-3",children:"ไปหน้าร้านค้า"})})]}),(0,t.jsx)(_,{isOpen:el,onClose:()=>en(!1),onSelectAddress:(e,t,s)=>{A(e),t&&J(t),s&&V(s)}}),ec&&(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50",children:(0,t.jsxs)("div",{className:"bg-white rounded-3xl w-full max-w-md overflow-hidden shadow-2xl flex flex-col max-h-[520px] border border-gray-100 text-left",children:[(0,t.jsxs)("div",{className:"p-5 border-b border-gray-100 flex justify-between items-center bg-gray-50/50",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2 text-accent",children:[(0,t.jsx)(p.Ticket,{className:"w-5 h-5"}),(0,t.jsx)("h3",{className:"text-base font-bold text-gray-900",children:"เลือกคูปองส่วนลด"})]}),(0,t.jsx)("button",{type:"button",onClick:()=>ei(!1),className:"p-1.5 hover:bg-gray-200/50 text-gray-400 hover:text-gray-700 rounded-full transition-colors cursor-pointer",children:(0,t.jsx)(g.X,{className:"w-5 h-5"})})]}),(0,t.jsx)("div",{className:"p-5 overflow-y-auto space-y-4 bg-gray-50/50 flex-1",children:[{code:"CMTC50",title:"ส่วนลดพิเศษ CMTC",desc:"รับส่วนลด ฿50 ไม่มีขั้นต่ำ สำหรับคนรักเทคนิคเชียงใหม่ทุกคน",min:0,icon:(0,t.jsx)(f.Tag,{className:"w-5 h-5 text-accent"})},{code:"WELCOME100",title:"ต้อนรับเปิดเทอมใหม่",desc:"รับส่วนลด ฿100 เมื่อมียอดสั่งซื้อสินค้าตั้งแต่ ฿1,000 ขึ้นไป",min:1e3,icon:(0,t.jsx)(b.Gift,{className:"w-5 h-5 text-accent"})},{code:"FREESHIP",title:"จัดส่งฟรีทั่วประเทศ",desc:"ฟรีค่าจัดส่งพัสดุ เมื่อมียอดสั่งซื้อขั้นต่ำ ฿500 ขึ้นไป",min:500,icon:(0,t.jsx)(i.Truck,{className:"w-5 h-5 text-accent"})}].map(s=>{let a=ef.includes(s.code),r=E<s.min,l=ex===s.code;return(0,t.jsxs)("div",{className:`flex border rounded-2xl overflow-hidden shadow-sm transition-all duration-200 ${r?"opacity-65 border-gray-200/80 bg-gray-100/50":l?"border-emerald-200 ring-2 ring-emerald-500/20 bg-white":"border-gray-200/70 hover:border-accent bg-white"}`,children:[(0,t.jsxs)("div",{className:`w-16 flex flex-col items-center justify-center border-r-2 border-dashed border-gray-200/85 relative ${r?"bg-gray-250/20":"bg-accent/5"}`,children:[(0,t.jsx)("div",{className:"absolute -top-1.5 -right-1.5 w-3 h-3 bg-gray-50 rounded-full border border-gray-200/25 shadow-inner"}),(0,t.jsx)("div",{className:"absolute -bottom-1.5 -right-1.5 w-3 h-3 bg-gray-50 rounded-full border border-gray-200/25 shadow-inner"}),s.icon]}),(0,t.jsxs)("div",{className:"flex-1 p-3.5 flex items-center justify-between space-x-2",children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-1.5",children:[(0,t.jsx)("span",{className:`font-bold text-xs ${r?"text-gray-500":"text-gray-800"}`,children:s.title}),a&&(0,t.jsx)("span",{className:"bg-amber-50 text-amber-600 text-[8px] font-bold px-1.5 py-0.5 rounded border border-amber-100/60 flex-shrink-0",children:"เก็บแล้ว"})]}),(0,t.jsx)("span",{className:"text-[10px] text-gray-500 font-light block mt-0.5 leading-relaxed",children:s.desc}),(0,t.jsxs)("div",{className:"mt-2.5 flex items-center space-x-2",children:[(0,t.jsx)("span",{className:"bg-accent/5 border border-accent/20 px-2 py-0.5 rounded text-[9px] font-bold text-accent tracking-wider",children:s.code}),(0,t.jsx)("span",{className:"text-[9px] text-gray-400 font-light",children:s.min>0?`ขั้นต่ำ ฿${s.min.toLocaleString()}`:"ไม่มีขั้นต่ำ"})]})]}),(0,t.jsx)("div",{className:"flex-shrink-0",children:r?(0,t.jsx)("span",{className:"px-2.5 py-1.5 bg-gray-100 text-gray-400 rounded-xl text-[10px] font-semibold border border-gray-200/50 cursor-not-allowed",children:"ยอดไม่ถึง"}):l?(0,t.jsx)("div",{className:"flex flex-col items-center",children:(0,t.jsx)("span",{className:"px-2.5 py-1.5 bg-emerald-50 text-emerald-600 border border-emerald-100 rounded-xl text-[10px] font-bold flex items-center space-x-0.5",children:(0,t.jsx)("span",{children:"ใช้งานอยู่"})})}):(0,t.jsx)("button",{type:"button",onClick:()=>{(t=>{eh("");let s=t.toUpperCase().trim();if(!s)return eh("กรุณากรอกรหัสคูปอง");if(["CMTC50","WELCOME100","FREESHIP"].includes(s))return e.some(e=>{let t=ej(e.product);if(t){let e=localStorage.getItem(`store_settings_${t}`);if(e)return!0===JSON.parse(e).disallowSystemCoupons}return!1})?eh("คูปองระบบนี้ไม่สามารถใช้ร่วมกับสินค้าบางชิ้นในรถเข็นได้ (ร้านค้างดเข้าร่วมส่วนลดกลาง)"):"CMTC50"===s?(em("CMTC50"),eg(50)):"WELCOME100"===s?E>=1e3?(em("WELCOME100"),eg(100)):eh("ยอดสินค้าไม่ถึงขั้นต่ำ ฿1,000"):"FREESHIP"===s&&(E>=500?(em("FREESHIP"),eg(eN)):eh("ยอดสินค้าไม่ถึงขั้นต่ำ ฿500"));let a=null,r="",l="";for(let e of Object.keys(localStorage))if(e.startsWith("store_settings_")){let t=localStorage.getItem(e);if(t){let n=(JSON.parse(t).coupons||[]).find(e=>e.code.toUpperCase()===s);if(n){a=n,r=e.replace("store_settings_","");let t=localStorage.getItem("ctc_accounts"),s=(t?JSON.parse(t):[]).find(e=>e.email===r);l=s?s.fullName:"ร้านแผนก";break}}}if(a){if(!1===a.isActive)return eh("คูปองนี้ถูกปิดการใช้งานชั่วคราว");let t=e.filter(e=>ej(e.product)===r);if(0===t.length)return eh(`คูปองนี้ใช้ได้เฉพาะกับสินค้าจากร้าน "${l}" เท่านั้น`);let s=t.reduce((e,t)=>e+t.product.price*t.quantity,0),n=a.minSpend??a.minPurchase??0;if(s<n)return eh(`ยอดสั่งซื้อสินค้าจากร้าน "${l}" ต้องซื้อขั้นต่ำ ฿${n.toLocaleString()} จึงจะใช้คูปองนี้ได้ (ยอดปัจจุบัน ฿${s.toLocaleString()})`);let c=0;if("free_shipping"===a.type||"free_shipping"===a.discountType)c=eN;else if("percent"===a.discountType){let e=s*(a.discountValue||a.discount||0)/100;c=a.maxDiscount&&a.maxDiscount>0?Math.min(e,a.maxDiscount):e}else c=a.discountValue??a.discount??0;return em(a.code),eg(Math.round(c))}eh("รหัสคูปองไม่ถูกต้อง")})(s.code),ei(!1)},className:"px-3 py-1.5 bg-accent hover:bg-highlight text-white rounded-xl text-[10px] font-bold shadow-sm transition-all duration-150 cursor-pointer",children:"เลือกใช้"})})]})]},s.code)})}),(0,t.jsxs)("div",{className:"p-4 border-t border-gray-100 bg-gray-50 text-center flex justify-between items-center px-6",children:[(0,t.jsx)("span",{className:"text-[10px] text-gray-400 font-light",children:"* ใช้คูปองส่วนลดได้สูงสุด 1 ใบต่อออเดอร์"}),(0,t.jsx)("button",{type:"button",onClick:()=>ei(!1),className:"text-xs font-bold text-accent hover:underline cursor-pointer",children:"ปิด"})]})]})})]})}],69439)}]);
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.28 |
proxy
|
phpinfo
|
Settings