%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home2/rezakur1/ai.rezakurnia.com/assets/
Upload File :
Create Path :
Current File : /home2/rezakur1/ai.rezakurnia.com/assets/BillingPage-BM1pwYJn.js

import{r as x,c as B,j as e}from"./index-BWQ2K1sp.js";import{i as k,b as _,C as f,e as T,d as S}from"./format-D-I1HO4E.js";import{B as g}from"./Badge-B6wRuamo.js";const q=3e4;function C(){const[t,n]=x.useState(null),[c,u]=x.useState(!0),[m,b]=x.useState(null),o=x.useCallback(async()=>{try{const i=await B("/me/billing");n(i),b(null)}catch(i){b(i instanceof Error?i.message:"Gagal memuat billing")}finally{u(!1)}},[]);return x.useEffect(()=>{o();const i=setInterval(o,q);return()=>clearInterval(i)},[o]),{data:t,loading:c,error:m,refresh:o}}const L=[{id:"all",label:"Semua"},{id:"topup",label:"Top Up"},{id:"usage",label:"Pemakaian"},{id:"adjustment",label:"Paket"}];function l(t){const n=Number(t);return Number.isFinite(n)?n.toLocaleString("id-ID",{style:"currency",currency:"IDR",maximumFractionDigits:2}):"Rp 0"}function M(t){switch(t.type){case"topup":return t.description||"Top up saldo";case"usage":return t.description||"Pemakaian model";case"adjustment":return t.description||"Pembelian paket";default:return t.description||"Transaksi"}}function F({type:t}){return t==="topup"?e.jsx(g,{tone:"success",children:"Top Up"}):t==="usage"?e.jsx(g,{tone:"danger",children:"Pemakaian"}):t==="adjustment"?e.jsx(g,{tone:"warning",children:"Paket"}):e.jsx(g,{tone:"default",children:t})}function p({label:t,value:n,hint:c,accent:u}){return e.jsxs(f,{className:"p-5",children:[e.jsx("p",{className:"text-xs font-medium text-slate-400",children:t}),e.jsx("p",{className:`mt-2 text-xl font-bold tracking-tight tabular-nums sm:text-2xl ${u}`,children:n}),c&&e.jsx("div",{className:"mt-1 text-[11px] text-slate-500",children:c})]})}function E(){const{data:t,loading:n,error:c,refresh:u}=C(),[m,b]=x.useState("all"),[o,i]=x.useState(!1),s=t==null?void 0:t.summary,d=t==null?void 0:t.active_package,j=t==null?void 0:t.breakdown,N=((t==null?void 0:t.transactions)??[]).filter(a=>m==="all"||a.type===m),v=Number((s==null?void 0:s.covered_by_package)??0),h=Number((s==null?void 0:s.total_usage_gross)??0),P=[{key:"billed_wallet",label:"Dipotong dari wallet",hint:"Request yang langsung mengurangi saldo",tone:"text-red-300",bar:"bg-red-400"},{key:"covered_package",label:"Ditanggung paket aktif",hint:"Request saat paket aktif (kuota paket)",tone:"text-brand-300",bar:"bg-brand-400"},{key:"untracked",label:"Tidak tertagih",hint:"Harga 0 / sebelum harga diset / model kosong",tone:"text-slate-400",bar:"bg-slate-500"}];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6 flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight text-white",children:"Billing"}),e.jsx("p",{className:"mt-0.5 text-sm text-slate-400",children:"Saldo wallet, ringkasan, dan log transaksi finansial Anda."})]}),e.jsx("button",{onClick:u,disabled:n,className:"rounded-xl border border-white/[0.08] bg-white/[0.03] px-3.5 py-2 text-xs font-medium text-slate-300 transition-colors hover:bg-white/[0.06] disabled:opacity-50",children:n?"Memuat…":"Muat Ulang"})]}),d&&e.jsxs("div",{className:"mb-6 flex flex-wrap items-center gap-3 rounded-2xl border border-brand-400/20 bg-brand-500/[0.07] px-5 py-4",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl border border-brand-400/25 bg-brand-500/10 text-brand-300",children:e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.7,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M20.25 7.5l-.625 10.632a2.25 2.25 0 01-2.247 2.118H6.622a2.25 2.25 0 01-2.247-2.118L3.75 7.5M10 11.25h4M3.375 7.5h17.25c.621 0 1.125-.504 1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125z"})})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-white",children:["Paket aktif: ",d.package_name]}),e.jsxs("p",{className:"mt-0.5 text-xs text-slate-400",children:["Pemakaian model selama paket aktif ditanggung paket (tidak memotong wallet)."," ",d.request_remaining!==null&&e.jsxs(e.Fragment,{children:["Sisa kuota:"," ",e.jsxs("span",{className:"font-medium text-slate-200",children:[k(d.request_remaining)," request"]}),d.token_remaining!==null&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"font-medium text-slate-200",children:[k(d.token_remaining)," token"]})]})]})," · ","Berlaku s.d."," ",e.jsx("span",{className:"font-medium text-slate-200",children:_(d.expires_at)})]})]}),e.jsx(g,{tone:"success",children:"Aktif"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-5",children:[e.jsx(p,{label:"Saldo Wallet",value:l((s==null?void 0:s.balance)??0),accent:"text-white",hint:"Saldo tersedia saat ini"}),e.jsx(p,{label:"Total Top Up",value:l((s==null?void 0:s.total_topup)??0),accent:"text-emerald-300",hint:"Akumulasi pengisian saldo"}),e.jsx(p,{label:"Total Pemakaian",value:l((s==null?void 0:s.total_usage)??0),accent:"text-red-300",hint:v>0?e.jsxs(e.Fragment,{children:[l(v)," ditanggung paket aktif",h>0&&e.jsxs(e.Fragment,{children:[" · nilai semua request ",e.jsx("span",{className:"text-slate-400",children:l(h)})]})]}):"Biaya pemakaian yang dipotong dari wallet"}),e.jsx(p,{label:"Total Beli Paket",value:l((s==null?void 0:s.total_package_orders)??0),accent:"text-amber-300",hint:"Pembelian paket kuota"}),e.jsx(p,{label:"Jumlah Request",value:k((s==null?void 0:s.requests)??0),accent:"text-sky-300",hint:"Total permintaan API (auto-refresh)"})]}),e.jsx(f,{className:"mt-6",children:e.jsxs(T,{className:"p-5",children:[e.jsxs("button",{type:"button",onClick:()=>i(a=>!a),className:"flex w-full items-center justify-between text-left",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-white",children:"Darimana angka pemakaian?"}),e.jsx("p",{className:"mt-0.5 text-xs text-slate-400",children:"Penjelasan mengapa Total Pemakaian (wallet) bisa jauh lebih kecil dari nilai semua request."})]}),e.jsx("svg",{className:`h-4 w-4 shrink-0 text-slate-500 transition-transform ${o?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"})})]}),o&&e.jsxs("div",{className:"mt-5 space-y-4",children:[e.jsx("div",{className:"flex items-end gap-1 rounded-xl border border-white/[0.06] bg-white/[0.02] px-3 pt-3",children:P.map(a=>{const r=j==null?void 0:j[a.key],R=r&&typeof r=="object"?r.requests:0,w=r&&typeof r=="object"?r.nominal_cost:0,y=h>0?Math.round(w/h*100):0;return e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:`h-2.5 rounded-t-md ${a.bar}`,style:{opacity:y>0?.9:.25}}),e.jsx("p",{className:`mt-2 text-[11px] font-medium ${a.tone}`,children:a.label}),e.jsx("p",{className:"text-sm font-semibold tabular-nums text-white",children:l(w)}),e.jsxs("p",{className:"text-[11px] text-slate-500",children:[R," request · ",y,"%"]}),e.jsx("p",{className:"mb-3 mt-0.5 text-[10px] text-slate-600",children:a.hint})]},a.key)})}),e.jsxs("p",{className:"text-xs leading-relaxed text-slate-400",children:["Total Pemakaian (Rp"," ",l((s==null?void 0:s.total_usage)??0).replace("Rp ",""),") hanya menghitung request yang benar-benar memotong wallet. Nilai semua request (Rp ",l(h).replace("Rp ",""),") sebagian ditanggung paket aktif, sebagian terjadi sebelum harga model diset (biaya 0), sehingga tidak tercatat sebagai potongan."]})]})]})}),e.jsxs(f,{className:"mt-6",children:[e.jsx(S,{title:"Log Transaksi",subtitle:"Riwayat finansial: top-up, pemakaian model, dan pembelian paket",action:e.jsx("div",{className:"flex flex-wrap gap-1.5",children:L.map(a=>e.jsx("button",{onClick:()=>b(a.id),className:`rounded-full px-3 py-1.5 text-xs font-medium transition-colors ${m===a.id?"bg-brand-500/20 text-brand-200 ring-1 ring-brand-400/30":"text-slate-400 hover:bg-white/[0.04] hover:text-slate-200"}`,children:a.label},a.id))})}),e.jsxs(T,{className:"p-0",children:[c&&e.jsxs("div",{className:"p-5 text-sm text-red-300",children:["Gagal memuat: ",c]}),n?e.jsx("div",{className:"space-y-3 p-5",children:[...Array(6)].map((a,r)=>e.jsx("div",{className:"h-12 animate-pulse rounded-xl bg-white/[0.02]"},r))}):N.length===0?e.jsxs("div",{className:"px-5 py-12 text-center",children:[e.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-2xl border border-white/[0.06] bg-white/[0.03] text-slate-500",children:e.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.7,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 18.75a60.07 60.07 0 0115.797 2.101c.727.198 1.453-.342 1.453-1.096V18.75M3.75 4.5v.75A.75.75 0 013 6h-.75m0 0v-.375c0-.621.504-1.125 1.125-1.125H20.25M2.25 6v9m18-10.5v.75c0 .414.336.75.75.75h.75m-1.5-1.5h.375c.621 0 1.125.504 1.125 1.125v9.75c0 .621-.504 1.125-1.125 1.125h-.375m1.5-1.5H21a.75.75 0 00-.75.75v.75m0 0H3.75m0 0h-.375a1.125 1.125 0 01-1.125-1.125V15m1.5 1.5v-.75A.75.75 0 003 15h-.75M15 10.5a3 3 0 11-6 0 3 3 0 016 0zm3 0h.008v.008H18V10.5zm-12 0h.008v.008H6V10.5z"})})}),e.jsx("p",{className:"mt-4 text-sm font-medium text-slate-200",children:"Belum ada transaksi"}),e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:m==="all"?"Transaksi finansial Anda akan muncul di sini.":"Tidak ada transaksi untuk kategori ini."})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[640px] text-left text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/[0.06] bg-white/[0.02] text-[11px] uppercase tracking-wider text-slate-500",children:[e.jsx("th",{className:"px-5 py-3 font-semibold",children:"Jenis"}),e.jsx("th",{className:"px-4 py-3 font-semibold",children:"Detail"}),e.jsx("th",{className:"px-4 py-3 text-right font-semibold",children:"Nominal"}),e.jsx("th",{className:"px-5 py-3 text-right font-semibold",children:"Tanggal"})]})}),e.jsx("tbody",{children:N.map(a=>e.jsxs("tr",{className:"border-b border-white/[0.04] transition-colors last:border-0 hover:bg-white/[0.02]",children:[e.jsx("td",{className:"px-5 py-3.5",children:e.jsx(F,{type:a.type})}),e.jsxs("td",{className:"max-w-[260px] truncate px-4 py-3.5 text-slate-300",children:[M(a),a.reference&&e.jsxs("span",{className:"ml-1.5 font-mono text-[11px] text-slate-500",children:["#",a.reference]})]}),e.jsxs("td",{className:`px-4 py-3.5 text-right font-medium tabular-nums ${a.type==="topup"?"text-emerald-300":"text-slate-200"}`,children:[a.type==="topup"?"+":"−",l(Math.abs(Number(a.amount)))]}),e.jsx("td",{className:"px-5 py-3.5 text-right text-slate-500",children:_(a.created_at)})]},a.id))})]})})]})]})]})}export{E as default};

Zerion Mini Shell 1.0