(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[786],{12240:function(e,r,t){Promise.resolve().then(t.bind(t,40496))},40496:function(e,r,t){"use strict";t.r(r),t.d(r,{default:function(){return i}});var n=t(57437),a=t(2265),s=t(94508);function i(){let[e,r]=(0,a.useState)([]),[t,i]=(0,a.useState)(!0),[l,o]=(0,a.useState)(1),[c,d]=(0,a.useState)(1),[u,b]=(0,a.useState)(""),[g,p]=(0,a.useState)(!1),[h,m]=(0,a.useState)(null),x=()=>{i(!0),fetch("/api/admin/products/vip?page=".concat(l,"&limit=20&search=").concat(u)).then(e=>e.json()).then(e=>{r(e.products||[]),d(e.pages||1),i(!1)})};(0,a.useEffect)(()=>{let e=setTimeout(x,300);return()=>clearTimeout(e)},[l,u]);let f=async()=>{if(confirm("Proses ini akan memakan waktu. Lanjutkan?")){p(!0),m(null);try{let e=await fetch("/api/admin/products/vip",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultMargin:15})}),r=await e.json();if(!e.ok)throw Error(r.error||"Gagal sinkronisasi");m(r),x()}catch(e){m({error:!0,message:e.message})}p(!1)}};return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-end",marginBottom:"24px",flexWrap:"wrap",gap:16},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"font-game",style:{fontSize:"28px",fontWeight:700,color:"#f1f5f9",marginBottom:"8px"},children:"Game VIP Products"}),(0,n.jsx)("p",{style:{color:"#64748b"},children:"Sinkronisasi dan margin produk dari VIP Reseller"})]}),(0,n.jsxs)("div",{style:{display:"flex",gap:"12px"},children:[(0,n.jsx)("input",{className:"input",placeholder:"Cari game/produk...",value:u,onChange:e=>{b(e.target.value),o(1)},style:{width:250}}),(0,n.jsx)("button",{className:"btn btn-primary",onClick:f,disabled:g,children:g?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"spinner"})," Syncing..."]}):"\uD83D\uDD04 Sync VIP Reseller"})]})]}),h&&(0,n.jsxs)("div",{style:{padding:"16px",background:h.error?"rgba(239,68,68,0.1)":"rgba(16,185,129,0.1)",border:"1px solid ".concat(h.error?"rgba(239,68,68,0.2)":"rgba(16,185,129,0.2)"),borderRadius:"12px",marginBottom:"24px",color:h.error?"#ef4444":"#10b981"},children:[h.error?"❌ ":"✅ "," ",h.message]}),(0,n.jsx)("div",{className:"card table-container",children:t?(0,n.jsx)("div",{className:"spinner",style:{margin:"40px auto",display:"block"}}):(0,n.jsxs)("table",{children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:"Kode"}),(0,n.jsx)("th",{children:"Game / Kategori"}),(0,n.jsx)("th",{children:"Nama Produk"}),(0,n.jsx)("th",{children:"Harga Asli"}),(0,n.jsx)("th",{children:"Harga Jual (Margin)"}),(0,n.jsx)("th",{children:"Status"})]})}),(0,n.jsx)("tbody",{children:e.map(e=>(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{style:{fontFamily:"monospace",color:"#94a3b8"},children:e.providerCode}),(0,n.jsx)("td",{style:{fontWeight:600},children:e.gameName}),(0,n.jsx)("td",{children:e.productName}),(0,n.jsx)("td",{style:{color:"#ef4444"},children:(0,s.b7)(e.price)}),(0,n.jsxs)("td",{style:{color:"#10b981",fontWeight:600},children:[(0,s.b7)(e.sellPrice)," ",(0,n.jsxs)("span",{style:{fontSize:10,color:"#64748b",fontWeight:400},children:["(",e.margin,"%)"]})]}),(0,n.jsx)("td",{children:(0,n.jsx)("span",{className:"badge",style:{background:e.status?"rgba(16,185,129,0.1)":"rgba(239,68,68,0.1)",color:e.status?"#10b981":"#ef4444"},children:e.status?"Tersedia":"Gangguan"})})]},e.id))})]})}),c>1&&(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"center",gap:"8px",marginTop:"24px"},children:[(0,n.jsx)("button",{className:"btn btn-secondary",disabled:1===l,onClick:()=>o(e=>e-1),children:"Prev"}),(0,n.jsxs)("span",{style:{padding:"8px 16px",color:"#94a3b8"},children:[l," / ",c]}),(0,n.jsx)("button",{className:"btn btn-secondary",disabled:l===c,onClick:()=>o(e=>e+1),children:"Next"})]})]})}},94508:function(e,r,t){"use strict";function n(e){if(!e)return"Rp 0";let r="string"==typeof e?parseFloat(e):e;return new Intl.NumberFormat("id-ID",{style:"currency",currency:"IDR",minimumFractionDigits:0,maximumFractionDigits:0}).format(r)}function a(e){return new Date(e).toLocaleDateString("id-ID",{day:"numeric",month:"long",year:"numeric",hour:"2-digit",minute:"2-digit"})}function s(e){return({PENDING:{label:"Menunggu",color:"#f59e0b",bg:"rgba(245,158,11,0.15)"},PAID:{label:"Dibayar",color:"#3b82f6",bg:"rgba(59,130,246,0.15)"},PROCESSING:{label:"Diproses",color:"#8b5cf6",bg:"rgba(139,92,246,0.15)"},SUCCESS:{label:"Sukses",color:"#10b981",bg:"rgba(16,185,129,0.15)"},FAILED:{label:"Gagal",color:"#ef4444",bg:"rgba(239,68,68,0.15)"},REFUNDED:{label:"Refund",color:"#06b6d4",bg:"rgba(6,182,212,0.15)"},CANCELLED:{label:"Dibatalkan",color:"#6b7280",bg:"rgba(107,114,128,0.15)"}})[e]||{label:e,color:"#6b7280",bg:"rgba(107,114,128,0.15)"}}t.d(r,{b7:function(){return n},p6:function(){return a},yr:function(){return s}})}},function(e){e.O(0,[971,117,744],function(){return e(e.s=12240)}),_N_E=e.O()}]);