File manager - Edit - /home/webapp69.cm.in.th/u69319090023/Shop23/_next/static/chunks/0ifag6im3r5d5.js
Back
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,72906,e=>{"use strict";var t=e.i(43476),s=e.i(71645),r=e.i(22016),a=e.i(57688),l=e.i(18566),n=e.i(49817),c=e.i(56420);let d=(0,c.default)("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]);var o=e.i(13285),i=e.i(63448),x=e.i(67363);let m=(0,c.default)("trending-up",[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]]);var h=e.i(66794),b=e.i(67784),p=e.i(66595),g=e.i(93583),u=e.i(70812),f=e.i(16327),y=e.i(47925),j=e.i(75183),N=e.i(26909);let v=(0,c.default)("circle-dot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);var w=e.i(89664),k=e.i(63676),A=e.i(2773),S=e.i(77071),C=e.i(24071),L=e.i(67927);let E=(0,c.default)("chevrons-left",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]),F=(0,c.default)("chevrons-right",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);var $=e.i(29210),_=e.i(26091),I=e.i(25981),P=e.i(44779),O=e.i(23067),D=e.i(59544),T=e.i(94164),B=e.i(35034),M=e.i(30801);e.s(["default",0,function(){let e,c,J,R,q,z,U,X,H,G,W,K,V,Z,Q,Y=(0,l.useRouter)(),[ee,et]=(0,s.useState)(null),[es,er]=(0,s.useState)(!1),[ea,el]=(0,s.useState)("dashboard"),[en,ec]=(0,s.useState)(!1),[ed,eo]=(0,s.useState)(!1),[ei,ex]=(0,s.useState)(""),[em,eh]=(0,s.useState)([]),[eb,ep]=(0,s.useState)(!1),[eg,eu]=(0,s.useState)(!0),[ef,ey]=(0,s.useState)(!0),[ej,eN]=(0,s.useState)(!0),[ev,ew]=(0,s.useState)(!0),ek=e=>{el(e),sessionStorage.setItem("admin_active_tab",e)},[eA,eS]=(0,s.useState)([{id:1,name:"สมชาย รักเรียน",email:"student1@cmtc.ac.th",role:"นักศึกษา",date:"15/7/2569",phone:"0823456789"},{id:2,name:"สมหญิง เก่งกาจ",email:"technician2@cmtc.ac.th",role:"บุคลากร",date:"17/7/2569",phone:"0834567890"}]),[eC,eL]=(0,s.useState)([]),[eE,eF]=(0,s.useState)([{id:201,name:"STUDENT1",email:"student1@cmtc.ac.th",role:"นักศึกษา",date:"10/7/2569",phone:"0823456789"},{id:202,name:"TECHNICIAN2",email:"technician2@cmtc.ac.th",role:"บุคลากร",date:"12/7/2569",phone:"0834567890"},{id:203,name:"USER3",email:"user3@cmtc.ac.th",role:"นักศึกษา",date:"14/7/2569",phone:"0845678901"},{id:204,name:"MEMBER4",email:"member4@cmtc.ac.th",role:"ทั่วไป",date:"16/7/2569",phone:"0899999999"}]),[e$,e_]=(0,s.useState)([]),[eI,eP]=(0,s.useState)([]),[eO,eD]=(0,s.useState)(!1),[eT,eB]=(0,s.useState)(!1),[eM,eJ]=(0,s.useState)(null),[eR,eq]=(0,s.useState)(""),[ez,eU]=(0,s.useState)(""),[eX,eH]=(0,s.useState)("shirt"),[eG,eW]=(0,s.useState)("เสื้อผ้าและเครื่องแบบ"),[eK,eV]=(0,s.useState)([]),[eZ,eQ]=(0,s.useState)(!1),[eY,e0]=(0,s.useState)(null),[e5,e1]=(0,s.useState)([]),[e2,e4]=(0,s.useState)(""),[e3,e8]=(0,s.useState)(null),[e9,e6]=(0,s.useState)(!1),[e7,te]=(0,s.useState)("2026-07-26"),[tt,ts]=(0,s.useState)("requests"),[tr,ta]=(0,s.useState)(!1),[tl,tn]=(0,s.useState)(""),[tc,td]=(0,s.useState)(""),[to,ti]=(0,s.useState)("🛍️"),[tx,tm]=(0,s.useState)(null),[th,tb]=(0,s.useState)(B.default.getDefaultSettings()),[tp,tg]=(0,s.useState)(!0),[tu,tf]=(0,s.useState)(5),[ty,tj]=(0,s.useState)(!0),[tN,tv]=(0,s.useState)(2e4),[tw,tk]=(0,s.useState)(8),[tA,tS]=(0,s.useState)([]),[tC,tL]=(0,s.useState)(null),[tE,tF]=(0,s.useState)(null),[t$,t_]=(0,s.useState)(""),[tI,tP]=(0,s.useState)(""),[tO,tD]=(0,s.useState)(""),[tT,tB]=(0,s.useState)(""),[tM,tJ]=(0,s.useState)(null),tR=()=>{tS(M.default.getAllPayoutRequests())},tq=async e=>{let t=e.target.files?.[0];if(!t)return;if(!t.type.startsWith("image/"))return void tU("กรุณาเลือกไฟล์รูปภาพเท่านั้น","error");let s=new FileReader;s.onload=e=>{t_(e.target?.result)},s.readAsDataURL(t)},tz=e=>{ts(e),sessionStorage.setItem("admin_mgmt_sub_tab",e)};(0,s.useEffect)(()=>{{let e=sessionStorage.getItem("admin_active_tab");e&&el(e);let t=sessionStorage.getItem("admin_mgmt_sub_tab");t&&ts(t)}tR();let e=B.default.getCommissionSettings();tb(e),tg(e.enabled),tf(e.baseRatePercent),tj(e.isTieredEnabled),tv(e.tierThresholdAmount),tk(e.tierRatePercent);let t=()=>{tR();let e=B.default.getCommissionSettings();tb(e),tg(e.enabled),tf(e.baseRatePercent),tj(e.isTieredEnabled),tv(e.tierThresholdAmount),tk(e.tierRatePercent)};return window.addEventListener("commissionChange",t),window.addEventListener("storage",t),()=>{window.removeEventListener("commissionChange",t),window.removeEventListener("storage",t)}},[]);(0,s.useEffect)(()=>{let e=P.default.getCurrentUser();e&&"admin"===e.role?(et(e),er(!0)):Y.push("/login?redirect=/admin")},[Y]),(0,s.useEffect)(()=>{localStorage.getItem("ctc_accounts")||localStorage.setItem("ctc_accounts",JSON.stringify([{id:"usr_admin",email:"admin@cmtc.ac.th",fullName:"ผู้ดูแลระบบส่วนกลาง (Admin)",role:"admin",status:"approved",date:"01/07/2569",phone:"0812345678"}]));let e=()=>{let e=localStorage.getItem("ctc_accounts"),t=e?JSON.parse(e):[],s=t.filter(e=>!["usr_store1","usr_store2","usr_store3","usr_store5","usr_store6"].includes(e.id));s.length!==t.length&&(t=s,localStorage.setItem("ctc_accounts",JSON.stringify(t))),eS(t.filter(e=>"pending"===e.status).map(e=>({id:e.id,name:e.fullName,email:e.email,role:"merchant"===e.role?"ร้านค้า (Merchant)":e.email.toLowerCase().includes("technician")?"บุคลากร":"นักศึกษา",date:e.date||"15/7/2569",phone:e.phone||"-"}))),eF(t.filter(e=>"customer"===e.role&&"approved"===e.status).map(e=>({id:e.id,name:e.fullName,email:e.email,role:e.email.toLowerCase().includes("technician")?"บุคลากร":"นักศึกษา",date:e.date||"10/7/2569",phone:e.phone||"-"}))),eL(t.filter(e=>"merchant"===e.role&&"approved"===e.status).map(e=>({id:e.id,logo:e.logo||"🛍️",name:e.fullName,email:e.email,type:"ร้านค้าทางการ",date:e.date||"10/7/2569",phone:e.phone||"-"})));let r=localStorage.getItem("ctc_orders"),a=r?JSON.parse(r):[],l=a.filter(e=>{var t;return e&&e.id&&!((t=e.id)&&(t.startsWith("CMTC-8849")||t.startsWith("CMTC-202")))});l.length!==a.length&&(a=l,localStorage.setItem("ctc_orders",JSON.stringify(a))),eh(a),localStorage.getItem("ctc_categories")||localStorage.setItem("ctc_categories",JSON.stringify([{id:"cat_tshirt",name:"เสื้อยืด",slug:"t-shirts",subtext:"เสื้อยืดคอกลม, ลายมินิมอล, ผ้าฝ้าย Cotton",icon:"shirt",active:!0,parentCategory:"เสื้อผ้าและเครื่องแบบ"},{id:"cat_polo",name:"เสื้อโปโล",slug:"polo-shirts",subtext:"เสื้อโปโลปักตราวิทยาลัย, ผ้าลายจุติ",icon:"polo",active:!0,parentCategory:"เสื้อผ้าและเครื่องแบบ"},{id:"cat_hoodie",name:"เสื้อฮู้ดดี้",slug:"hoodies",subtext:"เสื้อกันหนาวมีฮู้ด, แขนยาวบุสำลีพรีเมียม",icon:"hoodie",active:!0,parentCategory:"เสื้อผ้าและเครื่องแบบ"},{id:"cat_jacket",name:"เสื้อแจ็คเก็ต & เสื้อช็อป",slug:"jackets",subtext:"เสื้อช็อปฝึกงาน, ช่างยนต์, ช่างไฟฟ้า",icon:"jacket",active:!0,parentCategory:"เสื้อผ้าและเครื่องแบบ"},{id:"cat_accessories",name:"อุปกรณ์เสริม",slug:"accessories",subtext:"หมวกแก๊ป, กระเป๋าเป้, ตราวิทยาลัย",icon:"accessories",active:!0,parentCategory:"อุปกรณ์เสริมและอื่นๆ"}]));let n=localStorage.getItem("ctc_categories");e_(n?JSON.parse(n):[]),O.default.getProducts().then(e=>{eV(e)});let c=localStorage.getItem("ctc_category_suggestions");eP(c?JSON.parse(c):[])};return e(),window.addEventListener("storage",e),()=>{window.removeEventListener("storage",e)}},[]);let tU=(e,t="success")=>{tm({text:e,type:t}),setTimeout(()=>{tm(null)},3e3)},tX=()=>{P.default.logout(),Y.push("/login")},tH=(e,t)=>{let s=localStorage.getItem("ctc_orders"),r=(s?JSON.parse(s):[]).map(s=>s.id===e?{...s,status:t}:s);localStorage.setItem("ctc_orders",JSON.stringify(r)),window.dispatchEvent(new Event("storage")),e3&&e3.id===e&&e8({...e3,status:t}),tU(`อัปเดตสถานะคำสั่งซื้อ ${e} เรียบร้อยแล้ว`,"success")};return es&&ee?(0,t.jsxs)("div",{className:"h-screen w-screen bg-[#FAF8F5] flex flex-col font-sans relative overflow-hidden",children:[tx&&(0,t.jsx)("div",{className:"fixed top-6 right-6 z-50 animate-in fade-in slide-in-from-top-4 duration-300",children:(0,t.jsxs)("div",{className:`px-5 py-3.5 rounded-2xl shadow-luxury border flex items-center space-x-3 text-xs font-bold ${"success"===tx.type?"bg-emerald-50 text-emerald-700 border-emerald-100":"error"===tx.type?"bg-red-50 text-red-700 border-red-100":"bg-amber-50 text-amber-700 border-amber-100"}`,children:[(0,t.jsx)(v,{className:"w-4 h-4 animate-pulse"}),(0,t.jsx)("span",{children:tx.text})]})}),(0,t.jsxs)("header",{className:"h-20 bg-white border-b border-[#F3F1ED] flex items-center px-6 justify-between shadow-xs flex-shrink-0 z-40",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2.5 sm:space-x-3",children:[(0,t.jsx)("button",{type:"button",onClick:()=>ep(!0),className:"md:hidden p-1.5 text-gray-600 hover:text-gray-900 hover:bg-gray-50 rounded-xl transition-all cursor-pointer border-none bg-transparent","aria-label":"เปิดเมนูนำทาง",children:(0,t.jsx)(g.Menu,{className:"w-5.5 h-5.5"})}),(0,t.jsx)("div",{className:"relative w-9 h-9 sm:w-11 sm:h-11",children:(0,t.jsx)(a.default,{src:"/logo_crest.png",alt:"Chiangmai Technical College Logo",fill:!0,priority:!0,className:"object-contain"})}),(0,t.jsxs)("div",{className:"flex flex-col text-left",children:[(0,t.jsx)("span",{className:"text-base sm:text-lg font-black text-[#800A0A] tracking-wider leading-none",children:"CMTC SHOP"}),(0,t.jsx)("span",{className:"text-[8px] text-gray-400 font-bold tracking-widest leading-none mt-1",children:"CHIANGMAI TECHNICAL COLLEGE"})]})]}),(0,t.jsxs)("div",{className:"hidden md:flex items-center relative w-96",children:[(0,t.jsx)(p.Search,{className:"w-4 h-4 text-gray-400 absolute left-4 pointer-events-none"}),(0,t.jsx)("input",{type:"text",placeholder:"ค้นหาข้อมูล (ลูกค้า, คำสั่งซื้อ, สินค้า)...",value:ei,onChange:e=>ex(e.target.value),className:"w-full bg-[#FAF8F5] hover:bg-gray-50/50 border border-gray-200/80 rounded-full py-2 pl-11 pr-4 text-xs focus:outline-none focus:ring-2 focus:ring-[#800A0A]/10 focus:border-[#800A0A] text-gray-800 transition-all placeholder-gray-400 font-medium"})]}),(0,t.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,t.jsx)("div",{className:"relative",children:(e=eA.length,c=em.filter(e=>"pending"===e.status).length,J=eI.filter(e=>"pending"===e.status),R=tA.filter(e=>"pending"===e.status).length,q=e+c+J.length+R,(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("button",{onClick:()=>{eo(!ed),ec(!1)},className:"p-2.5 bg-gray-50 hover:bg-gray-100/80 text-gray-600 hover:text-gray-900 border border-gray-200/60 rounded-full transition-all focus:outline-none relative cursor-pointer flex items-center justify-center","aria-label":"การแจ้งเตือน",children:[(0,t.jsx)(u.Bell,{className:"w-5 h-5"}),q>0&&(0,t.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-4 h-4 bg-[#B91C1C] text-white text-[9px] font-black rounded-full flex items-center justify-center border-2 border-white",children:q})]}),ed&&(0,t.jsxs)("div",{className:"absolute right-0 mt-2.5 w-72 bg-white border border-gray-150 rounded-2xl shadow-luxury p-3 text-left space-y-2.5 z-50",children:[(0,t.jsx)("h5",{className:"font-extrabold text-gray-800 text-xs px-1 border-b border-gray-100 pb-2",children:"การแจ้งเตือนล่าสุด"}),(0,t.jsx)("div",{className:"space-y-2 text-[11px] text-gray-600 max-h-56 overflow-y-auto",children:q>0?(0,t.jsxs)(t.Fragment,{children:[R>0&&(0,t.jsxs)("button",{type:"button",onClick:()=>{ek("payouts"),eo(!1)},className:"w-full text-left p-2 hover:bg-emerald-50/50 rounded-lg border-l-2 border-emerald-500 bg-emerald-50/30 cursor-pointer transition-colors block",children:[(0,t.jsx)("span",{className:"font-bold text-emerald-900 block",children:"💸 คำขอถอนเงินรออนุมัติ"}),(0,t.jsxs)("span",{className:"font-medium text-emerald-700 block mt-0.5",children:["มี ",R," คำขอถอนเงินจากร้านค้า"]})]}),J.length>0&&(0,t.jsxs)("button",{type:"button",onClick:()=>{ek("categories"),eo(!1)},className:"w-full text-left p-2 hover:bg-amber-50/50 rounded-lg border-l-2 border-amber-500 bg-amber-50/30 cursor-pointer transition-colors block",children:[(0,t.jsx)("span",{className:"font-bold text-amber-900 block",children:"💡 ข้อเสนอแนะหมวดหมู่ใหม่"}),(0,t.jsxs)("span",{className:"font-medium text-amber-700 block mt-0.5",children:["มี ",J.length," คำขอเสนอหมวดหมู่จากร้านค้า"]})]}),e>0&&(0,t.jsxs)("button",{type:"button",onClick:()=>{ek("users"),tz("requests"),eo(!1)},className:"w-full text-left p-2 hover:bg-gray-50 rounded-lg border-l-2 border-[#800A0A] bg-red-50/30 cursor-pointer transition-colors block",children:[(0,t.jsx)("span",{className:"font-bold text-gray-800 block",children:"คำร้องขอเปิดร้านค้าใหม่"}),(0,t.jsxs)("span",{className:"font-medium text-red-650 block mt-0.5",children:["มี ",e," คำขอที่รอการอนุมัติ"]})]}),c>0&&(0,t.jsxs)("button",{type:"button",onClick:()=>{ek("orders"),eo(!1)},className:"w-full text-left p-2 hover:bg-gray-50 rounded-lg border-l-2 border-blue-500 bg-blue-50/30 cursor-pointer transition-colors block",children:[(0,t.jsx)("span",{className:"font-bold text-gray-800 block",children:"คำสั่งซื้อรอดำเนินการ"}),(0,t.jsxs)("span",{className:"font-light text-gray-500 block mt-0.5",children:["มี ",c," รายการใหม่ที่รอการตรวจสอบ"]})]})]}):(0,t.jsxs)("div",{className:"py-6 text-center space-y-1.5 bg-gray-50/50 rounded-xl border border-gray-100",children:[(0,t.jsx)("span",{className:"text-xl block",children:"🔔"}),(0,t.jsx)("span",{className:"font-bold text-gray-700 text-xs block",children:"ไม่มีการแจ้งเตือนใหม่"}),(0,t.jsx)("span",{className:"text-[10px] text-gray-400 block px-2",children:"เมื่อมีคำร้องเปิดร้านค้า คำขอถอนเงิน หรือคำสั่งซื้อใหม่จะแจ้งเตือนที่นี่"})]})})]})]}))}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsxs)("button",{onClick:()=>{ec(!en),eo(!1)},className:"flex items-center space-x-3 px-3 py-1.5 border border-[#800A0A] rounded-2xl hover:bg-gray-50 transition-all focus:outline-none bg-white text-left shadow-xs cursor-pointer",children:[(0,t.jsx)("div",{className:"relative w-8 h-8 rounded-full overflow-hidden border border-gray-100 bg-gray-50",children:(0,t.jsx)(a.default,{src:"/admin_avatar.png",alt:"Admin User Profile Avatar",fill:!0,className:"object-cover"})}),(0,t.jsxs)("div",{className:"hidden sm:flex flex-col justify-center",children:[(0,t.jsx)("span",{className:"text-xs font-extrabold text-gray-900 leading-none",children:"ยินดีต้อนรับ, แอดมิน"}),(0,t.jsx)("span",{className:"text-[9px] text-gray-400 font-medium leading-none mt-1",children:"admin@cmtc.ac.th"})]}),(0,t.jsx)(f.ChevronDown,{className:"w-3.5 h-3.5 text-gray-400"})]}),en&&(0,t.jsxs)("div",{className:"absolute right-0 mt-2 w-56 bg-white border border-gray-150 rounded-2xl shadow-luxury overflow-hidden z-50 animate-in fade-in zoom-in-95 duration-150",children:[(0,t.jsxs)("div",{className:"px-4 py-3 border-b border-gray-100 text-xs bg-gray-50/50",children:[(0,t.jsx)("span",{className:"font-bold text-gray-800 block",children:"ผู้ดูแลระบบ (Admin)"}),(0,t.jsx)("span",{className:"text-gray-400 text-[10px] block mt-0.5",children:"admin@cmtc.ac.th"})]}),(0,t.jsxs)("div",{className:"p-1 space-y-0.5",children:[(0,t.jsxs)(r.default,{href:"/",onClick:()=>ec(!1),className:"w-full flex items-center space-x-2.5 px-3 py-2 hover:bg-gray-50 text-gray-700 hover:text-gray-950 text-xs font-bold text-left rounded-xl transition-colors",children:[(0,t.jsx)(N.ArrowLeftRight,{className:"w-3.5 h-3.5 text-[#800A0A]"}),(0,t.jsx)("span",{children:"สลับไปหน้าผู้ซื้อ (Buyer Mode)"})]}),(0,t.jsxs)(r.default,{href:"/merchant",onClick:()=>ec(!1),className:"w-full flex items-center space-x-2.5 px-3 py-2 hover:bg-gray-50 text-gray-700 hover:text-gray-950 text-xs font-bold text-left rounded-xl transition-colors",children:[(0,t.jsx)(j.Store,{className:"w-3.5 h-3.5 text-emerald-600"}),(0,t.jsx)("span",{children:"สลับไปหน้าร้านค้า (Merchant)"})]})]}),(0,t.jsx)("div",{className:"border-t border-gray-100 p-1",children:(0,t.jsxs)("button",{onClick:tX,className:"w-full flex items-center space-x-2.5 px-3 py-2 hover:bg-red-50 text-red-600 hover:text-red-700 text-xs font-bold text-left rounded-xl transition-colors border-none bg-transparent cursor-pointer",children:[(0,t.jsx)(b.LogOut,{className:"w-3.5 h-3.5"}),(0,t.jsx)("span",{children:"ออกจากระบบ"})]})})]})]})]})]}),(0,t.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,t.jsxs)("aside",{className:"hidden md:flex w-64 bg-white border-r border-[#F3F1ED] flex-col justify-between p-4 flex-shrink-0 z-30 font-prompt",children:[(0,t.jsx)("div",{className:"space-y-1",children:[{id:"dashboard",label:"หน้าแดชบอร์ดหลัก",icon:(0,t.jsx)(n.Home,{className:"w-4 h-4"})},{id:"users",label:"จัดการผู้ใช้/ร้านค้า",icon:(0,t.jsx)(d,{className:"w-4 h-4"}),badge:eA.length>0?eA.length.toString():null},{id:"categories",label:"หมวดหมู่หลัก",icon:(0,t.jsx)(o.Layers,{className:"w-4 h-4"})},{id:"orders",label:"ภาพรวมคำสั่งซื้อ",icon:(0,t.jsx)(i.ShoppingBag,{className:"w-4 h-4"})},{id:"shipping",label:"ภาพรวมการจัดส่ง",icon:(0,t.jsx)(x.Truck,{className:"w-4 h-4"})},{id:"finance",label:"รายงานการเงิน",icon:(0,t.jsx)(m,{className:"w-4 h-4"}),badge:"฿"},{id:"payouts",label:"จัดการการถอนเงิน",icon:(0,t.jsx)($.Landmark,{className:"w-4 h-4"}),badge:tA.filter(e=>"pending"===e.status).length>0?tA.filter(e=>"pending"===e.status).length.toString():null},{id:"settings",label:"การตั้งค่าระบบ",icon:(0,t.jsx)(h.Settings,{className:"w-4 h-4"})}].map(e=>{let s=ea===e.id;return(0,t.jsxs)("button",{onClick:()=>ek(e.id),className:`w-full flex items-center justify-between px-4 py-3 rounded-xl text-xs font-bold transition-all cursor-pointer ${s?"bg-[#800A0A] text-white shadow-md":"text-gray-600 hover:text-gray-900 hover:bg-gray-50"}`,children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[e.icon,(0,t.jsx)("span",{children:e.label})]}),e.badge&&(0,t.jsx)("span",{className:`text-[9px] font-black px-2 py-0.5 rounded-full ${s?"bg-white/20 text-white":"฿"===e.badge?"bg-amber-100 text-amber-700":"bg-black text-white"}`,children:e.badge})]},e.id)})}),(0,t.jsxs)("div",{className:"space-y-1.5 border-t border-gray-100 pt-3 mt-auto w-full",children:[(0,t.jsxs)(r.default,{href:"/",title:"สลับไปยังโหมดผู้ซื้อ/ลูกค้าทั่วไป",className:"w-full flex items-center space-x-3 px-3.5 py-2.5 text-[#800A0A] hover:bg-red-50/70 rounded-xl text-xs font-bold transition-all text-left block font-prompt border border-red-100 bg-red-50/30 shadow-2xs",children:[(0,t.jsx)(N.ArrowLeftRight,{className:"w-4 h-4 flex-shrink-0"}),(0,t.jsx)("span",{children:"สลับไปหน้าผู้ซื้อ (Buyer Mode)"})]}),(0,t.jsxs)(r.default,{href:"/merchant",title:"สลับไปยังแผงควบคุมร้านค้า",className:"w-full flex items-center space-x-3 px-3.5 py-2.5 text-gray-700 hover:text-gray-950 hover:bg-gray-50 rounded-xl text-xs font-bold transition-all text-left block font-prompt border border-gray-150 bg-gray-50/40",children:[(0,t.jsx)(j.Store,{className:"w-4 h-4 flex-shrink-0 text-emerald-600"}),(0,t.jsx)("span",{children:"สลับไปหน้าร้านค้า (Merchant)"})]}),(0,t.jsxs)("button",{onClick:tX,className:"w-full flex items-center space-x-3 px-3.5 py-2 text-red-600 hover:text-red-700 hover:bg-red-50/50 rounded-xl text-xs font-bold transition-all text-left bg-transparent border-none cursor-pointer",children:[(0,t.jsx)(b.LogOut,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:"ออกจากระบบ"})]})]})]}),(0,t.jsx)(T.default,{isOpen:eb,onClose:()=>ep(!1),children:(0,t.jsxs)("div",{className:"flex flex-col h-full justify-between font-prompt",children:[(0,t.jsx)("div",{className:"space-y-1",children:[{id:"dashboard",label:"หน้าแดชบอร์ดหลัก",icon:(0,t.jsx)(n.Home,{className:"w-4 h-4"})},{id:"users",label:"จัดการผู้ใช้/ร้านค้า",icon:(0,t.jsx)(d,{className:"w-4 h-4"}),badge:eA.length>0?eA.length.toString():null},{id:"categories",label:"หมวดหมู่หลัก",icon:(0,t.jsx)(o.Layers,{className:"w-4 h-4"})},{id:"orders",label:"ภาพรวมคำสั่งซื้อ",icon:(0,t.jsx)(i.ShoppingBag,{className:"w-4 h-4"})},{id:"shipping",label:"ภาพรวมการจัดส่ง",icon:(0,t.jsx)(x.Truck,{className:"w-4 h-4"})},{id:"finance",label:"รายงานการเงิน",icon:(0,t.jsx)(m,{className:"w-4 h-4"}),badge:"฿"},{id:"payouts",label:"จัดการการถอนเงิน",icon:(0,t.jsx)($.Landmark,{className:"w-4 h-4"}),badge:tA.filter(e=>"pending"===e.status).length>0?tA.filter(e=>"pending"===e.status).length.toString():null},{id:"settings",label:"การตั้งค่าระบบ",icon:(0,t.jsx)(h.Settings,{className:"w-4 h-4"})}].map(e=>{let s=ea===e.id;return(0,t.jsxs)("button",{onClick:()=>{ek(e.id),ep(!1)},className:`w-full flex items-center justify-between px-4 py-3 rounded-xl text-xs font-bold transition-all cursor-pointer ${s?"bg-[#800A0A] text-white shadow-md":"text-gray-600 hover:text-gray-900 hover:bg-gray-50"}`,children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[e.icon,(0,t.jsx)("span",{children:e.label})]}),e.badge&&(0,t.jsx)("span",{className:`text-[9px] font-black px-2 py-0.5 rounded-full ${s?"bg-white/20 text-white":"฿"===e.badge?"bg-amber-100 text-amber-700":"bg-black text-white"}`,children:e.badge})]},e.id)})}),(0,t.jsxs)("div",{className:"space-y-1.5 border-t border-gray-100 pt-3 mt-auto",children:[(0,t.jsxs)(r.default,{href:"/",onClick:()=>ep(!1),className:"w-full flex items-center space-x-3 px-3.5 py-2.5 text-[#800A0A] hover:bg-red-50/70 rounded-xl text-xs font-bold transition-all text-left block border border-red-100 bg-red-50/30",children:[(0,t.jsx)(N.ArrowLeftRight,{className:"w-4 h-4 flex-shrink-0"}),(0,t.jsx)("span",{children:"สลับไปหน้าผู้ซื้อ (Buyer Mode)"})]}),(0,t.jsxs)(r.default,{href:"/merchant",onClick:()=>ep(!1),className:"w-full flex items-center space-x-3 px-3.5 py-2.5 text-gray-700 hover:text-gray-950 hover:bg-gray-50 rounded-xl text-xs font-bold transition-all text-left block border border-gray-150 bg-gray-50/40",children:[(0,t.jsx)(j.Store,{className:"w-4 h-4 flex-shrink-0 text-emerald-600"}),(0,t.jsx)("span",{children:"สลับไปหน้าร้านค้า (Merchant)"})]}),(0,t.jsxs)("button",{onClick:tX,className:"w-full flex items-center space-x-3 px-3.5 py-2 text-red-600 hover:text-red-700 hover:bg-red-50/50 rounded-xl text-xs font-bold transition-all text-left bg-transparent border-none cursor-pointer",children:[(0,t.jsx)(b.LogOut,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:"ออกจากระบบ"})]})]})]})}),(0,t.jsxs)("main",{className:"flex-1 bg-[#FAF8F5] overflow-y-auto p-3 md:p-8 text-left",children:["dashboard"===ea&&(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsx)("div",{children:(0,t.jsx)("h1",{className:"text-2xl font-black text-gray-900 leading-none",children:"แผงควบคุมหลัก"})}),(0,t.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6",children:[(0,t.jsxs)("div",{onClick:()=>{ek("users"),tz("requests")},className:"bg-white rounded-2xl border border-[#F3F1ED] p-5 shadow-sm relative flex items-center justify-between overflow-visible transition-all hover:shadow-md cursor-pointer group/card",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("span",{className:"text-[10px] text-gray-400 font-bold uppercase tracking-wider block",children:"ร้านค้าใหม่รออนุมัติ"}),(0,t.jsx)("span",{className:"text-3xl font-black text-gray-900 block group-hover/card:scale-105 transition-transform duration-300 origin-left",children:eA.length})]}),(0,t.jsxs)("div",{className:"w-12 h-12 rounded-xl bg-red-50 text-[#800A0A] flex items-center justify-center relative shadow-xs",children:[(0,t.jsx)(j.Store,{className:"w-6 h-6"}),eA.length>0&&(0,t.jsx)("span",{className:"absolute -top-1 -right-1 w-5 h-5 bg-[#B91C1C] text-white text-[9px] font-black rounded-full flex items-center justify-center border-2 border-white shadow-xs",children:eA.length})]})]}),(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-[#F3F1ED] p-5 shadow-sm relative flex items-center justify-between overflow-visible transition-all hover:shadow-md group/card",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("span",{className:"text-[10px] text-gray-400 font-bold uppercase tracking-wider block",children:"หมวดหมู่สินค้าหลัก"}),(0,t.jsx)("span",{className:"text-3xl font-black text-gray-900 block group-hover/card:scale-105 transition-transform duration-300 origin-left",children:e$.length})]}),(0,t.jsx)("div",{className:"w-12 h-12 rounded-xl bg-red-50 text-[#800A0A] flex items-center justify-center shadow-xs",children:(0,t.jsx)(o.Layers,{className:"w-6 h-6"})})]}),(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-[#F3F1ED] p-5 shadow-sm relative flex items-center justify-between overflow-visible transition-all hover:shadow-md group/card",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("span",{className:"text-[10px] text-gray-400 font-bold uppercase tracking-wider block",children:"คำสั่งซื้อทั้งหมด"}),(0,t.jsx)("span",{className:"text-3xl font-black text-gray-900 block group-hover/card:scale-105 transition-transform duration-300 origin-left",children:211+em.length})]}),(0,t.jsx)("div",{className:"w-12 h-12 rounded-xl bg-red-50 text-[#800A0A] flex items-center justify-center shadow-xs",children:(0,t.jsx)(i.ShoppingBag,{className:"w-6 h-6"})})]}),(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-[#F3F1ED] p-5 shadow-sm relative flex items-center justify-between overflow-visible transition-all hover:shadow-md group/card",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("span",{className:"text-[10px] text-gray-400 font-bold uppercase tracking-wider block",children:"รายรับรวมสะสม"}),(0,t.jsxs)("span",{className:"text-3xl font-black text-[#800A0A] block group-hover/card:scale-105 transition-transform duration-300 origin-left",children:["฿",(256800+em.reduce((e,t)=>e+t.totalAmount,0)).toLocaleString()]})]}),(0,t.jsx)("div",{className:"w-12 h-12 rounded-xl bg-red-50 text-[#800A0A] flex items-center justify-center shadow-xs",children:(0,t.jsx)(m,{className:"w-6 h-6"})})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-6 items-stretch",children:[(0,t.jsxs)("div",{className:"lg:col-span-7 bg-white rounded-2xl border border-[#F3F1ED] p-6 shadow-sm flex flex-col justify-between",children:[(0,t.jsxs)("div",{className:"border-b border-gray-100 pb-3 flex justify-between items-center",children:[(0,t.jsx)("h3",{className:"font-extrabold text-gray-800 text-sm",children:"สถิติการสั่งซื้อรายสัปดาห์"}),(0,t.jsx)("span",{className:"text-[10px] font-bold text-gray-400 bg-gray-50 border border-gray-150 px-2 py-0.5 rounded-md",children:"อัปเดตเรียลไทม์"})]}),(0,t.jsxs)("div",{className:"relative h-64 flex items-end justify-between px-2 pt-8",children:[(0,t.jsxs)("div",{className:"absolute inset-0 flex flex-col justify-between pointer-events-none text-[9px] text-gray-400 font-semibold py-1",children:[(0,t.jsx)("div",{className:"w-full border-t border-dashed border-gray-100 flex justify-between pr-1",children:(0,t.jsx)("span",{children:"150"})}),(0,t.jsx)("div",{className:"w-full border-t border-dashed border-gray-100 flex justify-between pr-1",children:(0,t.jsx)("span",{children:"100"})}),(0,t.jsx)("div",{className:"w-full border-t border-dashed border-gray-100 flex justify-between pr-1",children:(0,t.jsx)("span",{children:"50"})}),(0,t.jsx)("div",{className:"w-full border-t border-transparent flex justify-between pr-1",children:(0,t.jsx)("span",{children:"0"})})]}),[{day:"สรับ",label:"จ.",value:90,height:"60%"},{day:"หลัป",label:"อ.",value:70,height:"47%"},{day:"คอก",label:"พ.",value:68,height:"45%"},{day:"ภาพ",label:"พฤ.",value:98,height:"65%"},{day:"เผย",label:"ศ.",value:85,height:"57%"},{day:"ปติ",label:"ส.",value:115,height:"77%"},{day:"คถบ",label:"อา.",value:45,height:"30%"}].map((e,s)=>(0,t.jsxs)("div",{className:"relative z-10 flex flex-col items-center flex-1 group/bar cursor-pointer",children:[(0,t.jsxs)("div",{className:"absolute -top-7 scale-0 group-hover/bar:scale-100 bg-gray-900 text-white text-[9px] font-bold px-2 py-1 rounded shadow-md transition-all duration-200 leading-none whitespace-nowrap z-30",children:[e.value," คำสั่งซื้อ"]}),(0,t.jsx)("div",{className:"w-8 bg-[#800A0A] hover:bg-[#B91C1C] rounded-t-md transition-all duration-500 ease-out shadow-xs group-hover/bar:shadow-md",style:{height:e.height}}),(0,t.jsxs)("div",{className:"mt-2.5 flex flex-col items-center",children:[(0,t.jsx)("span",{className:"text-[10px] text-gray-800 font-black",children:e.day}),(0,t.jsxs)("span",{className:"text-[8px] text-gray-400 font-medium mt-0.5",children:["(",e.label,")"]})]})]},s))]})]}),(0,t.jsxs)("div",{className:"lg:col-span-5 bg-white rounded-2xl border border-[#F3F1ED] p-6 shadow-sm flex flex-col justify-between",children:[(0,t.jsxs)("div",{className:"border-b border-gray-100 pb-3 flex justify-between items-center",children:[(0,t.jsx)("h3",{className:"font-extrabold text-gray-800 text-sm",children:"รายการสั่งซื้อล่าสุด (5 ล่าสุด)"}),(0,t.jsx)("button",{onClick:()=>ek("orders"),className:"text-[10px] font-bold text-[#800A0A] hover:underline bg-transparent border-none cursor-pointer",children:"ดูทั้งหมด"})]}),(0,t.jsx)("div",{className:"flex-1 overflow-x-auto pt-4",children:(0,t.jsxs)("table",{className:"w-full text-left text-xs border-collapse min-w-[400px] whitespace-nowrap",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:"bg-[#FAF3E8] rounded-xl text-gray-700 font-black",children:[(0,t.jsx)("th",{className:"p-2.5 rounded-l-xl",children:"Order ID"}),(0,t.jsx)("th",{className:"p-2.5",children:"ลูกค้า"}),(0,t.jsx)("th",{className:"p-2.5 rounded-r-xl",children:"Status"})]})}),(0,t.jsx)("tbody",{className:"divide-y divide-gray-50",children:em.slice(0,5).map((e,s)=>{let r="pending"===e.status?"รอตรวจสอบ":"delivered"===e.status?"สำเร็จแล้ว":"กำลังดำเนินการ",a="pending"===e.status?"bg-amber-100 text-amber-805 border-amber-200":"delivered"===e.status?"bg-green-100 text-green-805 border-green-200":"bg-blue-100 text-blue-805 border-blue-200";return(0,t.jsxs)("tr",{className:"hover:bg-gray-50/50 transition-colors font-medium",children:[(0,t.jsxs)("td",{className:"p-2.5 font-bold text-gray-800 text-[11px]",children:["#",e.id]}),(0,t.jsx)("td",{className:"p-2.5 text-gray-500 text-[10px] truncate max-w-[130px]",title:e.shippingAddress?.fullName,children:e.shippingAddress?.fullName}),(0,t.jsx)("td",{className:"p-2.5",children:(0,t.jsx)("span",{className:`inline-flex items-center space-x-1.5 px-3 py-1 rounded-full text-[10px] font-bold border ${a}`,children:(0,t.jsx)("span",{children:r})})})]},s)})})]})})]})]})]}),"users"===ea&&(0,t.jsxs)("div",{className:"space-y-6 animate-in fade-in duration-300",children:[(0,t.jsx)("div",{children:(0,t.jsx)("h1",{className:"text-2xl font-black text-gray-900 leading-none",children:"จัดการผู้ใช้/ร้านค้า"})}),(0,t.jsxs)("div",{className:"flex border-b border-gray-200 text-xs font-bold",children:[(0,t.jsx)("button",{onClick:()=>tz("merchants"),className:`py-3 px-6 -mb-px transition-colors cursor-pointer ${"merchants"===tt?"border-b-2 border-[#800A0A] text-[#800A0A]":"text-gray-500 hover:text-gray-800"}`,children:"ร้านค้า (Merchants)"}),(0,t.jsx)("button",{onClick:()=>tz("users"),className:`py-3 px-6 -mb-px transition-colors cursor-pointer ${"users"===tt?"border-b-2 border-[#800A0A] text-[#800A0A]":"text-gray-500 hover:text-gray-800"}`,children:"ผู้ใช้ทั่วไป (Users)"}),(0,t.jsxs)("button",{onClick:()=>tz("requests"),className:`py-3 px-6 -mb-px transition-colors flex items-center space-x-2 cursor-pointer ${"requests"===tt?"border-b-2 border-[#800A0A] text-[#800A0A]":"text-gray-500 hover:text-gray-800"}`,children:[(0,t.jsx)("span",{children:"คำขออนุมัติ"}),eA.length>0&&(0,t.jsx)("span",{className:"w-5.5 h-5.5 bg-[#B91C1C] text-white text-[9px] font-black rounded-full flex items-center justify-center",children:eA.length})]})]}),(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-[#F3F1ED] p-5 shadow-sm space-y-4",children:[(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row justify-between items-stretch sm:items-center gap-3",children:[(0,t.jsx)("div",{children:"merchants"===tt&&(0,t.jsxs)("button",{onClick:()=>ta(!0),className:"bg-gray-150 hover:bg-gray-250 text-gray-700 border border-gray-200/50 rounded-xl px-4 py-2 text-xs font-bold transition-all flex items-center space-x-1.5 cursor-pointer",children:[(0,t.jsx)(S.Plus,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:"เพิ่มร้านค้าใหม่"})]})}),(0,t.jsxs)("div",{className:"flex items-center gap-2 self-end w-full sm:w-auto",children:[(0,t.jsxs)("div",{className:"relative flex-1 sm:w-60",children:[(0,t.jsx)(p.Search,{className:"w-3.5 h-3.5 text-gray-400 absolute left-3 top-1/2 -translate-y-1/2"}),(0,t.jsx)("input",{type:"text",placeholder:"ค้นหา...",value:ei,onChange:e=>ex(e.target.value),className:"w-full bg-white border border-gray-200 rounded-xl py-1.5 pl-9 pr-3 text-xs focus:outline-none focus:ring-1 focus:ring-[#800A0A] focus:border-[#800A0A] text-gray-700 placeholder-gray-400"})]}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsxs)("select",{className:"appearance-none bg-white border border-gray-250 rounded-xl py-1.5 pl-3 pr-8 text-xs font-bold text-gray-700 focus:outline-none focus:ring-1 focus:ring-[#800A0A] focus:border-[#800A0A] cursor-pointer",children:[(0,t.jsx)("option",{children:"ล่าสุด"}),(0,t.jsx)("option",{children:"ชื่อร้าน (ก-ฮ)"}),(0,t.jsx)("option",{children:"ชื่อร้าน (A-Z)"})]}),(0,t.jsx)(f.ChevronDown,{className:"w-3.5 h-3.5 text-gray-400 absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none"})]}),(0,t.jsx)("button",{className:"p-2 bg-gray-50 border border-gray-200/80 rounded-xl hover:bg-gray-100 hover:border-gray-300 text-gray-500 cursor-pointer",children:(0,t.jsx)(A.Filter,{className:"w-3.5 h-3.5"})})]})]}),(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)("table",{className:"w-full text-left text-xs border-collapse min-w-[1000px] whitespace-nowrap",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:"bg-[#FAF3E8] rounded-xl text-gray-700 font-bold border-b border-gray-100",children:["requests"===tt&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("th",{className:"p-3.5 rounded-l-xl",children:"ชื่อ-นามสกุล"}),(0,t.jsx)("th",{className:"p-3.5",children:"อีเมลบัญชี"}),(0,t.jsx)("th",{className:"p-3.5",children:"เบอร์โทรศัพท์"}),(0,t.jsx)("th",{className:"p-3.5",children:"บทบาท/ประเภท"}),(0,t.jsx)("th",{className:"p-3.5",children:"วันที่ส่งคำขอ"}),(0,t.jsx)("th",{className:"p-3.5 rounded-r-xl text-center",children:"การดำเนินการ"})]}),"merchants"===tt&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("th",{className:"p-3.5 rounded-l-xl w-20",children:"โลโก้"}),(0,t.jsx)("th",{className:"p-3.5",children:"ชื่อร้าน"}),(0,t.jsx)("th",{className:"p-3.5",children:"อีเมลติดต่อ"}),(0,t.jsx)("th",{className:"p-3.5",children:"เบอร์โทรศัพท์"}),(0,t.jsx)("th",{className:"p-3.5",children:"ประเภท"}),(0,t.jsx)("th",{className:"p-3.5",children:"วันที่อนุมัติ/เข้าร่วม"}),(0,t.jsx)("th",{className:"p-3.5 rounded-r-xl text-center",children:"การดำเนินการ"})]}),"users"===tt&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("th",{className:"p-3.5 rounded-l-xl",children:"รหัสสมาชิก"}),(0,t.jsx)("th",{className:"p-3.5",children:"ชื่อ-นามสกุล"}),(0,t.jsx)("th",{className:"p-3.5",children:"อีเมลบัญชี"}),(0,t.jsx)("th",{className:"p-3.5",children:"เบอร์โทรศัพท์"}),(0,t.jsx)("th",{className:"p-3.5",children:"บทบาท"}),(0,t.jsx)("th",{className:"p-3.5",children:"วันที่ลงทะเบียน"}),(0,t.jsx)("th",{className:"p-3.5 rounded-r-xl text-center",children:"การดำเนินการ"})]})]})}),(0,t.jsxs)("tbody",{className:"divide-y divide-gray-50 font-medium",children:["requests"===tt&&(eA.filter(e=>e.name.toLowerCase().includes(ei.toLowerCase())||e.email.toLowerCase().includes(ei.toLowerCase())).length>0?eA.filter(e=>e.name.toLowerCase().includes(ei.toLowerCase())||e.email.toLowerCase().includes(ei.toLowerCase())).map(e=>(0,t.jsxs)("tr",{className:"hover:bg-gray-50/50 transition-colors",children:[(0,t.jsx)("td",{className:"p-3.5 font-bold text-gray-800",children:e.name}),(0,t.jsx)("td",{className:"p-3.5 text-gray-500",children:e.email}),(0,t.jsx)("td",{className:"p-3.5 text-gray-500",children:e.phone}),(0,t.jsx)("td",{className:"p-3.5",children:(0,t.jsx)("span",{className:`px-2 py-0.5 rounded-full text-[9px] font-bold ${"บุคลากร"===e.role?"bg-blue-50 text-blue-600 border border-blue-100":"bg-[#FEF3C7] text-[#D97706] border border-amber-100"}`,children:e.role})}),(0,t.jsx)("td",{className:"p-3.5 text-gray-500",children:e.date}),(0,t.jsxs)("td",{className:"p-3.5 flex justify-center items-center space-x-2",children:[(0,t.jsx)("button",{onClick:()=>{var t,s;let r,a;return t=e.id,s=e.name,a=((r=localStorage.getItem("ctc_accounts"))?JSON.parse(r):[]).map(e=>e.id.toString()===t.toString()?{...e,status:"approved"}:e),void(localStorage.setItem("ctc_accounts",JSON.stringify(a)),window.dispatchEvent(new Event("storage")),tU(`อนุมัติบัญชีผู้ใช้ "${s}" เรียบร้อยแล้ว`,"success"))},className:"bg-emerald-600 hover:bg-emerald-700 text-white rounded-xl px-4 py-1.5 font-bold text-[11px] shadow-xs hover:scale-105 active:scale-95 transition-all cursor-pointer",children:"อนุมัติ"}),(0,t.jsx)("button",{onClick:()=>{var t,s;let r,a;return t=e.id,s=e.name,a=((r=localStorage.getItem("ctc_accounts"))?JSON.parse(r):[]).filter(e=>e.id.toString()!==t.toString()),void(localStorage.setItem("ctc_accounts",JSON.stringify(a)),window.dispatchEvent(new Event("storage")),tU(`ปฏิเสธบัญชีผู้ใช้ "${s}" แล้ว`,"info"))},className:"bg-[#B91C1C] hover:bg-red-800 text-white rounded-xl px-4 py-1.5 font-bold text-[11px] shadow-xs hover:scale-105 active:scale-95 transition-all cursor-pointer",children:"ปฏิเสธ"})]})]},e.id)):(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:6,className:"p-8 text-center text-gray-400 font-light bg-gray-50/30 rounded-b-xl",children:"ไม่มีคำขออนุมัติบัญชีผู้ใช้ในขณะนี้"})})),"merchants"===tt&&(eC.filter(e=>e.name.toLowerCase().includes(ei.toLowerCase())||e.email.toLowerCase().includes(ei.toLowerCase())).length>0?eC.filter(e=>e.name.toLowerCase().includes(ei.toLowerCase())||e.email.toLowerCase().includes(ei.toLowerCase())).map(e=>(0,t.jsxs)("tr",{className:"hover:bg-gray-50/50 transition-colors",children:[(0,t.jsx)("td",{className:"p-3.5",children:(0,t.jsx)("span",{className:"w-10 h-10 rounded-xl bg-amber-50 text-xl border border-amber-100 flex items-center justify-center shadow-xs",children:e.logo})}),(0,t.jsx)("td",{className:"p-3.5 font-bold text-gray-800",children:e.name}),(0,t.jsx)("td",{className:"p-3.5 text-gray-500",children:e.email}),(0,t.jsx)("td",{className:"p-3.5 text-gray-500",children:e.phone}),(0,t.jsx)("td",{className:"p-3.5 text-gray-500",children:e.type}),(0,t.jsx)("td",{className:"p-3.5 text-gray-500",children:e.date}),(0,t.jsx)("td",{className:"p-3.5 text-center",children:(0,t.jsxs)("div",{className:"flex items-center justify-center space-x-1.5",children:[(0,t.jsx)("button",{onClick:()=>{{let t=localStorage.getItem("ctc_accounts"),s=(t?JSON.parse(t):[]).map(t=>t.id.toString()===e.id.toString()?{...t,status:"pending"}:t);localStorage.setItem("ctc_accounts",JSON.stringify(s)),window.dispatchEvent(new Event("storage"))}tU(`ระงับสิทธิ์ร้านค้า "${e.name}" เรียบร้อยแล้ว`,"info")},className:"border border-amber-200 text-amber-600 hover:bg-amber-50 rounded-xl px-3 py-1 font-bold text-[10px] transition-all cursor-pointer",children:"ระงับสิทธิ์"}),(0,t.jsx)("button",{onClick:()=>tU(`ส่งอีเมลรีเซ็ตรหัสผ่านให้แก่ร้านค้า "${e.email}"`,"info"),className:"border border-gray-250 text-gray-600 hover:bg-gray-50 rounded-xl px-3 py-1 font-bold text-[10px] transition-all cursor-pointer",children:"กู้คืนรหัสผ่าน"}),(0,t.jsx)("button",{onClick:()=>{if(confirm(`คุณแน่ใจหรือไม่ว่าต้องการลบบัญชีร้านค้า "${e.name}" ออกจากระบบ?`)){{let t=localStorage.getItem("ctc_accounts"),s=(t?JSON.parse(t):[]).filter(t=>t.id.toString()!==e.id.toString());localStorage.setItem("ctc_accounts",JSON.stringify(s)),window.dispatchEvent(new Event("storage"))}tU(`ลบบัญชีร้านค้า "${e.name}" เรียบร้อยแล้ว`,"success")}},className:"border border-red-200 text-red-500 hover:bg-red-50 rounded-xl px-3 py-1 font-bold text-[10px] transition-all cursor-pointer",children:"ลบบัญชี"})]})})]},e.id)):(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:7,className:"p-8 text-center text-gray-400 font-light bg-gray-50/30 rounded-b-xl",children:"ไม่พบร้านค้าที่ตรงกับเงื่อนไขการค้นหา"})})),"users"===tt&&(eE.filter(e=>e.name.toLowerCase().includes(ei.toLowerCase())||e.email.toLowerCase().includes(ei.toLowerCase())).length>0?eE.filter(e=>e.name.toLowerCase().includes(ei.toLowerCase())||e.email.toLowerCase().includes(ei.toLowerCase())).map(e=>(0,t.jsxs)("tr",{className:"hover:bg-gray-50/50 transition-colors",children:[(0,t.jsxs)("td",{className:"p-3.5 text-gray-500 font-bold",children:["USR-",e.id]}),(0,t.jsx)("td",{className:"p-3.5 font-bold text-gray-800",children:e.name}),(0,t.jsx)("td",{className:"p-3.5 text-gray-500",children:e.email}),(0,t.jsx)("td",{className:"p-3.5 text-gray-500",children:e.phone}),(0,t.jsx)("td",{className:"p-3.5",children:(0,t.jsx)("span",{className:`px-2 py-0.5 rounded-full text-[9px] font-bold ${"บุคลากร"===e.role?"bg-blue-50 text-blue-600 border border-blue-100":"นักศึกษา"===e.role?"bg-[#FEF3C7] text-[#D97706] border border-amber-100":"bg-gray-50 text-gray-500 border border-gray-150"}`,children:e.role})}),(0,t.jsx)("td",{className:"p-3.5 text-gray-500",children:e.date}),(0,t.jsx)("td",{className:"p-3.5 text-center",children:(0,t.jsxs)("div",{className:"flex items-center justify-center space-x-1.5",children:[(0,t.jsx)("button",{onClick:()=>{{let t=localStorage.getItem("ctc_accounts"),s=(t?JSON.parse(t):[]).map(t=>t.id.toString()===e.id.toString()?{...t,status:"pending"}:t);localStorage.setItem("ctc_accounts",JSON.stringify(s)),window.dispatchEvent(new Event("storage"))}tU(`ระงับสิทธิ์ผู้ใช้งาน "${e.name}" เรียบร้อยแล้ว`,"info")},className:"border border-amber-200 text-amber-600 hover:bg-amber-50 rounded-xl px-3 py-1 font-bold text-[10px] transition-all cursor-pointer",children:"ระงับสิทธิ์"}),(0,t.jsx)("button",{onClick:()=>tU(`ส่งอีเมลรีเซ็ตรหัสผ่านให้แก่ผู้ใช้งาน "${e.email}"`,"info"),className:"border border-gray-250 text-gray-600 hover:bg-gray-50 rounded-xl px-3 py-1 font-bold text-[10px] transition-all cursor-pointer",children:"กู้คืนรหัสผ่าน"}),(0,t.jsx)("button",{onClick:()=>{if(confirm(`คุณแน่ใจหรือไม่ว่าต้องการลบบัญชีผู้ใช้งาน "${e.name}" ออกจากระบบ?`)){{let t=localStorage.getItem("ctc_accounts"),s=(t?JSON.parse(t):[]).filter(t=>t.id.toString()!==e.id.toString());localStorage.setItem("ctc_accounts",JSON.stringify(s)),window.dispatchEvent(new Event("storage"))}tU(`ลบบัญชีผู้ใช้งาน "${e.name}" เรียบร้อยแล้ว`,"success")}},className:"border border-red-200 text-red-500 hover:bg-red-50 rounded-xl px-3 py-1 font-bold text-[10px] transition-all cursor-pointer",children:"ลบบัญชี"})]})})]},e.id)):(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:7,className:"p-8 text-center text-gray-400 font-light bg-gray-50/30 rounded-b-xl",children:"ไม่พบผู้ใช้ที่ตรงกับเงื่อนไขการค้นหา"})}))]})]})}),(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row justify-between items-center pt-3 gap-3",children:[(0,t.jsxs)("span",{className:"text-[10px] text-gray-400 font-bold",children:["requests"===tt&&`แสดงผล 1 - ${eA.length} จากทั้งหมด ${eA.length} รายการ`,"merchants"===tt&&`แสดงผล 1 - ${eC.length} จากทั้งหมด ${eC.length} รายการ`,"users"===tt&&`แสดงผล 1 - ${eE.length} จากทั้งหมด ${eE.length} รายการ`]}),(0,t.jsxs)("div",{className:"flex items-center space-x-1.5",children:[(0,t.jsx)("button",{className:"w-8 h-8 rounded-lg border border-gray-200 hover:bg-gray-50 flex items-center justify-center text-gray-500 hover:text-gray-900 transition-colors disabled:opacity-50 cursor-pointer",disabled:!0,children:(0,t.jsx)(E,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("button",{className:"w-8 h-8 rounded-lg border border-gray-200 hover:bg-gray-50 flex items-center justify-center text-gray-500 hover:text-gray-900 transition-colors disabled:opacity-50 cursor-pointer",disabled:!0,children:(0,t.jsx)(C.ChevronLeft,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("button",{className:"w-8 h-8 rounded-lg bg-[#800A0A] hover:bg-[#991B1B] text-white flex items-center justify-center text-xs font-black shadow-sm cursor-pointer",children:"1"}),(0,t.jsx)("button",{className:"w-8 h-8 rounded-lg border border-gray-200 hover:bg-gray-50 flex items-center justify-center text-gray-500 hover:text-gray-900 transition-colors disabled:opacity-50 cursor-pointer",disabled:!0,children:(0,t.jsx)(L.ChevronRight,{className:"w-3.5 h-3.5"})}),(0,t.jsx)("button",{className:"w-8 h-8 rounded-lg border border-gray-200 hover:bg-gray-50 flex items-center justify-center text-gray-500 hover:text-gray-900 transition-colors disabled:opacity-50 cursor-pointer",disabled:!0,children:(0,t.jsx)(F,{className:"w-3.5 h-3.5"})})]})]})]}),tr&&(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-xs animate-in fade-in duration-200",children:(0,t.jsxs)("div",{className:"bg-white rounded-3xl w-full max-w-md overflow-hidden shadow-2xl flex flex-col border border-gray-100 text-left animate-in zoom-in-95 duration-200",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.5 text-[#800A0A]",children:[(0,t.jsx)(j.Store,{className:"w-5 h-5"}),(0,t.jsx)("h3",{className:"text-base font-black text-gray-900",children:"เพิ่มร้านค้าจำหน่ายสินค้าใหม่"})]}),(0,t.jsx)("button",{onClick:()=>ta(!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)(k.X,{className:"w-5 h-5"})})]}),(0,t.jsxs)("form",{onSubmit:e=>{if(e.preventDefault(),!tl||!tc)return void tU("กรุณากรอกข้อมูลให้ครบถ้วน","error");let t=new Date().toLocaleDateString("th-TH"),s=localStorage.getItem("ctc_accounts"),r=s?JSON.parse(s):[],a={id:"usr_"+Date.now(),email:tc.trim().toLowerCase(),fullName:tl.trim(),role:"merchant",status:"approved",date:t,logo:to};r.push(a),localStorage.setItem("ctc_accounts",JSON.stringify(r)),window.dispatchEvent(new Event("storage")),ta(!1),tn(""),td(""),tU(`เพิ่มร้านค้าใหม่ "${tl}" สำเร็จแล้ว`,"success")},className:"p-5 space-y-4 text-xs",children:[(0,t.jsxs)("div",{className:"flex flex-col space-y-1.5",children:[(0,t.jsx)("label",{className:"font-bold text-gray-700",children:"ชื่อร้านค้า"}),(0,t.jsx)("input",{type:"text",required:!0,placeholder:"กรอกชื่อร้านค้าใหม่ เช่น ร้านน้ำหวานไอที...",value:tl,onChange:e=>tn(e.target.value),className:"border border-gray-200 rounded-xl px-4 py-2.5 text-xs focus:outline-none focus:ring-1 focus:ring-[#800A0A] focus:border-[#800A0A] text-gray-800"})]}),(0,t.jsxs)("div",{className:"flex flex-col space-y-1.5",children:[(0,t.jsx)("label",{className:"font-bold text-gray-700",children:"อีเมลติดต่อ (ผู้รับผิดชอบ)"}),(0,t.jsx)("input",{type:"email",required:!0,placeholder:"example@cmtc.ac.th",value:tc,onChange:e=>td(e.target.value),className:"border border-gray-200 rounded-xl px-4 py-2.5 text-xs focus:outline-none focus:ring-1 focus:ring-[#800A0A] focus:border-[#800A0A] text-gray-800"})]}),(0,t.jsxs)("div",{className:"pt-4 flex space-x-2",children:[(0,t.jsx)("button",{type:"button",onClick:()=>ta(!1),className:"flex-1 border border-gray-250 hover:bg-gray-50 text-gray-750 font-bold py-2.5 rounded-xl transition-colors cursor-pointer",children:"ยกเลิก"}),(0,t.jsx)("button",{type:"submit",className:"flex-1 bg-[#800A0A] hover:bg-[#991B1B] text-white font-bold py-2.5 rounded-xl shadow-sm transition-colors cursor-pointer",children:"บันทึกร้านค้าใหม่"})]})]})]})})]}),"categories"===ea&&(0,t.jsxs)("div",{className:"space-y-6 animate-in fade-in duration-300",children:[(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsx)("h1",{className:"text-2xl font-black text-gray-900 leading-none",children:"หมวดหมู่หลัก"}),(0,t.jsxs)("button",{onClick:()=>{eq(""),eU(""),eH("shirt"),eW("เสื้อผ้าและเครื่องแบบ"),eD(!0)},className:"bg-[#800A0A] hover:bg-[#991B1B] text-white rounded-xl px-5 py-2.5 text-xs font-bold transition-all flex items-center space-x-2 cursor-pointer shadow-md hover:scale-105 active:scale-95",children:[(0,t.jsx)(S.Plus,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:"เพิ่มหมวดหมู่ใหม่"})]})]}),0===(z=eI.filter(e=>"pending"===e.status)).length?null:(0,t.jsxs)("div",{className:"bg-gradient-to-r from-amber-50/90 to-orange-50/90 border-2 border-amber-300/80 rounded-2xl p-5 shadow-sm space-y-4",children:[(0,t.jsx)("div",{className:"flex items-center justify-between",children:(0,t.jsxs)("div",{className:"flex items-center space-x-2.5",children:[(0,t.jsx)("span",{className:"text-2xl",children:"💡"}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)("h3",{className:"font-black text-amber-950 text-sm",children:"ข้อเสนอแนะหมวดหมู่ใหม่จากร้านค้า"}),(0,t.jsxs)("span",{className:"bg-amber-500 text-white text-[10px] font-black px-2 py-0.5 rounded-full shadow-xs",children:[z.length," คำขอใหม่"]})]}),(0,t.jsx)("p",{className:"text-[11px] text-amber-850/80 font-medium mt-0.5",children:"ร้านค้าได้เสนอแนะหมวดหมู่สินค้าที่ต้องการใช้งาน คุณสามารถกดอนุมัติเพื่อสร้างและเปิดใช้งานในระบบได้ทันที"})]})]})}),(0,t.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:z.map(e=>(0,t.jsxs)("div",{className:"bg-white border border-amber-200 rounded-xl p-3.5 flex flex-col justify-between space-y-3 shadow-xs hover:border-amber-400 transition-colors text-left",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("span",{className:"font-extrabold text-gray-900 text-xs",children:["📁 ",e.name]}),(0,t.jsx)("span",{className:"text-[9px] font-bold text-amber-700 bg-amber-100/80 px-2 py-0.5 rounded-md",children:"รอพิจารณา"})]}),(0,t.jsxs)("div",{className:"text-[10px] text-gray-500 mt-1 space-y-0.5 font-medium",children:[(0,t.jsxs)("p",{className:"truncate",children:["โดย: ",(0,t.jsx)("span",{className:"text-gray-700 font-semibold",children:e.merchantEmail||"ร้านค้าสมาชิก"})]}),(0,t.jsx)("p",{className:"text-gray-400",children:e.createdAt?new Date(e.createdAt).toLocaleDateString("th-TH"):"วันนี้"})]})]}),(0,t.jsxs)("div",{className:"flex items-center space-x-2 pt-2 border-t border-gray-100",children:[(0,t.jsx)("button",{type:"button",onClick:()=>{var t,s;let r,a,l,n;return t=e.id,s=e.name,r=`cat_${Date.now()}`,a=s.toLowerCase().replace(/ /g,"-").replace(/[^\w-]/g,""),e_(l=[...e$,{id:r,name:s,slug:a||`category-${Date.now()}`,subtext:"หมวดหมู่เพิ่มเติมจากการเสนอแนะของร้านค้า",icon:"shirt",active:!0,parentCategory:"เสื้อผ้าและเครื่องแบบ"}]),localStorage.setItem("ctc_categories",JSON.stringify(l)),void(eP(n=eI.map(e=>e.id===t?{...e,status:"approved"}:e)),localStorage.setItem("ctc_category_suggestions",JSON.stringify(n)),window.dispatchEvent(new Event("storage")),tU(`อนุมัติและเปิดใช้งานหมวดหมู่ "${s}" เรียบร้อยแล้ว`,"success"))},className:"flex-1 bg-emerald-600 hover:bg-emerald-700 text-white text-[10.5px] font-bold py-1.5 px-2 rounded-lg transition-colors cursor-pointer text-center shadow-xs",children:"✓ อนุมัติและสร้าง"}),(0,t.jsx)("button",{type:"button",onClick:()=>{var t;let s;return t=e.id,void(eP(s=eI.map(e=>e.id===t?{...e,status:"rejected"}:e)),localStorage.setItem("ctc_category_suggestions",JSON.stringify(s)),window.dispatchEvent(new Event("storage")),tU("ปฏิเสธคำขอเสนอแนะหมวดหมู่แล้ว","info"))},className:"bg-gray-150 hover:bg-gray-200 text-gray-700 text-[10.5px] font-bold py-1.5 px-3 rounded-lg transition-colors cursor-pointer",children:"ปฏิเสธ"})]})]},e.id))})]}),(0,t.jsxs)("div",{className:"flex items-center relative w-full sm:w-96 bg-white rounded-xl border border-gray-200 shadow-xs",children:[(0,t.jsx)(p.Search,{className:"w-4 h-4 text-gray-400 absolute left-4 pointer-events-none"}),(0,t.jsx)("input",{type:"text",placeholder:"ค้นหาหมวดหมู่...",value:ei,onChange:e=>ex(e.target.value),className:"w-full border-none bg-transparent py-2.5 pl-11 pr-4 text-xs focus:outline-none text-gray-800 font-medium"})]}),(0,t.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6",children:e$.filter(e=>e.name.toLowerCase().includes(ei.toLowerCase())||e.subtext.toLowerCase().includes(ei.toLowerCase())).map((e,s)=>{let r,a=s%3,l=eK.filter(t=>t.categoryId===e.id).length;return(0,t.jsxs)("div",{className:`rounded-3xl p-6 flex flex-col justify-between items-center text-center space-y-6 shadow-md hover:shadow-lg hover:scale-103 transition-all duration-300 relative border ${2===a?"border-amber-150":"border-transparent"} ${0===a?"bg-[#800A0A] text-white":1===a?"bg-[#2E0202] text-white":"bg-[#FAF3E8] text-gray-850"}`,children:[(0,t.jsx)("div",{className:`w-20 h-20 rounded-full flex items-center justify-center ${2===a?"bg-amber-100/50":"bg-white/10"}`,children:(r=`w-9 h-9 ${2===a?"text-amber-900":"text-white"}`,"shirt"===e.icon||"polo"===e.icon||"hoodie"===e.icon?(0,t.jsx)(o.Layers,{className:r}):"jacket"===e.icon?(0,t.jsx)(y.Wrench,{className:r}):"accessories"===e.icon?(0,t.jsx)(i.ShoppingBag,{className:r}):"wrench"===e.icon?(0,t.jsx)(y.Wrench,{className:r}):"shopping-bag"===e.icon?(0,t.jsx)(i.ShoppingBag,{className:r}):"store"===e.icon?(0,t.jsx)(j.Store,{className:r}):(0,t.jsx)(o.Layers,{className:r}))}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("span",{className:`text-[9px] font-bold tracking-wider uppercase px-2 py-0.5 rounded-md ${2===a?"bg-amber-900/10 text-amber-900":"bg-white/10 text-white/80"}`,children:e.parentCategory||"เสื้อผ้าและเครื่องแบบ"}),(0,t.jsx)("h3",{className:"text-lg font-black tracking-tight leading-snug",children:e.name}),(0,t.jsx)("p",{className:`text-xs font-light leading-relaxed max-w-[200px] mx-auto min-h-[32px] ${2===a?"text-gray-500":"text-gray-300"}`,children:e.subtext}),(0,t.jsxs)("span",{className:`inline-block px-3 py-1 rounded-full text-xs font-bold mt-2 ${2===a?"bg-amber-950/10 text-amber-950":"bg-black/20 text-white"}`,children:[l," สินค้า"]}),(0,t.jsxs)("div",{className:"flex items-center justify-center space-x-2.5 pt-3",children:[(0,t.jsx)("span",{className:`text-[10px] font-bold ${2===a?"text-gray-500":"text-gray-300"}`,children:!1!==e.active?"เปิดใช้งาน":"ปิดใช้งาน"}),(0,t.jsx)("button",{type:"button",onClick:()=>{var t,s;let r,a;return t=e.id,s=!1!==e.active,a=((r=localStorage.getItem("ctc_categories"))?JSON.parse(r):[]).map(e=>e.id===t?{...e,active:!s}:e),void(localStorage.setItem("ctc_categories",JSON.stringify(a)),window.dispatchEvent(new Event("storage")),tU("เปลี่ยนสถานะการใช้งานหมวดหมู่เรียบร้อยแล้ว","success"))},className:`relative inline-flex h-5 w-9 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none ${!1!==e.active?2===a?"bg-amber-955/80":"bg-white/80":"bg-gray-400/50"}`,children:(0,t.jsx)("span",{className:`pointer-events-none inline-block h-4 w-4 transform rounded-full bg-white shadow-sm ring-0 transition duration-200 ease-in-out ${!1!==e.active?"translate-x-4":"translate-x-0"} ${!1!==e.active&&2!==a?"bg-[#800A0A]":"bg-white"}`})})]})]}),(0,t.jsxs)("div",{className:"flex flex-col space-y-2 pt-2 w-full items-center",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2 w-full justify-center",children:[(0,t.jsx)("button",{onClick:()=>{eJ(e),eq(e.name),eU(e.subtext),eH(e.icon),eW(e.parentCategory||"เสื้อผ้าและเครื่องแบบ"),eB(!0)},className:`px-4 py-2 text-xs font-bold flex items-center space-x-1.5 border-none cursor-pointer rounded-full transition-all hover:scale-105 active:scale-95 ${2===a?"bg-[#1F160C] hover:bg-[#2C1F11] text-white":"bg-white hover:bg-gray-50 text-gray-800"}`,children:(0,t.jsx)("span",{children:"แก้ไข"})}),(0,t.jsx)("button",{onClick:()=>{var t,s;let r,a;return t=e.id,s=e.name,a=((r=localStorage.getItem("ctc_categories"))?JSON.parse(r):[]).filter(e=>e.id!==t),void(localStorage.setItem("ctc_categories",JSON.stringify(a)),window.dispatchEvent(new Event("storage")),tU(`ลบหมวดหมู่สินค้า "${s}" เรียบร้อยแล้ว`,"info"))},className:`px-4 py-2 text-xs font-bold flex items-center space-x-1.5 border-none cursor-pointer rounded-full transition-all hover:scale-105 active:scale-95 ${2===a?"bg-[#F2E5D2] hover:bg-[#EBDABF] text-red-650":"bg-[#5B0404] hover:bg-[#480303] text-white"}`,children:(0,t.jsx)("span",{children:"ลบ"})})]}),(0,t.jsxs)("button",{onClick:()=>{e0(e),e1(eK.filter(t=>t.categoryId===e.id).map(e=>e.id)),e4(""),eQ(!0)},className:`w-full py-2 text-[10px] font-bold flex items-center justify-center space-x-1.5 border rounded-full transition-all hover:scale-102 active:scale-98 cursor-pointer ${2===a?"border-[#1F160C] text-[#1F160C] hover:bg-[#1F160C]/5":"border-white/40 text-white hover:bg-white/10"}`,children:[(0,t.jsx)(i.ShoppingBag,{className:"w-3.5 h-3.5"}),(0,t.jsx)("span",{children:"จับคู่และจัดสรรสินค้า"})]})]})]},e.id)})}),eO&&(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-xs animate-in fade-in duration-200",children:(0,t.jsxs)("div",{className:"bg-white rounded-3xl w-full max-w-md overflow-hidden shadow-2xl flex flex-col border border-gray-100 text-left animate-in zoom-in-95 duration-200",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.5 text-[#800A0A]",children:[(0,t.jsx)(o.Layers,{className:"w-5 h-5"}),(0,t.jsx)("h3",{className:"text-base font-black text-gray-900",children:"เพิ่มหมวดหมู่สินค้าใหม่"})]}),(0,t.jsx)("button",{onClick:()=>eD(!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)(k.X,{className:"w-5 h-5"})})]}),(0,t.jsxs)("form",{onSubmit:e=>{if(e.preventDefault(),!eR||!ez)return void tU("กรุณากรอกข้อมูลให้ครบถ้วน","error");let t=localStorage.getItem("ctc_categories"),s=t?JSON.parse(t):[],r={id:"cat_"+Math.floor(1e3+9e3*Math.random()),name:eR.trim(),slug:eR.toLowerCase().replace(/[^a-z0-9]/g,"-"),subtext:ez.trim(),icon:eX,active:!0,parentCategory:eG};localStorage.setItem("ctc_categories",JSON.stringify([...s,r])),window.dispatchEvent(new Event("storage")),eD(!1),tU(`เพิ่มหมวดหมู่สินค้า "${eR}" สำเร็จแล้ว`,"success")},className:"p-5 space-y-4 text-xs",children:[(0,t.jsxs)("div",{className:"flex flex-col space-y-1.5",children:[(0,t.jsx)("label",{className:"font-bold text-gray-700",children:"ชื่อหมวดหมู่"}),(0,t.jsx)("input",{type:"text",required:!0,placeholder:"กรอกชื่อหมวดหมู่ใหม่ เช่น เสื้อวอร์มกีฬา...",value:eR,onChange:e=>eq(e.target.value),className:"border border-gray-200 rounded-xl px-4 py-2.5 text-xs focus:outline-none focus:ring-1 focus:ring-[#800A0A] focus:border-[#800A0A] text-gray-800"})]}),(0,t.jsxs)("div",{className:"flex flex-col space-y-1.5",children:[(0,t.jsx)("label",{className:"font-bold text-gray-700",children:"คำอธิบายเพิ่มเติม (คำย่อย)"}),(0,t.jsx)("input",{type:"text",required:!0,placeholder:"เช่น เสื้อแจ็คเก็ตกีฬา, เสื้อกิจกรรม...",value:ez,onChange:e=>eU(e.target.value),className:"border border-gray-200 rounded-xl px-4 py-2.5 text-xs focus:outline-none focus:ring-1 focus:ring-[#800A0A] focus:border-[#800A0A] text-gray-800"})]}),(0,t.jsxs)("div",{className:"flex flex-col space-y-1.5",children:[(0,t.jsx)("label",{className:"font-bold text-gray-700",children:"หมวดหมู่หลัก (Parent Category)"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsxs)("select",{value:eG,onChange:e=>eW(e.target.value),className:"w-full appearance-none border border-gray-200 rounded-xl px-4 py-2.5 text-xs font-bold text-gray-700 focus:outline-none focus:ring-1 focus:ring-[#800A0A] focus:border-[#800A0A] cursor-pointer",children:[(0,t.jsx)("option",{value:"เสื้อผ้าและเครื่องแบบ",children:"เสื้อผ้าและเครื่องแบบ (Apparel & Clothing)"}),(0,t.jsx)("option",{value:"อุปกรณ์เสริมและอื่นๆ",children:"อุปกรณ์เสริมและอื่นๆ (Supplies & Accessories)"})]}),(0,t.jsx)(f.ChevronDown,{className:"w-4 h-4 text-gray-400 absolute right-3.5 top-1/2 -translate-y-1/2 pointer-events-none"})]})]}),(0,t.jsxs)("div",{className:"flex flex-col space-y-1.5",children:[(0,t.jsx)("label",{className:"font-bold text-gray-700",children:"ไอคอนหมวดหมู่"}),(0,t.jsx)("div",{className:"grid grid-cols-4 gap-2 text-center",children:[{id:"shirt",label:"เสื้อยืด/ปก"},{id:"hoodie",label:"เสื้อฮู้ด"},{id:"jacket",label:"เสื้อช็อป/ช่าง"},{id:"accessories",label:"อุปกรณ์เสริม"}].map(e=>(0,t.jsx)("button",{type:"button",onClick:()=>eH(e.id),className:`p-2 rounded-xl border text-[10px] font-bold transition-all cursor-pointer ${eX===e.id?"bg-[#800A0A]/5 border-[#800A0A] text-[#800A0A]":"border-gray-200 hover:bg-gray-50 text-gray-500"}`,children:e.label},e.id))})]}),(0,t.jsxs)("div",{className:"pt-4 flex space-x-2",children:[(0,t.jsx)("button",{type:"button",onClick:()=>eD(!1),className:"flex-1 border border-gray-250 hover:bg-gray-50 text-gray-755 font-bold py-2.5 rounded-xl transition-colors cursor-pointer",children:"ยกเลิก"}),(0,t.jsx)("button",{type:"submit",className:"flex-1 bg-[#800A0A] hover:bg-[#991B1B] text-white font-bold py-2.5 rounded-xl shadow-sm transition-colors cursor-pointer",children:"บันทึกหมวดหมู่ใหม่"})]})]})]})}),eT&&(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-xs animate-in fade-in duration-200",children:(0,t.jsxs)("div",{className:"bg-white rounded-3xl w-full max-w-md overflow-hidden shadow-2xl flex flex-col border border-gray-100 text-left animate-in zoom-in-95 duration-200",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.5 text-[#800A0A]",children:[(0,t.jsx)(o.Layers,{className:"w-5 h-5"}),(0,t.jsx)("h3",{className:"text-base font-black text-gray-900",children:"แก้ไขข้อมูลหมวดหมู่สินค้า"})]}),(0,t.jsx)("button",{onClick:()=>{eB(!1),eJ(null)},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)(k.X,{className:"w-5 h-5"})})]}),(0,t.jsxs)("form",{onSubmit:e=>{if(e.preventDefault(),!eR||!ez||!eM)return void tU("กรุณากรอกข้อมูลให้ครบถ้วน","error");let t=localStorage.getItem("ctc_categories"),s=(t?JSON.parse(t):[]).map(e=>e.id===eM.id?{...e,name:eR.trim(),subtext:ez.trim(),icon:eX,parentCategory:eG}:e);localStorage.setItem("ctc_categories",JSON.stringify(s)),window.dispatchEvent(new Event("storage")),eB(!1),eJ(null),tU(`แก้ไขข้อมูลหมวดหมู่สินค้า "${eR}" เรียบร้อยแล้ว`,"success")},className:"p-5 space-y-4 text-xs",children:[(0,t.jsxs)("div",{className:"flex flex-col space-y-1.5",children:[(0,t.jsx)("label",{className:"font-bold text-gray-700",children:"ชื่อหมวดหมู่"}),(0,t.jsx)("input",{type:"text",required:!0,placeholder:"กรอกชื่อหมวดหมู่...",value:eR,onChange:e=>eq(e.target.value),className:"border border-gray-200 rounded-xl px-4 py-2.5 text-xs focus:outline-none focus:ring-1 focus:ring-[#800A0A] focus:border-[#800A0A] text-gray-800"})]}),(0,t.jsxs)("div",{className:"flex flex-col space-y-1.5",children:[(0,t.jsx)("label",{className:"font-bold text-gray-700",children:"คำอธิบายเพิ่มเติม (คำย่อย)"}),(0,t.jsx)("input",{type:"text",required:!0,placeholder:"เช่น เสื้อแจ็คเก็ตกีฬา...",value:ez,onChange:e=>eU(e.target.value),className:"border border-gray-200 rounded-xl px-4 py-2.5 text-xs focus:outline-none focus:ring-1 focus:ring-[#800A0A] focus:border-[#800A0A] text-gray-800"})]}),(0,t.jsxs)("div",{className:"flex flex-col space-y-1.5",children:[(0,t.jsx)("label",{className:"font-bold text-gray-700",children:"หมวดหมู่หลัก (Parent Category)"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsxs)("select",{value:eG,onChange:e=>eW(e.target.value),className:"w-full appearance-none border border-gray-200 rounded-xl px-4 py-2.5 text-xs font-bold text-gray-700 focus:outline-none focus:ring-1 focus:ring-[#800A0A] focus:border-[#800A0A] cursor-pointer",children:[(0,t.jsx)("option",{value:"เสื้อผ้าและเครื่องแบบ",children:"เสื้อผ้าและเครื่องแบบ (Apparel & Clothing)"}),(0,t.jsx)("option",{value:"อุปกรณ์เสริมและอื่นๆ",children:"อุปกรณ์เสริมและอื่นๆ (Supplies & Accessories)"})]}),(0,t.jsx)(f.ChevronDown,{className:"w-4 h-4 text-gray-400 absolute right-3.5 top-1/2 -translate-y-1/2 pointer-events-none"})]})]}),(0,t.jsxs)("div",{className:"flex flex-col space-y-1.5",children:[(0,t.jsx)("label",{className:"font-bold text-gray-700",children:"ไอคอนหมวดหมู่"}),(0,t.jsx)("div",{className:"grid grid-cols-4 gap-2 text-center",children:[{id:"shirt",label:"เสื้อยืด/ปก"},{id:"hoodie",label:"เสื้อฮู้ด"},{id:"jacket",label:"เสื้อช็อป/ช่าง"},{id:"accessories",label:"อุปกรณ์เสริม"}].map(e=>(0,t.jsx)("button",{type:"button",onClick:()=>eH(e.id),className:`p-2 rounded-xl border text-[10px] font-bold transition-all cursor-pointer ${eX===e.id?"bg-[#800A0A]/5 border-[#800A0A] text-[#800A0A]":"border-gray-200 hover:bg-gray-50 text-gray-500"}`,children:e.label},e.id))})]}),(0,t.jsxs)("div",{className:"pt-4 flex space-x-2",children:[(0,t.jsx)("button",{type:"button",onClick:()=>{eB(!1),eJ(null)},className:"flex-1 border border-gray-250 hover:bg-gray-50 text-gray-755 font-bold py-2.5 rounded-xl transition-colors cursor-pointer",children:"ยกเลิก"}),(0,t.jsx)("button",{type:"submit",className:"flex-1 bg-[#800A0A] hover:bg-[#991B1B] text-white font-bold py-2.5 rounded-xl shadow-sm transition-colors cursor-pointer",children:"บันทึกการแก้ไข"})]})]})]})}),eZ&&eY&&(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-xs animate-in fade-in duration-200",children:(0,t.jsxs)("div",{className:"bg-white rounded-3xl w-full max-w-2xl overflow-hidden shadow-2xl flex flex-col border border-gray-100 text-left animate-in zoom-in-95 duration-200",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.5 text-[#800A0A]",children:[(0,t.jsx)(i.ShoppingBag,{className:"w-5 h-5"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-base font-black text-gray-900 leading-none",children:"จัดสรรสินค้าในหมวดหมู่"}),(0,t.jsxs)("span",{className:"text-[10px] text-gray-400 font-medium block mt-1",children:["หมวดหมู่ปัจจุบัน: ",eY.name," (",eY.parentCategory||"เสื้อผ้าและเครื่องแบบ",")"]})]})]}),(0,t.jsx)("button",{onClick:()=>{eQ(!1),e0(null)},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)(k.X,{className:"w-5 h-5"})})]}),(0,t.jsxs)("form",{onSubmit:e=>{if(e.preventDefault(),!eY)return;let t=eK.map(e=>e5.includes(e.id)?{...e,categoryId:eY.id}:e.categoryId===eY.id?{...e,categoryId:""}:e);O.default.updateProducts(t),eV(t),eQ(!1),e0(null),tU("อัปเดตการจับคู่หมวดหมู่สินค้าเรียบร้อยแล้ว","success")},className:"flex flex-col flex-1 overflow-hidden",children:[(0,t.jsxs)("div",{className:"p-4 border-b border-gray-100 bg-gray-50/30 flex items-center relative",children:[(0,t.jsx)(p.Search,{className:"w-4 h-4 text-gray-450 absolute left-8 pointer-events-none"}),(0,t.jsx)("input",{type:"text",placeholder:"ค้นหาสินค้าจากชื่อ...",value:e2,onChange:e=>e4(e.target.value),className:"w-full border border-gray-200 bg-white rounded-xl py-2 pl-11 pr-4 text-xs focus:outline-none focus:ring-1 focus:ring-[#800A0A] focus:border-[#800A0A] text-gray-800 font-medium"})]}),(0,t.jsx)("div",{className:"p-5 overflow-y-auto max-h-[350px] space-y-2",children:eK.filter(e=>e.name.toLowerCase().includes(e2.toLowerCase())).map(e=>{let s=e5.includes(e.id),r=e$.find(t=>t.id===e.categoryId);return(0,t.jsxs)("div",{onClick:()=>{s?e1(e5.filter(t=>t!==e.id)):e1([...e5,e.id])},className:`flex items-center justify-between p-3 rounded-xl border transition-all cursor-pointer select-none ${s?"bg-[#800A0A]/5 border-[#800A0A]":"border-gray-150 hover:bg-gray-50/50"}`,children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3.5",children:[(0,t.jsx)("div",{className:`w-4 h-4 rounded-md border flex items-center justify-center transition-all ${s?"bg-[#800A0A] border-[#800A0A] text-white":"border-gray-300"}`,children:s&&(0,t.jsx)(w.Check,{className:"w-3 h-3 stroke-[3]"})}),(0,t.jsxs)("div",{className:"text-left",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)("span",{className:"font-extrabold text-gray-800 text-[11px] block leading-none",children:e.name}),(0,t.jsx)("span",{className:`text-[8px] font-bold px-1.5 py-0.5 rounded ${!1!==e.inStock?"bg-emerald-50 text-emerald-600":"bg-red-50 text-red-600"}`,children:!1!==e.inStock?"มีสินค้า":"หมด (Sold Out)"})]}),(0,t.jsxs)("span",{className:"text-[9px] text-gray-400 font-medium block mt-1",children:["รหัสสินค้า: ",e.id," | ราคา: ฿",e.price]})]})]}),(0,t.jsx)("div",{children:e.categoryId?(0,t.jsx)("span",{className:`text-[9px] font-bold px-2 py-0.5 rounded-full ${e.categoryId===eY.id?"bg-[#800A0A]/10 text-[#800A0A]":"bg-gray-100 text-gray-400"}`,children:r?r.name:"มีหมวดหมู่แล้ว"}):(0,t.jsx)("span",{className:"text-[9px] font-medium text-gray-300 px-2 py-0.5",children:"ยังไม่มีหมวดหมู่"})})]},e.id)})}),(0,t.jsxs)("div",{className:"p-4 border-t border-gray-100 bg-gray-50/50 flex space-x-2 text-xs",children:[(0,t.jsx)("button",{type:"button",onClick:()=>{eQ(!1),e0(null)},className:"flex-1 border border-gray-250 hover:bg-gray-50 text-gray-755 font-bold py-2.5 rounded-xl transition-colors cursor-pointer",children:"ยกเลิก"}),(0,t.jsx)("button",{type:"submit",className:"flex-1 bg-[#800A0A] hover:bg-[#991B1B] text-white font-bold py-2.5 rounded-xl shadow-sm transition-colors cursor-pointer",children:"บันทึกการจัดหมวดหมู่สินค้า"})]})]})]})})]}),"orders"===ea&&(0,t.jsxs)("div",{className:"space-y-6 animate-in fade-in duration-300",children:[(0,t.jsx)("div",{className:"flex justify-between items-center",children:(0,t.jsx)("h1",{className:"text-2xl font-black text-gray-900 leading-none",children:"Order Overview"})}),(0,t.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6",children:[(0,t.jsx)("div",{className:"bg-white rounded-2xl border border-gray-150 p-5 shadow-xs relative flex items-center justify-between",children:(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("span",{className:"text-[10px] text-gray-400 font-bold uppercase tracking-wider block",children:"คำสั่งซื้อทั้งหมด"}),(0,t.jsx)("span",{className:"text-3xl font-black text-gray-900 block",children:em.length+211})]})}),(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-150 p-5 shadow-xs relative flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("span",{className:"text-[10px] text-gray-400 font-bold uppercase tracking-wider block",children:"รอดำเนินการ"}),(0,t.jsx)("span",{className:"text-3xl font-black text-gray-900 block",children:em.filter(e=>"pending"===e.status).length+44})]}),(0,t.jsx)("span",{className:"w-7 h-7 rounded-full bg-amber-500 text-white text-[11px] font-bold flex items-center justify-center",children:em.filter(e=>"pending"===e.status).length+44})]}),(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-150 p-5 shadow-xs relative flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("span",{className:"text-[10px] text-gray-400 font-bold uppercase tracking-wider block",children:"กำลังจัดส่ง"}),(0,t.jsx)("span",{className:"text-3xl font-black text-gray-900 block",children:em.filter(e=>"processing"===e.status||"shipped"===e.status).length+101})]}),(0,t.jsx)("span",{className:"w-7 h-7 rounded-full bg-blue-600 text-white text-[11px] font-bold flex items-center justify-center",children:em.filter(e=>"processing"===e.status||"shipped"===e.status).length+101})]}),(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-150 p-5 shadow-xs relative flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("span",{className:"text-[10px] text-gray-400 font-bold uppercase tracking-wider block",children:"สำเร็จแล้ว"}),(0,t.jsx)("span",{className:"text-3xl font-black text-gray-900 block",children:em.filter(e=>"delivered"===e.status).length+65})]}),(0,t.jsx)("span",{className:"w-7 h-7 rounded-full bg-green-600 text-white text-[11px] font-bold flex items-center justify-center",children:em.filter(e=>"delivered"===e.status).length+65})]})]}),(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-150 p-5 shadow-xs space-y-4",children:[(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center space-y-3 sm:space-y-0",children:[(0,t.jsx)("h2",{className:"text-sm font-black text-gray-950",children:"เลขคำสั่งซื้อ"}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3 w-full sm:w-auto",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2 bg-gray-50 border border-gray-200 rounded-xl px-3 py-2 text-xs font-bold text-gray-750",children:[(0,t.jsx)("span",{className:"text-gray-400",children:"📅"}),(0,t.jsx)("input",{type:"date",value:e7,onChange:e=>te(e.target.value),className:"bg-transparent border-none text-xs focus:outline-none cursor-pointer"})]}),(0,t.jsx)("button",{type:"button",onClick:()=>tU("ส่งออกข้อมูลรายงานสำเร็จแล้ว","success"),className:"bg-[#800A0A] hover:bg-[#991B1B] text-white font-bold text-xs px-4 py-2 rounded-xl transition-all cursor-pointer shadow-sm",children:"ส่งออกข้อมูล"})]})]}),(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)("table",{className:"w-full text-left text-xs border-collapse min-w-[900px] whitespace-nowrap",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:"bg-[#FAF8F5] text-gray-600 font-bold uppercase border-b border-gray-150",children:[(0,t.jsx)("th",{className:"py-3 px-4",children:"เลขคำสั่งซื้อ"}),(0,t.jsx)("th",{className:"py-3 px-4",children:"ชื่อผู้ซื้อ"}),(0,t.jsx)("th",{className:"py-3 px-4",children:"ร้านค้า"}),(0,t.jsx)("th",{className:"py-3 px-4",children:"ยอดรวม"}),(0,t.jsx)("th",{className:"py-3 px-4",children:"ชำระเงิน"}),(0,t.jsx)("th",{className:"py-3 px-4",children:"สถานะ"}),(0,t.jsx)("th",{className:"py-3 px-4 text-center",children:"การดำเนินการ"})]})}),(0,t.jsx)("tbody",{className:"divide-y divide-gray-100 font-medium text-gray-800",children:em.length>0?em.map(e=>{let s="bank_transfer"===e.paymentMethod||"qr_code"===e.paymentMethod?"โอนเงิน":"cooperative"===e.paymentMethod?"จ่ายที่สหกรณ์":"เก็บเงินปลายทาง",r=e.items[0]?.product?.merchantEmail,a=eC.find(e=>e.email?.toLowerCase()===r?.toLowerCase()),l=a?a.name:e.items[0]?.product?.name?"ร้านค้าสมาชิก":"ร้านค้าส่วนกลาง";return(0,t.jsxs)("tr",{className:"hover:bg-gray-50/50 transition-colors",children:[(0,t.jsxs)("td",{className:"py-3.5 px-4 font-bold text-gray-950",children:["#",e.id]}),(0,t.jsx)("td",{className:"py-3.5 px-4",children:e.shippingAddress?.fullName||"ลูกค้าทั่วไป"}),(0,t.jsx)("td",{className:"py-3.5 px-4",children:l}),(0,t.jsxs)("td",{className:"py-3.5 px-4 font-bold",children:["฿",e.totalAmount.toLocaleString()]}),(0,t.jsx)("td",{className:"py-3.5 px-4",children:s}),(0,t.jsx)("td",{className:"py-3.5 px-4",children:(0,t.jsx)("span",{className:`inline-block px-2.5 py-0.5 rounded-full text-[10px] font-bold ${"pending"===e.status?"bg-amber-100 text-amber-800":"delivered"===e.status?"bg-green-100 text-green-800":"bg-blue-100 text-blue-800"}`,children:"pending"===e.status?"รอตรวจสอบ":"delivered"===e.status?"สำเร็จแล้ว":"กำลังดำเนินการ"})}),(0,t.jsx)("td",{className:"py-3.5 px-4 text-center",children:(0,t.jsx)("button",{onClick:()=>{e8(e),e6(!0)},className:"bg-[#1D4ED8] hover:bg-[#1E40AF] text-white text-[10px] font-bold px-3 py-1.5 rounded-lg transition-colors cursor-pointer",children:"ดูรายละเอียด"})})]},e.id)}):(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:7,className:"py-12 text-center text-gray-400 font-light bg-gray-50/30 rounded-b-xl",children:(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center space-y-1.5",children:[(0,t.jsx)("span",{className:"text-2xl",children:"📦"}),(0,t.jsx)("span",{className:"font-bold text-gray-700 text-xs",children:"ยังไม่มีรายการคำสั่งซื้อในระบบ"}),(0,t.jsx)("span",{className:"text-[11px] text-gray-400",children:"เมื่อมีลูกค้าสั่งซื้อสินค้า รายการคำสั่งซื้อจะแสดงที่นี่"})]})})})})]})})]}),e9&&e3&&(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-xs animate-in fade-in duration-200",children:(0,t.jsxs)("div",{className:"bg-white rounded-3xl w-full max-w-4xl overflow-hidden shadow-2xl flex flex-col border border-gray-100 text-left animate-in zoom-in-95 duration-200",children:[(0,t.jsxs)("div",{className:"p-5 border-b border-gray-150 flex justify-between items-center bg-gray-50/50",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,t.jsxs)("h3",{className:"text-base font-black text-gray-900 leading-none",children:["รายละเอียดคำสั่งซื้อ #",e3.id]}),(0,t.jsx)("span",{className:"inline-block px-2.5 py-0.5 rounded-full text-[10px] font-bold bg-green-100 text-green-800",children:"โอนเงินแล้ว"})]}),(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)("button",{onClick:()=>window.print(),className:"bg-[#800A0A] hover:bg-[#991B1B] text-white text-[10px] font-bold px-3.5 py-2 rounded-xl transition-colors cursor-pointer flex items-center space-x-1.5 shadow-sm",children:(0,t.jsx)("span",{children:"Print Invoice"})}),(0,t.jsx)("button",{onClick:()=>{e6(!1),e8(null)},className:"p-1.5 hover:bg-gray-250/50 text-gray-400 hover:text-gray-700 rounded-full transition-colors cursor-pointer",children:(0,t.jsx)(k.X,{className:"w-5 h-5"})})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 p-6 overflow-y-auto max-h-[70vh]",children:[(0,t.jsxs)("div",{className:"space-y-5",children:[(0,t.jsxs)("div",{className:"bg-[#FAF8F5] rounded-2xl p-5 border border-gray-150 text-xs",children:[(0,t.jsx)("h4",{className:"font-black text-gray-950 mb-3 text-sm pb-1.5 border-b border-gray-200",children:"ข้อมูลผู้สั่งซื้อ (Customer Profile)"}),(0,t.jsxs)("div",{className:"space-y-2 font-medium text-gray-700",children:[(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"font-bold text-gray-900",children:"รหัสนักศึกษา:"}),(0,t.jsx)("span",{children:e3.shippingAddress.studentId||"65301040088"})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"font-bold text-gray-900",children:"ชื่อ-นามสกุล:"}),(0,t.jsx)("span",{children:e3.shippingAddress.fullName})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"font-bold text-gray-900",children:"เบอร์โทรศัพท์:"}),(0,t.jsx)("span",{children:e3.shippingAddress.phone})]}),(0,t.jsxs)("div",{className:"flex flex-col pt-1.5 border-t border-dashed border-gray-200",children:[(0,t.jsx)("span",{className:"font-bold text-gray-900 mb-0.5",children:"ที่อยู่จัดส่ง:"}),(0,t.jsxs)("span",{className:"leading-relaxed text-gray-600",children:[e3.shippingAddress.addressLine1," ",e3.shippingAddress.addressLine2||""," ",e3.shippingAddress.city," ",e3.shippingAddress.postalCode]})]})]})]}),(0,t.jsxs)("div",{className:"bg-[#FAF8F5] rounded-2xl p-5 border border-gray-150 text-xs",children:[(0,t.jsx)("h4",{className:"font-black text-gray-950 mb-3 text-sm pb-1.5 border-b border-gray-200",children:"หลักฐานการชำระเงิน (Payment Proof)"}),"bank_transfer"===e3.paymentMethod||"qr_code"===e3.paymentMethod?(0,t.jsxs)("div",{className:"max-w-[280px] mx-auto bg-white rounded-xl shadow-md border border-gray-100 overflow-hidden flex flex-col font-sans select-none",children:[(0,t.jsxs)("div",{className:"bg-[#00A859] p-3 text-white text-center flex items-center justify-center space-x-1.5",children:[(0,t.jsx)("div",{className:"w-4 h-4 rounded-full bg-white text-[#00A859] flex items-center justify-center",children:(0,t.jsx)(w.Check,{className:"w-3 h-3 stroke-[4]"})}),(0,t.jsx)("span",{className:"font-bold text-[11px] tracking-wide",children:"ทำรายการสำเร็จ (K-Plus E-Slip)"})]}),(0,t.jsxs)("div",{className:"p-4 space-y-3 text-[10px] text-gray-700",children:[(0,t.jsxs)("div",{className:"flex justify-between border-b border-gray-100 pb-1.5",children:[(0,t.jsx)("span",{className:"text-gray-400",children:"วันที่-เวลาโอน"}),(0,t.jsx)("span",{className:"font-semibold text-gray-800",children:"16 พ.ค. 2565 - 10:20 น."})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("span",{className:"text-gray-400 block",children:"จาก (ผู้โอน)"}),(0,t.jsx)("span",{className:"font-bold text-gray-800 text-[11px]",children:e3.shippingAddress.fullName}),(0,t.jsx)("span",{className:"text-gray-400 block text-[9px]",children:"ธนาคารกสิกรไทย • xxx-x-x6789-x"})]}),(0,t.jsxs)("div",{className:"space-y-1 pt-1.5 border-t border-dashed border-gray-100",children:[(0,t.jsx)("span",{className:"text-gray-400 block",children:"ไปยัง (ผู้รับโอน)"}),(0,t.jsx)("span",{className:"font-bold text-gray-800 text-[11px]",children:"วิทยาลัยเทคนิคเชียงใหม่ (CMTC SHOP)"}),(0,t.jsx)("span",{className:"text-gray-400 block text-[9px]",children:"ธนาคารกรุงไทย • xxx-x-x1234-x"})]}),(0,t.jsxs)("div",{className:"pt-2 border-t border-gray-150 flex justify-between items-center text-xs",children:[(0,t.jsx)("span",{className:"font-extrabold text-gray-900",children:"จำนวนเงิน"}),(0,t.jsxs)("span",{className:"font-black text-[#00A859] text-sm",children:["฿",e3.totalAmount.toLocaleString(),".00"]})]}),(0,t.jsxs)("div",{className:"flex justify-between text-[9px] text-gray-400",children:[(0,t.jsx)("span",{children:"ค่าธรรมเนียม"}),(0,t.jsx)("span",{children:"฿0.00"})]}),(0,t.jsx)("div",{className:"text-center pt-2 text-[8px] text-gray-300 border-t border-gray-100 font-mono",children:"Ref: 0121371020304050"})]})]}):"cooperative"===e3.paymentMethod?(0,t.jsxs)("div",{className:"p-4 bg-amber-50 rounded-xl border border-amber-200 text-center space-y-1",children:[(0,t.jsx)("span",{className:"text-lg",children:"🏢"}),(0,t.jsx)("p",{className:"font-bold text-amber-850 text-xs",children:"ชำระผ่านบัญชีปันผลสหกรณ์"}),(0,t.jsx)("p",{className:"text-[10px] text-amber-700",children:"หักเงินปันผล/ยอดจองสหกรณ์วิทยาลัยเรียบร้อยแล้ว"})]}):(0,t.jsxs)("div",{className:"p-4 bg-gray-50 rounded-xl border border-gray-200 text-center space-y-1",children:[(0,t.jsx)("span",{className:"text-lg",children:"📦"}),(0,t.jsx)("p",{className:"font-bold text-gray-700 text-xs",children:"ชำระปลายทาง (Cash on Delivery)"}),(0,t.jsx)("p",{className:"text-[10px] text-gray-500",children:"เรียกเก็บยอดจำนวนเงินสดเมื่อนำส่งพัสดุ"})]})]})]}),(0,t.jsxs)("div",{className:"space-y-5",children:[(0,t.jsxs)("div",{className:"text-xs",children:[(0,t.jsx)("h4",{className:"font-black text-gray-950 mb-3 text-sm pb-1.5 border-b border-gray-200",children:"รายการสินค้า (Order Items)"}),(0,t.jsx)("div",{className:"space-y-3",children:e3.items.map((e,s)=>(0,t.jsxs)("div",{className:"flex justify-between items-center p-2 rounded-xl bg-gray-50 border border-gray-150",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,t.jsx)("div",{className:"w-10 h-10 rounded-lg bg-white border border-gray-200 flex items-center justify-center text-lg text-gray-500 shadow-2xs",children:"👕"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"font-extrabold text-gray-905 block leading-tight",children:e.product.name}),(0,t.jsxs)("span",{className:"text-[10px] text-gray-400 block mt-1",children:["ไซส์: ",e.size||"L"," | จำนวน: x",e.quantity]})]})]}),(0,t.jsxs)("span",{className:"font-extrabold text-gray-800 text-right",children:["฿",(e.price*e.quantity).toLocaleString()]})]},s))})]}),(0,t.jsxs)("div",{className:"bg-gray-50 rounded-xl p-4 space-y-2 text-xs border border-gray-150",children:[(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-gray-500",children:"ยอดรวมสินค้า (Subtotal):"}),(0,t.jsxs)("span",{className:"font-bold text-gray-800",children:["฿",(e3.totalAmount-50).toLocaleString()]})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-gray-500",children:"ค่าจัดส่ง (Shipping Fee):"}),(0,t.jsx)("span",{className:"font-bold text-gray-800",children:"฿50"})]}),(0,t.jsxs)("div",{className:"flex justify-between border-t border-gray-200 pt-2 text-sm",children:[(0,t.jsx)("span",{className:"font-black text-gray-900",children:"ยอดรวมสุทธิ (Grand Total):"}),(0,t.jsxs)("span",{className:"font-black text-[#800A0A]",children:["฿",e3.totalAmount.toLocaleString()]})]})]}),(0,t.jsxs)("div",{className:"text-xs",children:[(0,t.jsx)("h4",{className:"font-black text-gray-950 mb-4 text-sm pb-1.5 border-b border-gray-200",children:"ประวัติสถานะ (Timeline Log)"}),(0,t.jsxs)("div",{className:"relative pl-6 space-y-4 before:content-[''] before:absolute before:left-[5px] before:top-2 before:bottom-2 before:w-[2px] before:bg-gray-250",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("span",{className:"absolute -left-[25px] top-1 w-3.5 h-3.5 rounded-full bg-green-600 border-2 border-white flex items-center justify-center"}),(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)("span",{className:"font-bold text-gray-900",children:"สั่งซื้อสำเร็จ (Order Placed)"}),(0,t.jsx)("span",{className:"text-[10px] text-gray-400 mt-0.5",children:"16 พ.ค. 2565 - 10:15 น."})]})]}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("span",{className:`absolute -left-[25px] top-1 w-3.5 h-3.5 rounded-full border-2 border-white flex items-center justify-center ${"cash_on_delivery"!==e3.paymentMethod?"bg-green-600":"bg-gray-300"}`}),(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)("span",{className:"font-bold text-gray-900",children:"ชำระเงินเรียบร้อย (Payment Verified)"}),(0,t.jsx)("span",{className:"text-[10px] text-gray-400 mt-0.5",children:"16 พ.ค. 2565 - 10:20 น."})]})]}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("span",{className:`absolute -left-[25px] top-1 w-3.5 h-3.5 rounded-full border-2 border-white flex items-center justify-center ${"pending"!==e3.status&&"cancelled"!==e3.status?"bg-green-600":"bg-gray-300"}`}),(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)("span",{className:"font-bold text-gray-900",children:"กำลังเตรียมจัดส่ง (Processing)"}),(0,t.jsx)("span",{className:"text-[10px] text-gray-400 mt-0.5",children:"pending"!==e3.status&&"cancelled"!==e3.status?"ได้รับการยืนยันและรอการส่งมอบพัสดุ":"รอแอดมินตรวจสอบยอดโอนเงิน"})]})]}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("span",{className:`absolute -left-[25px] top-1 w-3.5 h-3.5 rounded-full border-2 border-white flex items-center justify-center ${"shipped"===e3.status||"delivered"===e3.status?"bg-green-600":"bg-gray-300"}`}),(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)("span",{className:"font-bold text-gray-900",children:"จัดส่งสินค้าแล้ว (Shipped)"}),(0,t.jsx)("span",{className:"text-[10px] text-gray-400 mt-0.5",children:"shipped"===e3.status||"delivered"===e3.status?`เลขพัสดุ: ${e3.trackingCode}`:"อยู่ระหว่างดำเนินการในระบบ"})]})]})]})]})]})]}),(0,t.jsxs)("div",{className:"p-4 border-t border-gray-150 bg-gray-50/50 flex flex-wrap gap-2 text-xs justify-end",children:["pending"===e3.status&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",onClick:()=>tH(e3.id,"processing"),className:"bg-green-600 hover:bg-green-700 text-white rounded-xl px-5 py-2.5 font-bold cursor-pointer transition-colors shadow-sm",children:"อนุมัติการชำระเงิน"}),(0,t.jsx)("button",{type:"button",onClick:()=>tH(e3.id,"cancelled"),className:"bg-red-650 hover:bg-red-700 text-white rounded-xl px-5 py-2.5 font-bold cursor-pointer transition-colors shadow-sm",children:"ปฏิเสธคำสั่งซื้อ"})]}),"processing"===e3.status&&(0,t.jsx)("button",{type:"button",onClick:()=>tH(e3.id,"shipped"),className:"bg-[#800A0A] hover:bg-[#991B1B] text-white rounded-xl px-5 py-2.5 font-bold cursor-pointer transition-colors shadow-sm",children:"ยืนยันการจัดส่งสินค้า (Shipped)"}),(0,t.jsx)("button",{type:"button",onClick:()=>{e6(!1),e8(null)},className:"border border-gray-250 hover:bg-gray-50 text-gray-755 font-bold px-5 py-2.5 rounded-xl cursor-pointer transition-colors",children:"ปิดหน้าต่าง"})]})]})})]}),"shipping"===ea&&(0,t.jsxs)("div",{className:"space-y-6 text-left",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-2xl font-black text-gray-900 leading-none",children:"ภาพรวมและกำกับดูแลการจัดส่ง (Shipping Analytics & Audit)"}),(0,t.jsx)("p",{className:"text-xs text-gray-400 font-bold mt-1.5",children:"ตรวจสอบประสิทธิภาพการส่งมอบสินค้าของแต่ละร้านค้า ตั้งค่าผู้ให้บริการขนส่งกลาง และดูรายการตีกลับที่มีปัญหา"})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4 font-prompt",children:[(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-150 p-5 shadow-xs flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold text-gray-450 uppercase tracking-wider block",children:"จัดส่งพัสดุสำเร็จแล้ว (Total Shipped)"}),(0,t.jsx)("span",{className:"text-2xl font-black text-emerald-600 block",children:em.filter(e=>"shipped"===e.status||"delivered"===e.status).length+65})]}),(0,t.jsx)("div",{className:"w-10 h-10 rounded-xl bg-emerald-50 text-emerald-500 border border-emerald-100 flex items-center justify-center font-bold text-lg",children:"🚚"})]}),(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-150 p-5 shadow-xs flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold text-gray-450 uppercase tracking-wider block",children:"รอผู้ขายจัดส่ง (Pending Fulfillment)"}),(0,t.jsx)("span",{className:"text-2xl font-black text-amber-600 block",children:em.filter(e=>"processing"===e.status).length+101})]}),(0,t.jsx)("div",{className:"w-10 h-10 rounded-xl bg-amber-50 text-amber-500 border border-amber-100 flex items-center justify-center font-bold text-lg",children:"📦"})]}),(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-150 p-5 shadow-xs flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold text-gray-455 uppercase tracking-wider block",children:"อัตราการส่งสำเร็จ (Delivery Success Rate)"}),(0,t.jsx)("span",{className:"text-2xl font-black text-blue-600 block",children:(X=(U=em.filter(e=>"shipped"===e.status||"delivered"===e.status).length+65)+(em.filter(e=>"processing"===e.status).length+101))>0?`${Math.round(U/X*100)}%`:"100%"})]}),(0,t.jsx)("div",{className:"w-10 h-10 rounded-xl bg-blue-50 text-blue-500 border border-blue-100 flex items-center justify-center font-bold text-lg",children:"📈"})]})]}),(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-150 p-5 shadow-xs space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"font-extrabold text-gray-900 text-sm",children:"การติดตามประสิทธิภาพร้านค้า (Vendor Fulfillment SLA Tracking)"}),(0,t.jsx)("p",{className:"text-[11px] text-gray-400 mt-1",children:"ตรวจสอบสถานะและเวลาเฉลี่ยที่ร้านค้าจัดการออเดอร์เพื่อกำกับดูแลคุณภาพการบริการ"})]}),(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)("table",{className:"w-full text-left text-xs border-collapse min-w-[750px] whitespace-nowrap",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:"border-b border-gray-150 text-gray-400 font-bold",children:[(0,t.jsx)("th",{className:"pb-3 pr-4 font-bold",children:"ชื่อร้านค้า / แผนกวิชา"}),(0,t.jsx)("th",{className:"pb-3 px-4 font-bold",children:"ออเดอร์ทั้งหมด"}),(0,t.jsx)("th",{className:"pb-3 px-4 font-bold",children:"ออเดอร์รอจัดส่ง"}),(0,t.jsx)("th",{className:"pb-3 px-4 font-bold",children:"จัดส่งสำเร็จแล้ว"}),(0,t.jsx)("th",{className:"pb-3 px-4 font-bold",children:"อัตราตรงเวลา (SLA)"}),(0,t.jsx)("th",{className:"pb-3 pl-4 font-bold text-right",children:"สถานะร้านค้า"})]})}),(0,t.jsx)("tbody",{className:"divide-y divide-gray-100 font-medium text-gray-700",children:eC.length>0?eC.map(e=>{let s=em.filter(t=>t.items&&t.items.some(t=>{let s=eK.find(e=>e.id===t.product?.id),r=s?s.merchantEmail:t.product?.merchantEmail;return r&&r.toLowerCase()===e.email.toLowerCase()})),r=s.length,a=s.filter(e=>"processing"===e.status).length,l=s.filter(e=>"shipped"===e.status||"delivered"===e.status).length,n=r>0?0===a?"99%":`${Math.max(70,Math.round(100-a/r*100))}%`:"100%",c="bg-green-50 text-green-700 border-green-200",d="ยอดเยี่ยม (Excellent)";return a>2?(c="bg-red-50 text-red-700 border-red-200",d="ควรเฝ้าระวัง (Late)"):a>0&&(c="bg-amber-50 text-amber-700 border-amber-200",d="ปกติ (On track)"),(0,t.jsxs)("tr",{className:"hover:bg-gray-50/40",children:[(0,t.jsxs)("td",{className:"py-3.5 pr-4 font-bold text-gray-950 flex items-center space-x-2.5",children:[(0,t.jsx)("span",{className:"text-base",children:"🏬"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"block leading-none",children:e.name}),(0,t.jsx)("span",{className:"block text-[9px] text-gray-400 font-normal mt-1",children:e.email})]})]}),(0,t.jsx)("td",{className:"py-3.5 px-4 font-bold text-gray-900",children:r}),(0,t.jsx)("td",{className:"py-3.5 px-4 font-bold text-amber-600",children:a}),(0,t.jsx)("td",{className:"py-3.5 px-4 font-bold text-emerald-600",children:l}),(0,t.jsx)("td",{className:"py-3.5 px-4 font-mono text-gray-700 font-bold",children:n}),(0,t.jsx)("td",{className:"py-3.5 pl-4 text-right",children:(0,t.jsx)("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-bold border ${c}`,children:d})})]},e.email)}):(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:6,className:"py-8 text-center text-gray-400 italic",children:"ไม่พบรายชื่อร้านค้าในระบบที่ได้รับอนุมัติสิทธิ์"})})})]})})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-150 p-5 shadow-xs space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"font-extrabold text-gray-900 text-sm",children:"ผู้ให้บริการขนส่งของระบบ (Global Shipping Carriers)"}),(0,t.jsx)("p",{className:"text-[11px] text-gray-400 mt-1",children:"เปิดปิดหรือกำหนดค่าการจัดส่งพัสดุและพอร์ตการเชื่อมต่อ API ของขนส่งต่าง ๆ ที่ร้านค้าจะได้รับสิทธิ์"})]}),(0,t.jsxs)("div",{className:"space-y-3.5",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between border border-gray-150 p-3.5 rounded-xl bg-gray-50/50",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3 text-xs",children:[(0,t.jsx)("span",{className:"text-xl",children:"⚡"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"font-bold text-gray-950 block",children:"Flash Express API"}),(0,t.jsx)("span",{className:"text-[10px] text-emerald-600 font-bold block mt-0.5",children:"● Connected (Sandbox)"})]})]}),(0,t.jsx)("input",{type:"checkbox",checked:ej,onChange:e=>{eN(e.target.checked),tU(e.target.checked?"เปิดใช้งาน Flash Express API สำเร็จ":"ระงับใช้งาน Flash Express API ชั่วคราว","info")},className:"accent-[#800A0A] w-4 h-4 cursor-pointer"})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between border border-gray-150 p-3.5 rounded-xl bg-gray-50/50",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3 text-xs",children:[(0,t.jsx)("span",{className:"text-xl",children:"📦"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"font-bold text-gray-950 block",children:"Kerry Express Delivery"}),(0,t.jsx)("span",{className:"text-[10px] text-emerald-600 font-bold block mt-0.5",children:"● Connected (Production)"})]})]}),(0,t.jsx)("input",{type:"checkbox",checked:ef,onChange:e=>{ey(e.target.checked),tU(e.target.checked?"เปิดใช้งาน Kerry Express สำเร็จ":"ระงับใช้งาน Kerry Express ชั่วคราว","info")},className:"accent-[#800A0A] w-4 h-4 cursor-pointer"})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between border border-gray-150 p-3.5 rounded-xl bg-gray-50/50",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3 text-xs",children:[(0,t.jsx)("span",{className:"text-xl",children:"📮"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"font-bold text-gray-950 block",children:"ไปรษณีย์ไทย EMS"}),(0,t.jsx)("span",{className:"text-[10px] text-gray-400 font-bold block mt-0.5",children:"○ API Setup Pending"})]})]}),(0,t.jsx)("input",{type:"checkbox",checked:eg,onChange:e=>{eu(e.target.checked),tU(e.target.checked?"เปิดใช้งานไปรษณีย์ไทย EMS สำเร็จ":"ระงับใช้งานไปรษณีย์ไทย EMS ชั่วคราว","info")},className:"accent-[#800A0A] w-4 h-4 cursor-pointer"})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between border border-gray-150 p-3.5 rounded-xl bg-gray-50/50",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-3 text-xs",children:[(0,t.jsx)("span",{className:"text-xl",children:"🏢"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"font-bold text-gray-950 block",children:"รับเองที่สหกรณ์/แผนกวิชา (CMTC Pickup)"}),(0,t.jsx)("span",{className:"text-[10px] text-[#800A0A] font-bold block mt-0.5",children:"● Always Enabled for Campus"})]})]}),(0,t.jsx)("input",{type:"checkbox",disabled:!0,checked:ev,className:"accent-[#800A0A] w-4 h-4 opacity-50 cursor-not-allowed"})]})]})]}),(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-150 p-5 shadow-xs space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"font-extrabold text-gray-900 text-sm",children:"พัสดุจัดส่งที่มีปัญหา/ร้องเรียน (Disputes & Returned Packages)"}),(0,t.jsx)("p",{className:"text-[11px] text-gray-400 mt-1",children:"กำกับดูแลใบงานพัสดุส่งไม่สำเร็จ ตีกลับ หรือผู้ซื้อส่งข้อเรียกร้องความล่าช้า"})]}),(0,t.jsx)("div",{className:"space-y-3",children:(0,t.jsxs)("div",{className:"border border-gray-150 p-6 rounded-2xl bg-gray-50/50 text-xs text-center space-y-1.5",children:[(0,t.jsx)("span",{className:"text-2xl block",children:"✅"}),(0,t.jsx)("span",{className:"font-bold text-gray-700 block",children:"ไม่มีรายการพัสดุที่มีปัญหาหรือข้อเรียกร้องในขณะนี้"}),(0,t.jsx)("span",{className:"text-[11px] text-gray-400 block",children:"พัสดุทุกรายการอยู่ในการควบคุมและนำส่งตามปกติ"})]})})]})]})]}),"finance"===ea&&(0,t.jsxs)("div",{className:"space-y-6 text-left font-prompt",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-2xl font-black text-gray-900 leading-none",children:"รายงานการเงิน & การตั้งค่าค่าคอมมิชชั่น (Finance & Commission Settings)"}),(0,t.jsx)("p",{className:"text-xs text-gray-400 font-bold mt-1.5",children:"จัดการอัตราหักค่าคอมมิชชั่นร้านค้า กำหนดเกณฑ์ยอดขายขั้นบันได และตรวจสอบรายรับส่วนกลางของวิทยาลัย"})]}),(H=0,G=0,W=0,eC.forEach(e=>{let t=em.filter(t=>t.items&&t.items.some(t=>{let s=eK.find(e=>e.id===t.product?.id),r=s?s.merchantEmail:t.product?.merchantEmail;return r&&r.toLowerCase()===e.email.toLowerCase()})).reduce((e,t)=>e+t.totalAmount,0),s=B.default.calculateStoreCommission(t,th);H+=t,G+=s.commissionAmount,W+=s.netEarnings}),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-150 p-5 shadow-xs flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold text-gray-450 uppercase tracking-wider block",children:"ยอดขายรวมทุกร้านค้า (Gross GMV)"}),(0,t.jsxs)("span",{className:"text-2xl font-black text-gray-900 block",children:["฿",H.toLocaleString()]}),(0,t.jsxs)("span",{className:"text-[10px] text-gray-400 block font-normal",children:["จาก ",eC.length," ร้านค้าในระบบ"]})]}),(0,t.jsx)("div",{className:"w-11 h-11 rounded-xl bg-blue-50 text-blue-600 border border-blue-100 flex items-center justify-center font-bold text-lg",children:"💳"})]}),(0,t.jsxs)("div",{className:"bg-gradient-to-br from-[#800A0A] to-[#550507] text-white rounded-2xl p-5 shadow-md flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold text-[#FFD700] uppercase tracking-wider block",children:"รายได้ค่าคอมมิชชั่นของวิทยาลัย (Platform Revenue)"}),(0,t.jsxs)("span",{className:"text-2xl font-black text-white block",children:["฿",G.toLocaleString()]}),(0,t.jsxs)("span",{className:"text-[10px] text-amber-200 block font-normal",children:["สถานะ: ",th.enabled?`เปิดใช้งาน (${th.baseRatePercent}% / ขั้นบันได ${th.tierRatePercent}%)`:"ปิดใช้งาน"]})]}),(0,t.jsx)("div",{className:"w-11 h-11 rounded-xl bg-white/10 text-amber-300 border border-white/10 flex items-center justify-center font-bold text-xl",children:"🏛️"})]}),(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-150 p-5 shadow-xs flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold text-gray-450 uppercase tracking-wider block",children:"ยอดเงินสุทธิส่งมอบร้านค้า (Net Store Payout)"}),(0,t.jsxs)("span",{className:"text-2xl font-black text-emerald-600 block",children:["฿",W.toLocaleString()]}),(0,t.jsx)("span",{className:"text-[10px] text-gray-400 block font-normal",children:"หลังหักค่าธรรมเนียมแพลตฟอร์ม"})]}),(0,t.jsx)("div",{className:"w-11 h-11 rounded-xl bg-emerald-50 text-emerald-600 border border-emerald-100 flex items-center justify-center font-bold text-lg",children:"💰"})]})]}),(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-150 p-6 shadow-xs space-y-6",children:[(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between pb-4 border-b border-gray-100 gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)("span",{className:"w-2 h-2 rounded-full bg-[#800A0A]"}),(0,t.jsx)("h3",{className:"font-extrabold text-gray-900 text-sm sm:text-base",children:"การตั้งค่าอัตราค่าคอมมิชชั่นส่วนกลาง (Commission Control Panel)"})]}),(0,t.jsx)("p",{className:"text-xs text-gray-400 mt-1",children:"กำหนดอัตราหักรายได้ของร้านค้าเข้าวิทยาลัย และตั้งเงื่อนไขขั้นบันไดเมื่อยอดขายเกินเป้า"})]}),(0,t.jsxs)("label",{className:"inline-flex items-center space-x-2 cursor-pointer select-none bg-gray-50 border border-gray-200 px-3.5 py-1.5 rounded-xl",children:[(0,t.jsx)("input",{type:"checkbox",checked:tp,onChange:e=>tg(e.target.checked),className:"accent-[#800A0A] w-4 h-4 cursor-pointer"}),(0,t.jsx)("span",{className:"text-xs font-bold text-gray-700",children:tp?"เปิดใช้งานระบบหักค่าคอมมิชชั่น":"ปิดระบบหักค่าคอมมิชชั่น"})]})]}),(0,t.jsxs)("form",{onSubmit:e=>{e.preventDefault();let t={enabled:tp,baseRatePercent:Math.max(0,Number(tu)),isTieredEnabled:ty,tierThresholdAmount:Math.max(0,Number(tN)),tierRatePercent:Math.max(0,Number(tw))};B.default.saveCommissionSettings(t),tb(t),tU("บันทึกการตั้งค่าระบบค่าคอมมิชชั่นเรียบร้อยแล้ว","success")},className:"space-y-5",children:[(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 text-xs",children:[(0,t.jsxs)("div",{className:"bg-[#FAF8F5] border border-gray-200 rounded-xl p-4 space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("label",{className:"font-bold text-gray-800",children:"อัตราค่าคอมมิชชั่นเริ่มต้น"}),(0,t.jsx)("span",{className:"text-[10px] text-[#800A0A] font-bold",children:"Base Rate"})]}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{type:"number",min:"0",max:"50",step:"0.5",required:!0,value:tu,onChange:e=>tf(Number(e.target.value)),className:"w-full bg-white border border-gray-250 rounded-xl py-2 pl-3 pr-8 text-xs font-bold text-gray-900 focus:outline-none focus:ring-1 focus:ring-[#800A0A]"}),(0,t.jsx)("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 font-bold text-xs",children:"%"})]}),(0,t.jsx)("p",{className:"text-[10px] text-gray-400 leading-tight",children:"หักจากยอดขายของร้านค้าที่มียอดขายยังไม่ถึงเกณฑ์ขั้นบันได"})]}),(0,t.jsxs)("div",{className:"bg-[#FAF8F5] border border-gray-200 rounded-xl p-4 space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("label",{className:"font-bold text-gray-800",children:"เกณฑ์ยอดขายสะสมขั้นบันได"}),(0,t.jsx)("span",{className:"text-[10px] text-blue-700 font-bold",children:"Tier Threshold"})]}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{type:"number",min:"1000",step:"1000",required:!0,disabled:!ty,value:tN,onChange:e=>tv(Number(e.target.value)),className:`w-full bg-white border border-gray-250 rounded-xl py-2 pl-3 pr-8 text-xs font-bold text-gray-900 focus:outline-none focus:ring-1 focus:ring-[#800A0A] ${!ty?"opacity-50 cursor-not-allowed":""}`}),(0,t.jsx)("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 font-bold text-xs",children:"฿"})]}),(0,t.jsx)("p",{className:"text-[10px] text-gray-400 leading-tight",children:"เมื่อร้านค้าขายได้สะสมเกินเกณฑ์นี้ อัตราคอมมิชชั่นจะปรับเป็นเรตขั้นที่ 2"})]}),(0,t.jsxs)("div",{className:"bg-[#FAF8F5] border border-gray-200 rounded-xl p-4 space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("label",{className:"font-bold text-gray-800",children:"อัตราคอมมิชชั่นเมื่อเกินเกณฑ์"}),(0,t.jsx)("span",{className:"text-[10px] text-amber-700 font-bold",children:"Tier 2 Rate"})]}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{type:"number",min:"0",max:"50",step:"0.5",required:!0,disabled:!ty,value:tw,onChange:e=>tk(Number(e.target.value)),className:`w-full bg-white border border-gray-250 rounded-xl py-2 pl-3 pr-8 text-xs font-bold text-gray-900 focus:outline-none focus:ring-1 focus:ring-[#800A0A] ${!ty?"opacity-50 cursor-not-allowed":""}`}),(0,t.jsx)("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 font-bold text-xs",children:"%"})]}),(0,t.jsx)("p",{className:"text-[10px] text-gray-400 leading-tight",children:"อัตราที่จะนำมาคำนวณแทนเรตปกติเมื่อยอดขายของร้านค้าเกินเกณฑ์เป้าหมาย"})]})]}),(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row items-center justify-between pt-3 border-t border-gray-100 gap-3",children:[(0,t.jsxs)("label",{className:"flex items-center space-x-2 text-xs font-bold text-gray-700 cursor-pointer select-none",children:[(0,t.jsx)("input",{type:"checkbox",checked:ty,onChange:e=>tj(e.target.checked),className:"accent-[#800A0A] w-4 h-4 cursor-pointer"}),(0,t.jsx)("span",{children:"เปิดใช้งานระบบปรับค่าคอมมิชชั่นขั้นบันไดตามยอดขาย (Tiered Progressive Commission)"})]}),(0,t.jsx)("button",{type:"submit",className:"w-full sm:w-auto bg-[#800A0A] hover:bg-[#991B1B] text-white font-bold text-xs px-6 py-2.5 rounded-xl transition-all shadow-sm cursor-pointer",children:"บันทึกการตั้งค่าคอมมิชชั่น"})]})]})]}),(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-150 p-6 shadow-xs space-y-4",children:[(0,t.jsx)("div",{className:"flex justify-between items-center pb-2",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"font-extrabold text-gray-900 text-sm sm:text-base",children:"รายงานยอดขายและค่าคอมมิชชั่นแยกตามร้านค้า (Store Commission Breakdown)"}),(0,t.jsx)("p",{className:"text-xs text-gray-400 mt-0.5",children:"แสดงยอดขายสะสม สถานะอัตราที่ถูกคิด ยอดหัก และยอดเงินสุทธิที่เตรียมจัดสรรให้ร้านค้า"})]})}),(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)("table",{className:"w-full text-left text-xs border-collapse min-w-[850px]",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:"bg-[#FAF8F5] text-gray-600 font-bold uppercase border-b border-gray-150",children:[(0,t.jsx)("th",{className:"py-3 px-4",children:"ร้านค้า (Store)"}),(0,t.jsx)("th",{className:"py-3 px-4 text-right",children:"ยอดขายสะสม (Gross)"}),(0,t.jsx)("th",{className:"py-3 px-4 text-center",children:"สถานะเกณฑ์ยอดขาย"}),(0,t.jsx)("th",{className:"py-3 px-4 text-center",children:"อัตราคอมมิชชั่น"}),(0,t.jsx)("th",{className:"py-3 px-4 text-right",children:"ยอดหักคอมมิชชั่น"}),(0,t.jsx)("th",{className:"py-3 px-4 text-right",children:"ยอดเงินสุทธิร้านค้า"}),(0,t.jsx)("th",{className:"py-3 px-4 text-center",children:"การดำเนินการ"})]})}),(0,t.jsx)("tbody",{className:"divide-y divide-gray-100 font-medium text-gray-800",children:eC.map(e=>{let s=em.filter(t=>t.items&&t.items.some(t=>{let s=eK.find(e=>e.id===t.product?.id),r=s?s.merchantEmail:t.product?.merchantEmail;return r&&r.toLowerCase()===e.email.toLowerCase()})).reduce((e,t)=>e+t.totalAmount,0),r=B.default.calculateStoreCommission(s,th);return(0,t.jsxs)("tr",{className:"hover:bg-gray-50/50 transition-colors",children:[(0,t.jsx)("td",{className:"py-3 px-4",children:(0,t.jsxs)("div",{className:"flex items-center space-x-2.5",children:[(0,t.jsx)("div",{className:"w-8 h-8 rounded-lg bg-gray-100 flex items-center justify-center text-sm shadow-xs flex-shrink-0",children:e.logo||"🛍️"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"font-bold text-gray-900 block leading-tight",children:e.name}),(0,t.jsx)("span",{className:"text-[10px] text-gray-400 font-normal",children:e.email})]})]})}),(0,t.jsxs)("td",{className:"py-3 px-4 text-right font-black text-gray-900",children:["฿",s.toLocaleString()]}),(0,t.jsx)("td",{className:"py-3 px-4 text-center",children:r.isTier2?(0,t.jsx)("span",{className:"inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[10px] font-bold bg-amber-50 text-amber-700 border border-amber-200",children:(0,t.jsx)("span",{children:"🔥 เกินเกณฑ์ (Tier 2)"})}):(0,t.jsx)("span",{className:"inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[10px] font-bold bg-emerald-50 text-emerald-700 border border-emerald-200",children:(0,t.jsx)("span",{children:"✓ อัตราปกติ (Base)"})})}),(0,t.jsxs)("td",{className:"py-3 px-4 text-center font-bold text-gray-700",children:[r.effectiveRate,"%"]}),(0,t.jsxs)("td",{className:"py-3 px-4 text-right font-bold text-red-650",children:["-฿",r.commissionAmount.toLocaleString()]}),(0,t.jsxs)("td",{className:"py-3 px-4 text-right font-black text-emerald-600",children:["฿",r.netEarnings.toLocaleString()]}),(0,t.jsx)("td",{className:"py-3 px-4 text-center",children:(0,t.jsx)("button",{type:"button",onClick:()=>tU(`ส่งข้อมูลสรุปบัญชีและแจ้งโอนยอด ฿${r.netEarnings.toLocaleString()} ให้กับ ${e.name} แล้ว`,"success"),className:"bg-gray-100 hover:bg-gray-200 text-gray-700 text-[10px] font-bold px-3 py-1.5 rounded-lg transition-colors cursor-pointer",children:"สรุปยอดโอน"})})]},e.email)})})]})})]})]}))]}),"payouts"===ea&&(0,t.jsxs)("div",{className:"space-y-6 text-left font-prompt",children:[(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("h1",{className:"text-2xl font-black text-gray-900 leading-none flex items-center gap-2.5",children:[(0,t.jsx)("span",{children:"💸"}),(0,t.jsx)("span",{children:"จัดการและอนุมัติการถอนเงินร้านค้า (Payout Approvals)"})]}),(0,t.jsx)("p",{className:"text-xs text-gray-450 font-bold mt-1.5",children:"ตรวจสอบคำขอถอนเงินของผู้ขาย โอนเงินผ่านบัญชีธนาคาร/พร้อมเพย์ แนบสลิปหลักฐาน และอนุมัติการจ่ายเงิน"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 bg-emerald-50 border border-emerald-200 px-3.5 py-1.5 rounded-xl self-start sm:self-auto",children:[(0,t.jsx)("span",{className:"text-xs font-bold text-emerald-800",children:"คำขอรอตรวจสอบ:"}),(0,t.jsxs)("span",{className:"bg-emerald-600 text-white text-xs font-black px-2.5 py-0.5 rounded-lg shadow-xs",children:[tA.filter(e=>"pending"===e.status).length," รายการ"]})]})]}),(V=(K=tA.filter(e=>"pending"===e.status)).reduce((e,t)=>e+t.amount,0),Q=(Z=tA.filter(e=>"approved"===e.status)).reduce((e,t)=>e+t.amount,0),(0,t.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-amber-200/80 p-5 shadow-xs flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold text-amber-800 uppercase tracking-wider block",children:"ยอดเงินรออนุมัติโอน (Pending Payouts)"}),(0,t.jsxs)("span",{className:"text-2xl font-black text-gray-900 block",children:["฿",V.toLocaleString()]}),(0,t.jsxs)("span",{className:"text-[10px] text-gray-400 block font-normal",children:[K.length," คำขอที่รอการตรวจสอบ"]})]}),(0,t.jsx)("div",{className:"w-11 h-11 rounded-xl bg-amber-50 text-amber-600 border border-amber-100 flex items-center justify-center font-bold text-lg",children:"⏳"})]}),(0,t.jsxs)("div",{className:"bg-gradient-to-br from-emerald-600 to-teal-800 text-white rounded-2xl p-5 shadow-md flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold text-emerald-100 uppercase tracking-wider block",children:"โอนเงินสำเร็จสะสม (Total Settled)"}),(0,t.jsxs)("span",{className:"text-2xl font-black text-white block",children:["฿",Q.toLocaleString()]}),(0,t.jsxs)("span",{className:"text-[10px] text-emerald-100 block font-normal",children:[Z.length," รายการโอนเรียบร้อย"]})]}),(0,t.jsx)("div",{className:"w-11 h-11 rounded-xl bg-white/15 text-white border border-white/20 flex items-center justify-center font-bold text-xl",children:"✓"})]}),(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-150 p-5 shadow-xs flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold text-gray-450 uppercase tracking-wider block",children:"คำขอทั้งหมดในระบบ (Total Requests)"}),(0,t.jsx)("span",{className:"text-2xl font-black text-gray-900 block",children:tA.length}),(0,t.jsx)("span",{className:"text-[10px] text-gray-400 block font-normal",children:"ประวัติคำขอถอนเงินตั้งแต่เริ่มต้น"})]}),(0,t.jsx)("div",{className:"w-11 h-11 rounded-xl bg-blue-50 text-blue-600 border border-blue-100 flex items-center justify-center font-bold text-lg",children:"📊"})]})]})),(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-gray-150 p-6 shadow-xs space-y-4",children:[(0,t.jsx)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-2 pb-2",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"font-extrabold text-gray-900 text-sm sm:text-base",children:"รายการคำขอถอนเงินทั้งหมด (Merchant Withdrawal Requests)"}),(0,t.jsx)("p",{className:"text-xs text-gray-400 mt-0.5",children:'กดปุ่ม "อนุมัติ & แนบสลิปโอน" เมื่อทำการโอนเงินเข้าบัญชีร้านค้าเรียบร้อยแล้ว'})]})}),(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)("table",{className:"w-full text-left text-xs border-collapse min-w-[850px]",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:"bg-[#FAF8F5] text-gray-600 font-bold uppercase border-b border-gray-150",children:[(0,t.jsx)("th",{className:"py-3 px-4",children:"รหัสคำขอ"}),(0,t.jsx)("th",{className:"py-3 px-4",children:"ร้านค้า / ผู้ขอถอน"}),(0,t.jsx)("th",{className:"py-3 px-4",children:"วันที่ทำรายการ"}),(0,t.jsx)("th",{className:"py-3 px-4",children:"บัญชีธนาคารปลายทาง"}),(0,t.jsx)("th",{className:"py-3 px-4 text-right",children:"ยอดเงินที่ขอถอน"}),(0,t.jsx)("th",{className:"py-3 px-4 text-center",children:"สถานะ"}),(0,t.jsx)("th",{className:"py-3 px-4 text-center",children:"การดำเนินการ (Actions)"})]})}),(0,t.jsx)("tbody",{className:"divide-y divide-gray-100 font-medium text-gray-800",children:tA.length>0?tA.map(e=>(0,t.jsxs)("tr",{className:"hover:bg-gray-50/50 transition-colors",children:[(0,t.jsxs)("td",{className:"py-3.5 px-4 font-black text-gray-900",children:["#",e.id]}),(0,t.jsxs)("td",{className:"py-3.5 px-4",children:[(0,t.jsx)("div",{className:"font-bold text-gray-900",children:e.merchantName}),(0,t.jsx)("div",{className:"text-[11px] text-gray-400 font-normal",children:e.merchantEmail})]}),(0,t.jsx)("td",{className:"py-3.5 px-4 text-gray-500 text-[11px]",children:new Date(e.requestedAt).toLocaleDateString("th-TH",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}),(0,t.jsxs)("td",{className:"py-3.5 px-4",children:[(0,t.jsx)("div",{className:"font-bold text-gray-900",children:e.bankAccount.bankName}),(0,t.jsx)("div",{className:"text-[11px] text-gray-600 font-mono tracking-wide",children:e.bankAccount.accountNumber}),(0,t.jsxs)("div",{className:"text-[10.5px] text-gray-400",children:[e.bankAccount.accountName," ",e.bankAccount.promptPayNumber?`(PromptPay: ${e.bankAccount.promptPayNumber})`:""]})]}),(0,t.jsxs)("td",{className:"py-3.5 px-4 text-right font-black text-emerald-700 text-sm",children:["฿",e.amount.toLocaleString()]}),(0,t.jsx)("td",{className:"py-3.5 px-4 text-center",children:"approved"===e.status?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[10px] font-black bg-emerald-50 text-emerald-700 border border-emerald-200",children:[(0,t.jsx)("span",{children:"✓"}),(0,t.jsx)("span",{children:"โอนเงินสำเร็จ"})]}):"rejected"===e.status?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[10px] font-black bg-red-50 text-red-700 border border-red-200",children:[(0,t.jsx)("span",{children:"✕"}),(0,t.jsx)("span",{children:"ปฏิเสธ"})]}):(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[10px] font-black bg-amber-50 text-amber-700 border border-amber-200",children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-500 animate-pulse"}),(0,t.jsx)("span",{children:"รอการตรวจสอบ"})]})}),(0,t.jsx)("td",{className:"py-3.5 px-4 text-center",children:"pending"===e.status?(0,t.jsxs)("div",{className:"flex items-center justify-center space-x-1.5",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>{tL(e),t_(""),tP(`TXN-${Date.now()}`),tD("โอนเงินสำเร็จเรียบร้อย")},className:"px-3 py-1.5 bg-emerald-600 hover:bg-emerald-700 text-white text-[11px] font-bold rounded-xl transition-all shadow-xs cursor-pointer border-none flex items-center gap-1",children:[(0,t.jsx)(w.Check,{className:"w-3.5 h-3.5"}),(0,t.jsx)("span",{children:"อนุมัติ & แนบสลิป"})]}),(0,t.jsx)("button",{type:"button",onClick:()=>{tF(e),tB("")},className:"px-2.5 py-1.5 bg-red-50 hover:bg-red-100 text-red-700 text-[11px] font-bold rounded-xl transition-colors cursor-pointer border border-red-200",children:"ปฏิเสธ"})]}):"approved"===e.status&&e.slipUrl?(0,t.jsxs)("button",{type:"button",onClick:()=>tJ(e.slipUrl||null),className:"inline-flex items-center gap-1 px-3 py-1.5 bg-emerald-50 hover:bg-emerald-100 text-emerald-700 text-[11px] font-bold rounded-xl border border-emerald-200 cursor-pointer transition-colors",children:[(0,t.jsx)(_.FileText,{className:"w-3.5 h-3.5"}),(0,t.jsx)("span",{children:"ดูสลิปโอนเงิน"})]}):(0,t.jsx)("span",{className:"text-gray-400 text-xs",children:"-"})})]},e.id)):(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:7,className:"py-12 text-center text-gray-400 bg-gray-50/40 rounded-b-xl",children:(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center space-y-1.5",children:[(0,t.jsx)("span",{className:"text-2xl",children:"🏦"}),(0,t.jsx)("span",{className:"font-bold text-gray-700 text-xs",children:"ยังไม่มีคำขอถอนเงินในระบบ"}),(0,t.jsx)("span",{className:"text-[11px] text-gray-400",children:"เมื่อร้านค้าส่งคำขอถอนเงินเข้ามา รายการจะแสดงที่นี่เพื่อให้แอดมินอนุมัติ"})]})})})})]})})]})]}),tC&&(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-xs font-prompt animate-in fade-in duration-200",children:(0,t.jsxs)("div",{className:"bg-white rounded-3xl border border-gray-150 shadow-2xl max-w-lg w-full overflow-hidden flex flex-col max-h-[92vh]",children:[(0,t.jsxs)("div",{className:"px-6 py-4.5 border-b border-gray-150 flex items-center justify-between bg-white sticky top-0 z-10",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2.5",children:[(0,t.jsx)("div",{className:"w-8 h-8 rounded-xl bg-emerald-50 text-emerald-700 flex items-center justify-center",children:(0,t.jsx)(w.Check,{className:"w-4 h-4"})}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("h3",{className:"font-extrabold text-base text-gray-900",children:["อนุมัติและบันทึกการโอนเงิน (#",tC.id,")"]}),(0,t.jsx)("p",{className:"text-[10px] text-gray-400 font-semibold leading-none mt-0.5",children:"แนบรูปภาพสลิปหลักฐานการโอนเงินเพื่อส่งมอบให้ร้านค้า"})]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>tL(null),className:"p-1.5 text-gray-400 hover:text-gray-700 rounded-xl transition-colors border-none bg-transparent cursor-pointer",children:(0,t.jsx)(k.X,{className:"w-4 h-4"})})]}),(0,t.jsxs)("form",{onSubmit:e=>{if(e.preventDefault(),tC){if(!t$)return void tU("กรุณาแนบรูปภาพสลิปหลักฐานการโอนเงิน","error");M.default.approvePayout(tC.id,t$,tI.trim()||`TXN-${Date.now()}`,tO.trim()||"โอนเงินสำเร็จเรียบร้อย"),tR(),tL(null),t_(""),tP(""),tD(""),tU(`อนุมัติและบันทึกการโอนเงิน #${tC.id} เรียบร้อยแล้ว`,"success")}},className:"p-6 overflow-y-auto space-y-4 text-left",children:[(0,t.jsxs)("div",{className:"bg-emerald-50/70 border border-emerald-200 rounded-2xl p-4 space-y-2 text-xs text-gray-700",children:[(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsx)("span",{className:"text-gray-500",children:"ร้านค้าผู้ขอถอน:"}),(0,t.jsxs)("strong",{className:"text-gray-900",children:[tC.merchantName," (",tC.merchantEmail,")"]})]}),(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsx)("span",{className:"text-gray-500",children:"ธนาคารปลายทาง:"}),(0,t.jsx)("strong",{className:"text-gray-900",children:tC.bankAccount.bankName})]}),(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsx)("span",{className:"text-gray-500",children:"เลขที่บัญชี:"}),(0,t.jsx)("strong",{className:"text-gray-900 font-mono",children:tC.bankAccount.accountNumber})]}),(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsx)("span",{className:"text-gray-500",children:"ชื่อบัญชี:"}),(0,t.jsx)("strong",{className:"text-gray-900",children:tC.bankAccount.accountName})]}),(0,t.jsxs)("div",{className:"flex justify-between items-center border-t border-emerald-200 pt-2 text-sm",children:[(0,t.jsx)("span",{className:"font-bold text-gray-700",children:"ยอดเงินที่ต้องโอน:"}),(0,t.jsxs)("strong",{className:"text-emerald-700 font-black text-base",children:["฿",tC.amount.toLocaleString()]})]})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("label",{className:"text-xs font-bold text-gray-700 block",children:["แนบรูปภาพสลิปหลักฐานการโอนเงิน ",(0,t.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,t.jsx)("div",{className:"border-2 border-dashed border-gray-300 hover:border-emerald-500 rounded-2xl p-4 text-center transition-all bg-gray-50/50 relative",children:t$?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("img",{src:t$,alt:"Slip Preview",className:"max-h-48 mx-auto rounded-xl object-contain border border-gray-200 shadow-xs"}),(0,t.jsx)("button",{type:"button",onClick:()=>t_(""),className:"text-xs font-bold text-red-600 hover:underline cursor-pointer border-none bg-transparent",children:"ลบและเลือกรูปใหม่"})]}):(0,t.jsxs)("div",{className:"space-y-1.5 py-3",children:[(0,t.jsx)(I.Upload,{className:"w-8 h-8 text-gray-400 mx-auto"}),(0,t.jsx)("span",{className:"text-xs font-bold text-gray-700 block",children:"คลิกเพื่ออัปโหลดรูปภาพสลิปโอนเงิน"}),(0,t.jsx)("span",{className:"text-[10px] text-gray-400 block",children:"รองรับไฟล์ JPG, PNG หรือภาพหน้าจอ"}),(0,t.jsx)("input",{type:"file",accept:"image/*",onChange:tq,className:"absolute inset-0 opacity-0 cursor-pointer w-full h-full"})]})})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("label",{className:"text-xs font-bold text-gray-700 block",children:"เลขอ้างอิงธุรกรรมธนาคาร (Transaction Ref)"}),(0,t.jsx)("input",{type:"text",value:tI,onChange:e=>tP(e.target.value),placeholder:"เช่น TXN-12345678",className:"w-full px-3.5 py-2 bg-white border border-gray-300 rounded-xl text-xs font-mono font-bold text-gray-900 focus:outline-none focus:border-emerald-600"})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("label",{className:"text-xs font-bold text-gray-700 block",children:"บันทึกข้อความถึงร้านค้า (Note)"}),(0,t.jsx)("input",{type:"text",value:tO,onChange:e=>tD(e.target.value),placeholder:"เช่น โอนเงินเข้าบัญชีกสิกรไทยเรียบร้อยแล้ว",className:"w-full px-3.5 py-2 bg-white border border-gray-300 rounded-xl text-xs font-medium text-gray-900 focus:outline-none focus:border-emerald-600"})]}),(0,t.jsxs)("div",{className:"pt-3 border-t border-gray-150 flex items-center justify-end space-x-3",children:[(0,t.jsx)("button",{type:"button",onClick:()=>tL(null),className:"px-5 py-2.5 rounded-xl border border-gray-250 text-xs font-bold text-gray-600 hover:bg-gray-50 transition-colors cursor-pointer bg-white",children:"ยกเลิก"}),(0,t.jsxs)("button",{type:"submit",disabled:!t$,className:"px-6 py-2.5 rounded-xl bg-emerald-600 hover:bg-emerald-700 disabled:opacity-50 text-white text-xs font-bold transition-all shadow-sm active:scale-98 cursor-pointer border-none flex items-center space-x-2",children:[(0,t.jsx)(w.Check,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:"ยืนยันอนุมัติการจ่ายเงิน"})]})]})]})]})}),tE&&(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-xs font-prompt animate-in fade-in duration-200",children:(0,t.jsxs)("div",{className:"bg-white rounded-3xl border border-gray-150 shadow-2xl max-w-md w-full overflow-hidden flex flex-col",children:[(0,t.jsxs)("div",{className:"px-6 py-4.5 border-b border-gray-150 flex items-center justify-between bg-white",children:[(0,t.jsxs)("div",{className:"flex items-center space-x-2.5",children:[(0,t.jsx)("div",{className:"w-8 h-8 rounded-xl bg-red-50 text-red-700 flex items-center justify-center",children:(0,t.jsx)(k.X,{className:"w-4 h-4"})}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("h3",{className:"font-extrabold text-base text-gray-900",children:["ปฏิเสธคำขอถอนเงิน (#",tE.id,")"]}),(0,t.jsx)("p",{className:"text-[10px] text-gray-400 font-semibold leading-none mt-0.5",children:"ระบุเหตุผลเพื่อแจ้งเตือนไปยังผู้ขาย"})]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>tF(null),className:"p-1.5 text-gray-400 hover:text-gray-700 rounded-xl transition-colors border-none bg-transparent cursor-pointer",children:(0,t.jsx)(k.X,{className:"w-4 h-4"})})]}),(0,t.jsxs)("form",{onSubmit:e=>{if(e.preventDefault(),tE){if(!tT.trim())return void tU("กรุณาระบุเหตุผลที่ปฏิเสธคำขอ","error");M.default.rejectPayout(tE.id,tT.trim()),tR(),tF(null),tB(""),tU(`ปฏิเสธคำขอถอนเงิน #${tE.id} เรียบร้อยแล้ว`,"info")}},className:"p-6 space-y-4 text-left",children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("label",{className:"text-xs font-bold text-gray-700 block",children:["เหตุผลที่ปฏิเสธ ",(0,t.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,t.jsx)("textarea",{required:!0,rows:3,value:tT,onChange:e=>tB(e.target.value),placeholder:"เช่น ข้อมูลเลขที่บัญชีธนาคารไม่ถูกต้อง หรือชื่อบัญชีไม่ตรงกับชื่อผู้ลงทะเบียน",className:"w-full p-3 bg-white border border-gray-300 rounded-xl text-xs font-medium text-gray-900 focus:outline-none focus:border-red-600 resize-none"})]}),(0,t.jsxs)("div",{className:"pt-3 border-t border-gray-150 flex items-center justify-end space-x-3",children:[(0,t.jsx)("button",{type:"button",onClick:()=>tF(null),className:"px-5 py-2.5 rounded-xl border border-gray-250 text-xs font-bold text-gray-600 hover:bg-gray-50 transition-colors cursor-pointer bg-white",children:"ยกเลิก"}),(0,t.jsx)("button",{type:"submit",className:"px-6 py-2.5 rounded-xl bg-red-600 hover:bg-red-700 text-white text-xs font-bold transition-all shadow-sm active:scale-98 cursor-pointer border-none",children:"ยืนยันปฏิเสธคำขอ"})]})]})]})}),tM&&(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/70 backdrop-blur-xs font-prompt animate-in fade-in duration-200",children:(0,t.jsxs)("div",{className:"bg-white rounded-3xl border border-gray-150 shadow-2xl max-w-md w-full overflow-hidden flex flex-col",children:[(0,t.jsxs)("div",{className:"px-6 py-4 border-b border-gray-150 flex items-center justify-between bg-white",children:[(0,t.jsxs)("h3",{className:"font-extrabold text-base text-gray-900 flex items-center gap-2",children:[(0,t.jsx)(_.FileText,{className:"w-4 h-4 text-emerald-600"}),(0,t.jsx)("span",{children:"หลักฐานการโอนเงิน (Transfer Slip)"})]}),(0,t.jsx)("button",{type:"button",onClick:()=>tJ(null),className:"p-1.5 text-gray-400 hover:text-gray-700 rounded-xl border-none bg-transparent cursor-pointer",children:(0,t.jsx)(k.X,{className:"w-4 h-4"})})]}),(0,t.jsxs)("div",{className:"p-6 flex flex-col items-center justify-center bg-gray-50/50 space-y-3",children:[(0,t.jsx)("div",{className:"max-h-[60vh] overflow-auto rounded-2xl border border-gray-200 bg-white p-2 shadow-xs",children:(0,t.jsx)("img",{src:tM,alt:"Transfer Slip",className:"w-full h-auto object-contain rounded-xl"})}),(0,t.jsx)("button",{type:"button",onClick:()=>tJ(null),className:"w-full py-2.5 bg-gray-900 text-white font-bold text-xs rounded-xl border-none cursor-pointer hover:bg-black transition-colors",children:"ปิดหน้าต่าง"})]})]})}),"dashboard"!==ea&&"users"!==ea&&"categories"!==ea&&"orders"!==ea&&"shipping"!==ea&&"finance"!==ea&&"payouts"!==ea&&(0,t.jsxs)("div",{className:"bg-white border border-[#F3F1ED] p-16 rounded-2xl text-center shadow-sm max-w-xl mx-auto flex flex-col items-center justify-center min-h-[400px]",children:[(0,t.jsx)("div",{className:"w-16 h-16 rounded-full bg-red-50 flex items-center justify-center text-[#800A0A] mb-6 border border-red-100",children:(0,t.jsx)(y.Wrench,{className:"w-8 h-8"})}),(0,t.jsx)("h2",{className:"text-lg font-black text-gray-800 mb-1",children:"เมนูระบบจำลองการทำงาน"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 font-light max-w-xs mb-8",children:"ขณะนี้คุณเลือกหัวข้อแผงการจัดการแบบจำลอง ข้อมูลจริงจะถูกเชื่อมต่อผ่าน API ของเซิร์ฟเวอร์ในการจัดจำหน่ายจริง"}),(0,t.jsx)(D.default,{variant:"primary",onClick:()=>ek("dashboard"),className:"px-6 py-2.5",children:"กลับสู่หน้าหลักแดชบอร์ด"})]})]})]})]}):(0,t.jsx)("div",{className:"min-h-screen bg-[#FAF8F5] flex items-center justify-center",children:(0,t.jsxs)("div",{className:"flex flex-col items-center space-y-4",children:[(0,t.jsx)("div",{className:"w-12 h-12 rounded-full border-4 border-[#800A0A] border-t-transparent animate-spin"}),(0,t.jsx)("span",{className:"text-sm text-gray-500 font-medium",children:"กำลังตรวจสอบสิทธิ์ผู้ดูแลระบบ..."})]})})}],72906)}]);
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.27 |
proxy
|
phpinfo
|
Settings