%PDF- %PDF-
| Direktori : /home2/rezakur1/ai.rezakurnia.com/assets/ |
| Current File : //home2/rezakur1/ai.rezakurnia.com/assets/AdminDashboardPage-BNycf78t.js |
import{r as x,c as T,j as e,L as z}from"./index-CnB9nKbp.js";import{C as c,h as b,c as C,a as f,e as M}from"./format-B8Won_Te.js";import{S as u}from"./StatCard-BEXjnbRZ.js";import{R as k,C as N,X as v,Y as g,T as y}from"./CartesianChart-Bfy5VUzG.js";import{B as w,a as p}from"./BarChart-DbJ8cTr_.js";import"./index-BjE9Ehy3.js";import"./with-selector-BcCXhWZD.js";function I(n=30){const[l,r]=x.useState(null),[m,o]=x.useState(!0),[t,i]=x.useState(null),[s,a]=x.useState(0),d=x.useCallback(()=>a(h=>h+1),[]);return x.useEffect(()=>{let h=!1;return o(!0),T(`/admin/dashboard?days=${n}`).then(j=>{h||(r(j),i(null))}).catch(j=>{h||i(j.message)}).finally(()=>{h||o(!1)}),()=>{h=!0}},[n,s]),{data:l,loading:m,error:t,refresh:d}}function L({active:n,payload:l}){if(!n||!(l!=null&&l.length))return null;const r=l[0].payload,m=new Date(`${r.date}T00:00:00`),o=Number.isNaN(m.getTime())?r.date:new Intl.DateTimeFormat("id-ID",{day:"2-digit",month:"short",year:"numeric"}).format(m);return e.jsxs("div",{className:"rounded-xl border border-white/[0.08] bg-ink-900 px-3.5 py-2.5 text-xs shadow-modal",children:[e.jsx("p",{className:"mb-1.5 font-semibold text-white",children:o}),e.jsx("div",{className:"space-y-1",children:l.map(t=>{const i=typeof t.value=="number"?t.value:Number(t.value);return e.jsxs("p",{className:"flex items-center justify-between gap-6 text-slate-400",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"h-2 w-2 rounded-full",style:{background:t.color||t.fill}}),t.name]}),e.jsx("span",{className:"font-semibold tabular-nums text-white",children:Number.isFinite(i)?i.toLocaleString("id-ID"):String(t.value)})]},t.dataKey)})})]})}const S=[{to:"/admin/users",label:"Pengguna",desc:"Daftar & kelola akun",icon:"M15 19.128a9.38 9.38 0 002.625.372 9.337 9.337 0 004.121-.952 4.125 4.125 0 00-7.533-2.493M15 19.128v-.003c0-1.113-.285-2.16-.786-3.07M15 19.128v.106A12.318 12.318 0 018.624 21c-2.331 0-4.512-.645-6.374-1.766l-.001-.109a6.375 6.375 0 0111.964-3.07M12 6.375a3.375 3.375 0 11-6.75 0 3.375 3.375 0 016.75 0zm8.25 2.25a2.625 2.625 0 11-5.25 0 2.625 2.625 0 015.25 0z"},{to:"/admin/usage",label:"Penggunaan",desc:"Pemakaian token per user",icon:"M3 13.125C3 12.504 3.504 12 4.125 12h2.25c.621 0 1.125.504 1.125 1.125v6.75C7.5 20.496 6.996 21 6.375 21h-2.25A1.125 1.125 0 013 19.875v-6.75zM9.75 9.75c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125v10.125c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 01-1.125-1.125V9.75zM16.5 6v0c0-.621.504-1.125 1.125-1.125h2.25C20.496 4.875 21 5.379 21 6v12.75c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 01-1.125-1.125V6z"},{to:"/admin/topup",label:"Verifikasi Top Up",desc:"Tandai pembayaran QRIS",icon:"M2.25 8.25h19.5m-16.5.75h12a2.25 2.25 0 012.25 2.25v3a2.25 2.25 0 01-2.25 2.25h-12A2.25 2.25 0 012.25 14.25v-3a2.25 2.25 0 012.25-2.25z"}];function R(){const[n,l]=x.useState(30),{data:r,loading:m,error:o}=I(n),t=(r==null?void 0:r.daily)??[],i={className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.7},s=r==null?void 0:r.summary;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold tracking-tight text-white sm:text-2xl",children:"Dashboard Admin"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Ringkasan platform: pengguna, penggunaan, dan pendapatan."})]}),e.jsx("div",{className:"flex items-center gap-1 rounded-xl border border-white/[0.06] bg-white/[0.03] p-1",children:[7,30,90].map(a=>e.jsxs("button",{onClick:()=>l(a),className:`rounded-lg px-3.5 py-1.5 text-xs font-medium transition-colors ${n===a?"bg-white/[0.08] text-white":"text-slate-500 hover:text-slate-300"}`,children:[a," hari"]},a))})]}),o&&e.jsx("div",{className:"rounded-xl border border-red-500/25 bg-red-500/10 px-4 py-3 text-sm text-red-300",children:o}),m&&!s&&e.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4",children:[...Array(8)].map((a,d)=>e.jsx("div",{className:"h-28 animate-pulse rounded-2xl border border-white/[0.04] bg-white/[0.02]"},d))}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-3",children:[e.jsx(u,{label:"Total Pengguna",value:Number(s.total_users),accent:"pink",hint:`${Number(s.active_users)} aktif`,icon:e.jsx("svg",{...i,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19.128a9.38 9.38 0 002.625.372 9.337 9.337 0 004.121-.952 4.125 4.125 0 00-7.533-2.493M15 19.128v-.003c0-1.113-.285-2.16-.786-3.07M15 19.128v.106A12.318 12.318 0 018.624 21c-2.331 0-4.512-.645-6.374-1.766l-.001-.109a6.375 6.375 0 0111.964-3.07M12 6.375a3.375 3.375 0 11-6.75 0 3.375 3.375 0 016.75 0zm8.25 2.25a2.625 2.625 0 11-5.25 0 2.625 2.625 0 015.25 0z"})})}),e.jsx(u,{label:"Requests",value:Number(s.requests),accent:"fuchsia",hint:`${n} hari terakhir`,icon:e.jsx("svg",{...i,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 6.75h12M8.25 12h12m-12 5.25h12M3.75 6.75h.007v.008H3.75V6.75zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zM3.75 12h.007v.008H3.75V12zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm-.375 5.25h.007v.008H3.75v-.008zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z"})})}),e.jsx(u,{label:"Input Tokens",value:Number(s.input_tokens),accent:"rose",icon:e.jsx("svg",{...i,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 00-2.456 2.456z"})})}),e.jsx(u,{label:"Cached Tokens",value:Number(s.cached_tokens),accent:"hot",icon:e.jsx("svg",{...i,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7l4.029-1.523a.75.75 0 01.93.539v.011a.75.75 0 01-.539.93l-4.029 1.523a8.25 8.25 0 01-13.803 3.7l-3.182-3.182v-.001z"})})}),e.jsx(u,{label:"Output Tokens",value:Number(s.output_tokens),accent:"pink",icon:e.jsx("svg",{...i,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 13.5l10.5-11.25L12 10.5h8.25L9.75 21.75 12 13.5H3.75z"})})}),e.jsx(u,{label:"Total Token",value:Number(s.input_tokens)+Number(s.cached_tokens)+Number(s.output_tokens),accent:"rose",icon:e.jsx("svg",{...i,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 00-2.456 2.456z"})})})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsxs(c,{className:"p-5",children:[e.jsx("p",{className:"text-xs font-medium text-slate-400",children:"Pendapatan Top Up"}),e.jsx("p",{className:"mt-2 text-2xl font-bold tracking-tight tabular-nums text-white sm:text-3xl",children:b(Number(s.revenue_topup))}),e.jsx("p",{className:"mt-1 text-[11px] text-slate-500",children:"Total order berstatus terbayar"})]}),e.jsxs(c,{className:"p-5",children:[e.jsx("p",{className:"text-xs font-medium text-slate-400",children:"Biaya Pemakaian Token"}),e.jsx("p",{className:"mt-2 text-2xl font-bold tracking-tight tabular-nums text-white sm:text-3xl",children:b(Number(s.cost_usage))}),e.jsxs("p",{className:"mt-1 text-[11px] text-slate-500",children:[n," hari terakhir (berdasarkan pricing)"]})]}),e.jsxs(c,{className:"p-5",children:[e.jsx("p",{className:"text-xs font-medium text-slate-400",children:"Order Menunggu"}),e.jsx("p",{className:"mt-2 text-2xl font-bold tracking-tight tabular-nums text-white sm:text-3xl",children:Number(s.pending_orders)}),e.jsx("p",{className:"mt-1 text-[11px] text-slate-500",children:"Perlu verifikasi admin"})]}),e.jsxs(c,{className:"p-5",children:[e.jsx("p",{className:"text-xs font-medium text-slate-400",children:"Total Saldo Wallet"}),e.jsx("p",{className:"mt-2 text-2xl font-bold tracking-tight tabular-nums text-white sm:text-3xl",children:C(s.wallet_balance)}),e.jsx("p",{className:"mt-1 text-[11px] text-slate-500",children:"Akumulasi saldo semua pengguna"})]})]}),e.jsxs(c,{children:[e.jsxs("div",{className:"border-b border-white/[0.06] px-5 py-4",children:[e.jsx("p",{className:"text-sm font-semibold text-white",children:"Tren Token Harian"}),e.jsxs("p",{className:"mt-0.5 text-xs text-slate-500",children:["Komposisi input, cached & output token per hari (",n," hari terakhir)"]})]}),e.jsx("div",{className:"p-5",children:t.length===0?e.jsx("div",{className:"flex h-64 items-center justify-center text-sm text-slate-500",children:"Belum ada data pada rentang ini."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4 flex items-center gap-5 text-xs text-slate-400",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-blue-500"}),"Input"]}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-sky-400"}),"Cached"]}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-blue-300"}),"Output"]})]}),e.jsx("div",{className:"h-64 w-full",children:e.jsx(k,{width:"100%",height:"100%",children:e.jsxs(w,{data:t,margin:{top:4,right:4,left:0,bottom:0},barCategoryGap:0,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"admTokIn",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#3b82f6"}),e.jsx("stop",{offset:"100%",stopColor:"#1d4ed8"})]}),e.jsxs("linearGradient",{id:"admTokCached",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#38bdf8"}),e.jsx("stop",{offset:"100%",stopColor:"#0284c7"})]}),e.jsxs("linearGradient",{id:"admTokOut",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#93c5fd"}),e.jsx("stop",{offset:"100%",stopColor:"#60a5fa"})]})]}),e.jsx(N,{strokeDasharray:"3 3",stroke:"rgba(255,255,255,0.05)",vertical:!1}),e.jsx(v,{dataKey:"date",tickFormatter:a=>{const d=new Date(`${a}T00:00:00`);return Number.isNaN(d.getTime())?a:new Intl.DateTimeFormat("id-ID",{day:"2-digit",month:"short"}).format(d)},tick:{fill:"#475569",fontSize:10},axisLine:!1,tickLine:!1,minTickGap:24}),e.jsx(g,{tick:{fill:"#475569",fontSize:11},tickFormatter:f,axisLine:!1,tickLine:!1}),e.jsx(y,{content:e.jsx(L,{}),cursor:{fill:"rgba(255,255,255,0.04)",radius:6}}),e.jsx(p,{dataKey:"input_tokens",name:"Input",stackId:"tok",fill:"url(#admTokIn)",radius:[0,0,0,0],maxBarSize:22}),e.jsx(p,{dataKey:"cached_tokens",name:"Cached",stackId:"tok",fill:"url(#admTokCached)",maxBarSize:22}),e.jsx(p,{dataKey:"output_tokens",name:"Output",stackId:"tok",fill:"url(#admTokOut)",radius:[5,5,0,0],maxBarSize:22})]})})})]})})]}),e.jsxs(c,{children:[e.jsxs("div",{className:"border-b border-white/[0.06] px-5 py-4",children:[e.jsx("p",{className:"text-sm font-semibold text-white",children:"Pendapatan & Permintaan"}),e.jsxs("p",{className:"mt-0.5 text-xs text-slate-500",children:["Pendapatan top-up vs biaya pemakaian & request per hari (",n," hari terakhir)"]})]}),e.jsx("div",{className:"p-5",children:t.length===0?e.jsx("div",{className:"flex h-64 items-center justify-center text-sm text-slate-500",children:"Belum ada data pada rentang ini."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4 flex items-center gap-5 text-xs text-slate-400",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-blue-500"}),"Requests"]}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-emerald-400"}),"Pendapatan top-up"]}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-amber-400"}),"Biaya pemakaian"]})]}),e.jsx("div",{className:"h-64 w-full",children:e.jsx(k,{width:"100%",height:"100%",children:e.jsxs(w,{data:t,margin:{top:4,right:4,left:0,bottom:0},barGap:2,barCategoryGap:0,children:[e.jsx(N,{strokeDasharray:"3 3",stroke:"rgba(255,255,255,0.05)",vertical:!1}),e.jsx(v,{dataKey:"date",tickFormatter:a=>{const d=new Date(`${a}T00:00:00`);return Number.isNaN(d.getTime())?a:new Intl.DateTimeFormat("id-ID",{day:"2-digit",month:"short"}).format(d)},tick:{fill:"#475569",fontSize:10},axisLine:!1,tickLine:!1,minTickGap:24}),e.jsx(g,{yAxisId:"req",tick:{fill:"#475569",fontSize:11},tickFormatter:f,axisLine:!1,tickLine:!1}),e.jsx(g,{yAxisId:"money",orientation:"right",tick:{fill:"#475569",fontSize:11},tickFormatter:a=>f(a),axisLine:!1,tickLine:!1}),e.jsx(y,{content:e.jsx(L,{}),cursor:{fill:"rgba(255,255,255,0.04)",radius:6}}),e.jsx(p,{yAxisId:"req",dataKey:"requests",name:"Requests",fill:"url(#admTokIn)",radius:[5,5,0,0],maxBarSize:18}),e.jsx(p,{yAxisId:"money",dataKey:"revenue_topup",name:"Pendapatan top-up",fill:"#34d399",radius:[5,5,0,0],maxBarSize:18}),e.jsx(p,{yAxisId:"money",dataKey:"cost_usage",name:"Biaya pemakaian",fill:"#fbbf24",radius:[5,5,0,0],maxBarSize:18})]})})})]})})]}),e.jsx(c,{children:e.jsxs(M,{children:[e.jsx("p",{className:"text-sm font-semibold text-white",children:"Navigasi cepat"}),e.jsx("div",{className:"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-3",children:S.map(a=>e.jsxs(z,{to:a.to,className:"group flex items-center gap-3 rounded-xl border border-white/[0.06] bg-white/[0.02] p-4 transition hover:bg-white/[0.04] hover:border-white/[0.12]",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg border border-white/[0.06] bg-white/[0.04] text-brand-300",children:e.jsx("svg",{...i,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:a.icon})})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-white group-hover:text-brand-200",children:a.label}),e.jsx("p",{className:"truncate text-xs text-slate-500",children:a.desc})]})]},a.to))})]})})]}),e.jsxs("div",{className:"panel px-5 py-4 text-xs text-slate-500",children:["💡 ",e.jsx("span",{className:"text-slate-400",children:"Catatan:"})," angka penggunaan mengikuti filter periode (",n," hari)."," ",e.jsx("span",{className:"text-slate-400",children:"Pendapatan"})," dan"," ",e.jsx("span",{className:"text-slate-400",children:"saldo wallet"})," adalah nilai akumulatif sepanjang waktu."]})]})}export{R as default};