%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home2/rezakur1/ai.rezakurnia.com/zh-router-frontend/dist/assets/
Upload File :
Create Path :
Current File : //home2/rezakur1/ai.rezakurnia.com/zh-router-frontend/dist/assets/AdminUserDetailPage-CKYSyXs1.js

import{d as K,b as z,r as l,a as p,j as e}from"./index-BDMoG-ch.js";import{B as m}from"./Button-CLtEYZTH.js";import{C as A,b as T,a as G}from"./Card-DCk8Plvl.js";import{B as d}from"./Badge-BO45Wp4q.js";import{e as H,d as S,c as b,f as B}from"./format-CjhWL3Ta.js";function O(){return e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",className:"h-4 w-4","aria-hidden":!0,children:e.jsx("path",{d:"M10.5 19.5L3 12m0 0l7.5-7.5M3 12h18",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}function W(){return e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",className:"h-5 w-5","aria-hidden":!0,children:e.jsx("path",{d:"M3.75 13.5l10.5-11.25L12 10.5h8.25L9.75 21.75 12 13.5H3.75z",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}function Y(){const{id:E}=K(),h=z(),c=Number(E)||0,[a,u]=l.useState(null),[L,j]=l.useState(!0),[f,N]=l.useState(null),[g,y]=l.useState(!1),[w,v]=l.useState(null),[o,k]=l.useState(null),[_,P]=l.useState(null),C=l.useCallback(async()=>{if(c){j(!0),N(null);try{const s=await p(`/admin/users/${c}/analytics?days=30`);u(s)}catch(s){N(s instanceof Error?s.message:"Gagal memuat detail user")}finally{j(!1)}}},[c]);l.useEffect(()=>{C()},[C]);const $=async()=>{if(!a||g)return;y(!0),v(null);const s=Number(a.user.is_unlimited)!==1;try{const i=await p(`/admin/users/${c}/unlimited`,{method:"PATCH",body:{unlimited:s}});u(n=>n&&{...n,user:{...n.user,is_unlimited:i.is_unlimited}})}catch(i){v(i instanceof Error?i.message:"Gagal mengubah akses")}finally{y(!1)}},I=async s=>{if(!(!a||o!==null)){k(s),P(null);try{await p(`/admin/keys/${s}/reset-ip`,{method:"POST",body:{}}),u(i=>i&&{...i,keys:i.keys.map(n=>n.id===s?{...n,bound_ip:null}:n)})}catch(i){P(i instanceof Error?i.message:"Gagal reset IP")}finally{k(null)}}};if(!c)return e.jsx("div",{className:"px-5 py-10 text-center text-sm text-slate-500",children:"ID pengguna tidak valid."});if(L&&!a)return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"h-32 animate-pulse rounded-2xl border border-white/[0.04] bg-white/[0.02]"}),e.jsx("div",{className:"h-48 animate-pulse rounded-2xl border border-white/[0.04] bg-white/[0.02]"})]});if(f&&!a)return e.jsx("div",{className:"rounded-xl border border-red-500/25 bg-red-500/10 px-4 py-6 text-center text-sm text-red-300",children:f});if(!a)return null;const r=a.user,x=Number(r.is_unlimited)===1,t=a.usage,q=Number((t==null?void 0:t.requests)??0),D=Number((t==null?void 0:t.input_tokens)??0),M=Number((t==null?void 0:t.cached_tokens)??0),R=Number((t==null?void 0:t.output_tokens)??0),U=Number((t==null?void 0:t.cost)??0);return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{children:e.jsxs("button",{type:"button",onClick:()=>h("/admin/users"),className:"inline-flex items-center gap-1.5 text-xs font-medium text-slate-400 transition hover:text-slate-200",children:[e.jsx(O,{}),"Kembali ke Pengguna"]})}),e.jsx(A,{children:e.jsxs(T,{children:[e.jsxs("div",{className:"flex flex-wrap items-start gap-4",children:[e.jsx("div",{className:"flex h-14 w-14 shrink-0 items-center justify-center rounded-2xl bg-ink-700 text-lg font-semibold text-white",children:r.name.charAt(0).toUpperCase()}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"flex flex-wrap items-center gap-2 text-lg font-semibold text-white",children:[r.name,Number(r.is_admin)===1&&e.jsx(d,{tone:"info",children:"Admin"}),Number(r.is_active)===1?e.jsx(d,{tone:"success",children:"Aktif"}):e.jsx(d,{tone:"danger",children:"Suspend"}),x&&e.jsx(d,{tone:"warning",children:"Unlimited AI"})]}),e.jsx("p",{className:"truncate text-sm text-slate-500",children:r.email}),e.jsxs("p",{className:"mt-1 text-xs tabular-nums text-slate-600",children:["Terdaftar ",H(r.created_at)]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2.5 text-center text-xs sm:gap-3",children:[e.jsxs("div",{className:"rounded-xl border border-white/[0.06] bg-white/[0.02] px-3 py-2.5",children:[e.jsx("p",{className:"text-[10px] text-slate-500",children:"Saldo"}),e.jsx("p",{className:"mt-0.5 font-semibold tabular-nums text-slate-200",children:S(r.balance)})]}),e.jsxs("div",{className:"rounded-xl border border-white/[0.06] bg-white/[0.02] px-3 py-2.5",children:[e.jsx("p",{className:"text-[10px] text-slate-500",children:"Requests (30 hr)"}),e.jsx("p",{className:"mt-0.5 font-semibold tabular-nums text-slate-200",children:q})]}),e.jsxs("div",{className:"rounded-xl border border-white/[0.06] bg-white/[0.02] px-3 py-2.5",children:[e.jsx("p",{className:"text-[10px] text-slate-500",children:"Biaya (30 hr)"}),e.jsx("p",{className:"mt-0.5 font-semibold tabular-nums text-slate-200",children:S(String(U))})]})]})]}),e.jsx("div",{className:"mt-5 rounded-2xl border border-amber-400/20 bg-amber-500/[0.06] p-4",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-xl ${x?"bg-amber-500/20 text-amber-300":"bg-white/[0.05] text-slate-500"}`,children:e.jsx(W,{})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-white",children:"Akses Unlimited AI"}),e.jsx("p",{className:"mt-0.5 max-w-md text-xs text-slate-400",children:x?"Pengguna ini bisa memakai AI kapanpun tanpa dipotong saldo atau kuota paket.":"Pengguna ini memakai saldo / kuota paket seperti biasa."}),w&&e.jsx("p",{className:"mt-1 text-xs text-red-300",children:w})]})]}),e.jsx("button",{type:"button",role:"switch","aria-checked":x,disabled:g,onClick:()=>void $(),className:`relative h-7 w-12 shrink-0 rounded-full transition-colors disabled:opacity-40 ${x?"bg-amber-500/70":"bg-white/[0.08]"}`,children:e.jsx("span",{className:`absolute top-1 h-5 w-5 rounded-full bg-white transition-all ${x?"left-[26px]":"left-1"}`})})]})})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:gap-4 xl:grid-cols-4",children:[e.jsxs("div",{className:"rounded-xl border border-white/[0.06] bg-white/[0.02] px-4 py-3",children:[e.jsx("p",{className:"text-[10px] text-slate-500",children:"Input Tokens"}),e.jsx("p",{className:"mt-0.5 font-semibold tabular-nums text-slate-200",children:b(D)})]}),e.jsxs("div",{className:"rounded-xl border border-white/[0.06] bg-white/[0.02] px-4 py-3",children:[e.jsx("p",{className:"text-[10px] text-slate-500",children:"Cached Tokens"}),e.jsx("p",{className:"mt-0.5 font-semibold tabular-nums text-slate-200",children:b(M)})]}),e.jsxs("div",{className:"rounded-xl border border-white/[0.06] bg-white/[0.02] px-4 py-3",children:[e.jsx("p",{className:"text-[10px] text-slate-500",children:"Output Tokens"}),e.jsx("p",{className:"mt-0.5 font-semibold tabular-nums text-slate-200",children:b(R)})]}),e.jsxs("div",{className:"rounded-xl border border-white/[0.06] bg-white/[0.02] px-4 py-3",children:[e.jsx("p",{className:"text-[10px] text-slate-500",children:"Model Dipakai"}),e.jsx("p",{className:"mt-0.5 font-semibold tabular-nums text-slate-200",children:a.models.length})]})]}),e.jsxs(A,{children:[e.jsx(G,{title:"API Keys & IP",subtitle:"Setiap key terikat ke 1 IP — reset jika user ganti jaringan/IP"}),e.jsxs(T,{className:"p-0",children:[_&&e.jsx("p",{className:"px-5 pt-3 text-xs text-red-300",children:_}),a.keys.length===0?e.jsx("div",{className:"px-5 py-8 text-center text-sm text-slate-500",children:"Pengguna ini belum memiliki API key."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"divide-y divide-white/[0.04] md:hidden",children:a.keys.map(s=>e.jsxs("div",{className:"px-5 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"flex items-center gap-2 font-medium text-white",children:[e.jsx("span",{className:"truncate",children:s.name}),e.jsxs("span",{className:"shrink-0 font-mono text-[10px] text-slate-500",children:[s.key_prefix,"…"]})]}),e.jsxs("p",{className:"mt-0.5 text-[10px] text-slate-500",children:[s.requests," request · terakhir"," ",s.last_used_at?B(s.last_used_at):"—"]})]}),Number(s.is_active)===1?e.jsx(d,{tone:"success",children:"Aktif"}):e.jsx(d,{tone:"default",children:"Nonaktif"})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-xs",children:[e.jsxs("div",{className:"rounded-lg border border-white/[0.06] bg-white/[0.02] px-2.5 py-1.5",children:[e.jsx("p",{className:"text-[10px] text-slate-500",children:"IP Terikat"}),e.jsx("p",{className:"mt-0.5 truncate font-mono text-[11px] font-medium text-slate-200",children:s.bound_ip||"Belum terikat"})]}),e.jsxs("div",{className:"rounded-lg border border-white/[0.06] bg-white/[0.02] px-2.5 py-1.5",children:[e.jsx("p",{className:"text-[10px] text-slate-500",children:"IP Terakhir"}),e.jsx("p",{className:"mt-0.5 truncate font-mono text-[11px] text-slate-400",children:s.last_ip||"—"})]})]}),e.jsx("div",{className:"mt-3 flex justify-end",children:e.jsx(m,{variant:"ghost",size:"sm",disabled:o===s.id,onClick:()=>void I(s.id),children:o===s.id?"Mereset…":"Reset IP"})})]},s.id))}),e.jsx("div",{className:"hidden overflow-x-auto md:block",children:e.jsxs("table",{className:"w-full min-w-[720px] 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:"Key"}),e.jsx("th",{className:"px-4 py-3 font-semibold",children:"Status"}),e.jsx("th",{className:"px-4 py-3 font-semibold",children:"IP Terikat"}),e.jsx("th",{className:"px-4 py-3 font-semibold",children:"IP Terakhir"}),e.jsx("th",{className:"px-4 py-3 font-semibold",children:"Terakhir Dipakai"}),e.jsx("th",{className:"px-5 py-3 text-right font-semibold",children:"Aksi"})]})}),e.jsx("tbody",{children:a.keys.map(s=>e.jsxs("tr",{className:"border-b border-white/[0.04] transition-colors last:border-0 hover:bg-white/[0.02]",children:[e.jsxs("td",{className:"px-5 py-3.5",children:[e.jsx("p",{className:"font-medium text-white",children:s.name}),e.jsxs("p",{className:"font-mono text-[11px] text-slate-500",children:[s.key_prefix,"…"]})]}),e.jsx("td",{className:"px-4 py-3.5",children:Number(s.is_active)===1?e.jsx(d,{tone:"success",children:"Aktif"}):e.jsx(d,{tone:"default",children:"Nonaktif"})}),e.jsx("td",{className:"px-4 py-3.5",children:e.jsx("span",{className:"font-mono text-xs text-slate-200",children:s.bound_ip||"Belum terikat"})}),e.jsx("td",{className:"px-4 py-3.5 font-mono text-xs text-slate-400",children:s.last_ip||"—"}),e.jsx("td",{className:"px-4 py-3.5 text-xs tabular-nums text-slate-500",children:s.last_used_at?B(s.last_used_at):"—"}),e.jsx("td",{className:"px-5 py-3.5 text-right",children:e.jsx(m,{variant:"ghost",size:"sm",disabled:o===s.id,onClick:()=>void I(s.id),children:o===s.id?"Mereset…":"Reset IP"})})]},s.id))})]})})]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx(m,{variant:"ghost",onClick:()=>h(`/admin/analytics?user=${c}`),children:"Lihat Analisa Lengkap"}),e.jsx(m,{variant:"ghost",onClick:()=>h(`/admin/topup?q=${r.email}`),children:"Cek Order Top Up"})]})]})}export{Y as default};

Zerion Mini Shell 1.0