%PDF- %PDF-
| Direktori : /home2/rezakur1/ai.rezakurnia.com/zh-router-frontend/dist/assets/ |
| Current File : //home2/rezakur1/ai.rezakurnia.com/zh-router-frontend/dist/assets/AdminDashboardPage-CmGD8fya.js |
import{r as m,a as T,j as e,L as z}from"./index-BDMoG-ch.js";import{C as x,b as C}from"./Card-DCk8Plvl.js";import{S as u}from"./StatCard-BcwaOH6_.js";import{g as b,d as M,c as g}from"./format-CjhWL3Ta.js";import{R as k,C as N,X as v,Y as f,T as y}from"./CartesianChart-XyIc3ea4.js";import{B as w,a as p}from"./BarChart-V-nITa4T.js";import"./index-CZPP6v8x.js";import"./with-selector-DRFco5vk.js";function I(l=30){const[d,o]=m.useState(null),[n,h]=m.useState(!0),[i,r]=m.useState(null),[c,s]=m.useState(0),a=m.useCallback(()=>s(t=>t+1),[]);return m.useEffect(()=>{let t=!1;return h(!0),T(`/admin/dashboard?days=${l}`).then(j=>{t||(o(j),r(null))}).catch(j=>{t||r(j.message)}).finally(()=>{t||h(!1)}),()=>{t=!0}},[l,c]),{data:d,loading:n,error:i,refresh:a}}function L({active:l,payload:d}){if(!l||!(d!=null&&d.length))return null;const o=d[0].payload,n=new Date(`${o.date}T00:00:00`),h=Number.isNaN(n.getTime())?o.date:new Intl.DateTimeFormat("id-ID",{day:"2-digit",month:"short",year:"numeric"}).format(n);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:h}),e.jsx("div",{className:"space-y-1",children:d.map(i=>{const r=typeof i.value=="number"?i.value:Number(i.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:i.color||i.fill}}),i.name]}),e.jsx("span",{className:"font-semibold tabular-nums text-white",children:Number.isFinite(r)?r.toLocaleString("id-ID"):String(i.value)})]},i.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 q(){const[l,d]=m.useState(30),o=l===1?"hari ini":`${l} hari`,{data:n,loading:h,error:i}=I(l),r=(n==null?void 0:n.daily)??[],c={className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.7},s=n==null?void 0:n.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:[{v:1,label:"Hari ini"},{v:7,label:"7 hari"},{v:30,label:"30 hari"},{v:90,label:"90 hari"}].map(a=>e.jsx("button",{onClick:()=>d(a.v),className:`rounded-lg px-3.5 py-1.5 text-xs font-medium transition-colors ${l===a.v?"bg-white/[0.08] text-white":"text-slate-500 hover:text-slate-300"}`,children:a.label},a.v))})]}),i&&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:i}),h&&!s&&e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:gap-4 sm:grid-cols-2 xl:grid-cols-4",children:[...Array(8)].map((a,t)=>e.jsx("div",{className:"h-24 animate-pulse rounded-2xl border border-white/[0.04] bg-white/[0.02] sm:h-28"},t))}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3 sm: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",{...c,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:o,icon:e.jsx("svg",{...c,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",{...c,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",{...c,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",{...c,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",{...c,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-2 gap-3 sm:gap-4 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsxs(x,{className:"p-4 sm: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-lg font-bold tracking-tight tabular-nums text-white sm:text-2xl lg: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(x,{className:"p-4 sm: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-lg font-bold tracking-tight tabular-nums text-white sm:text-2xl lg:text-3xl",children:b(Number(s.cost_usage))}),e.jsxs("p",{className:"mt-1 text-[11px] text-slate-500",children:[o," (berdasarkan pricing)"]})]}),e.jsxs(x,{className:"p-4 sm:p-5",children:[e.jsx("p",{className:"text-xs font-medium text-slate-400",children:"Order Menunggu"}),e.jsx("p",{className:"mt-2 text-lg font-bold tracking-tight tabular-nums text-white sm:text-2xl lg:text-3xl",children:Number(s.pending_orders)}),e.jsx("p",{className:"mt-1 text-[11px] text-slate-500",children:"Perlu verifikasi admin"})]}),e.jsxs(x,{className:"p-4 sm: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-lg font-bold tracking-tight tabular-nums text-white sm:text-2xl lg:text-3xl",children:M(s.wallet_balance)}),e.jsx("p",{className:"mt-1 text-[11px] text-slate-500",children:"Akumulasi saldo semua pengguna"})]})]}),e.jsxs(x,{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 (",o,")"]})]}),e.jsx("div",{className:"p-5",children:r.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:r,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 t=new Date(`${a}T00:00:00`);return Number.isNaN(t.getTime())?a:new Intl.DateTimeFormat("id-ID",{day:"2-digit",month:"short"}).format(t)},tick:{fill:"#475569",fontSize:10},axisLine:!1,tickLine:!1,minTickGap:24}),e.jsx(f,{tick:{fill:"#475569",fontSize:11},tickFormatter:g,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(x,{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 (",o,")"]})]}),e.jsx("div",{className:"p-5",children:r.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:r,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 t=new Date(`${a}T00:00:00`);return Number.isNaN(t.getTime())?a:new Intl.DateTimeFormat("id-ID",{day:"2-digit",month:"short"}).format(t)},tick:{fill:"#475569",fontSize:10},axisLine:!1,tickLine:!1,minTickGap:24}),e.jsx(f,{yAxisId:"req",tick:{fill:"#475569",fontSize:11},tickFormatter:g,axisLine:!1,tickLine:!1}),e.jsx(f,{yAxisId:"money",orientation:"right",tick:{fill:"#475569",fontSize:11},tickFormatter:a=>g(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(x,{children:e.jsxs(C,{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",{...c,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 (",l," 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{q as default};