PageSourceSearch

https://aishudash-zzzaadkh.manus.space/assets/AdminUsers-j07i78Oz.js

js aishudash-zzzaadkh.manus.space collected 2026-10-03 05:01:51 UTC 14,853 bytes, 1 lines download raw bytes

1import{r as l,ae as x,j as e,h as B,af as $,ag as D,a5 as T,K as F,al as K,X as G,b4 as Q,b5 as X}from"./vendor-react-CSjVeD5C.js";import{t as h,B as a}from"./index-DCu_4ttF.js";import{A as Y}from"./AdminLayout-gr0C6aQ6.js";import{I as R}from"./input-CbkTLlBL.js";import{B as U}from"./badge-q_8Hkdab.js";import"./vendor-misc-DNIZ_o8-.js";import"./vendor-ui-BQCqNqg0.js";import"./vendor-charts-CTZ3m9kf.js";import"./vendor-ai-CwA6B3_0.js";import"./dialog-BspPSuTg.js";import"./useComposition-BO4n09CV.js";const g=20;function ae(){const[o,r]=l.useState(0),[u,A]=l.useState(""),[d,N]=l.useState(""),[n,f]=l.useState(""),[t,c]=l.useState(null),[b,m]=l.useState(""),y=h.useUtils(),v=()=>{r(0),N(u.trim())},E=()=>{A(""),N(""),r(0)},{data:i,isLoading:M,error:C}=h.admin.users.list.useQuery({limit:g,offset:o*g,...d?{search:d}:{}}),k=h.admin.users.updateRole.useMutation({onSuccess:()=>{y.admin.users.list.invalidate(),x.success("Role updated")},onError:s=>x.error(s.message)}),w=h.admin.users.hardDelete.useMutation({onSuccess:s=>{y.admin.users.list.invalidate(),x.success(`User "${s.deletedName}" permanently deleted`),c(null),m("")},onError:s=>{x.error(s.message),c(null),m("")}}),P=(s,j)=>{const I=j==="admin"?"user":"admin";confirm(`Change this user's role to ${I.toUpperCase()}?`)&&k.mutate({userId:s,role:I})},L=(s,j)=>{c({userId:s,userName:j,step:1}),m("")},z=()=>{t&&c({...t,step:2})},S=()=>{if(t){if(b.trim()!==t.userName){x.error("Name does not match — delete cancelled");return}w.mutate({userId:t.userId})}},p=i?.users.filter(s=>n?s.role===n:!0)??[];return e.jsx(Y,{"data-loc":"client/src/pages/admin/AdminUsers.tsx:113",children:e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:114",className:"space-y-6",children:[t&&e.jsx("div",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:117",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 backdrop-blur-sm",children:e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:118",className:"bg-[#1a0a0a] border border-red-900/50 rounded-xl p-6 w-full max-w-md 
1shadow-2xl",children:[e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:119",className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:120",className:"w-10 h-10 rounded-full bg-red-900/30 flex items-center justify-center",children:e.jsx(B,{"data-loc":"client/src/pages/admin/AdminUsers.tsx:121",className:"w-5 h-5 text-red-400"})}),e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:123",children:[e.jsx("h2",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:124",className:"text-base font-bold text-red-300",children:"Permanent Delete"}),e.jsx("p",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:125",className:"text-xs text-red-400/70",children:"This action cannot be undone"})]})]}),t.step===1?e.jsxs(e.Fragment,{children:[e.jsx("p",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:131",className:"text-sm text-warm-white mb-2",children:"You are about to permanently delete:"}),e.jsx("p",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:134",className:"text-base font-bold text-red-300 mb-4 px-3 py-2 bg-red-900/20 rounded-lg",children:t.userName}),e.jsxs("p",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:137",className:"text-xs text-soft-gray mb-6",children:["This will erase the user account and ",e.jsx("strong",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:138",className:"text-warm-white",children:"all associated data"})," — characters, memories, chat sessions, voice profiles, photos, and everything else. The user will need to register again from scratch."]}),e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:140",className:"flex gap-3",children:[e.jsx(a,{"data-loc":"client/src/pages/admin/AdminUsers.tsx:141",variant:"outline",className:"flex-1 bg-transparent border-white/10 text-soft-gray hover:text-warm-white",onClick:()=>c(null),children:"Cancel"}),e.jsx(a,{"data-loc":"client/src/pages/admin/AdminUsers.tsx:148",className:"flex-1 bg-red-900/40 hover:bg-red-900/60 text-red-300 border border-red-900/50",onClick:z,children:"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:158",className:"text-sm text-warm-white mb-3",children:"Type the user's name to confirm deletion:"}),e.jsx("p",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:161",className:"text-xs text-soft-gray mb-2 font-mono bg-white/5 px-2 py-1 rounded",children:t.userName}),e.jsx(R,{"data-loc":"client/src/pages/admin/AdminUsers.tsx:164",value:b,onChange:s=>m(s.target.value),onKeyDown:s=>s.key==="Enter"&&S(),placeholder:"Type name exactly…",className:"mb-4 bg-surface-2 border-red-900/30 text-warm-white placeholder:text-soft-gray/40 focus:border-red-500/50",autoFocus:!0}),e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:172",className:"flex gap-3",children:[e.jsx(a,{"data-loc":"client/src/pages/admin/AdminUsers.tsx:173",variant:"outline",className:"flex-1 bg-transparent border-white/10 text-soft-gray hover:text-warm-white",onClick:()=>{c(null),m("")},children:"Cancel"}),e.jsx(a,{"data-loc":"client/src/pages/admin/AdminUsers.tsx:180",className:"flex-1 bg-red-700/60 hover:bg-red-700/80 text-red-200 border border-red-700/50 disabled:opacity-40",onClick:S,disabled:b.trim()!==t.userName||w.isPending,children:w.isPending?e.jsx($,{"data-loc":"client/src/pages/admin/AdminUsers.tsx:186",className:"w-4 h-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(D,{"data-loc":"client/src/pages/admin/AdminUsers.tsx:189",className:"w-4 h-4 mr-1.5"}),"Delete Forever"]})})]})]})]})}),e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:201",className:"flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:202",children:[e.jsx("h1",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:203",className:"text-2xl font-heading font-bold text-warm-white",children:"Users"}),e.jsx("p",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:204",className:"text-sm text-soft-gray mt-1",children:"Manage user accounts and roles"})]}),i&&e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:207",className:"flex gap-2 flex-wrap",children:[e.jsxs(U,{"data-loc":"client/src/pages/admin/AdminUsers.tsx:208",className:`curs
1or-pointer text-xs ${n===""?"bg-white/15 text-warm-white border-white/20":"bg-white/5 text-soft-gray border-white/5 hover:text-warm-white"}`,onClick:()=>{f(""),r(0)},children:["All ",i.total]}),e.jsxs(U,{"data-loc":"client/src/pages/admin/AdminUsers.tsx:214",className:`cursor-pointer text-xs ${n==="admin"?"bg-rose-500/20 text-rose-300 border-rose-500/30":"bg-white/5 text-soft-gray border-white/5 hover:text-warm-white"}`,onClick:()=>{f(n==="admin"?"":"admin"),r(0)},children:[e.jsx(T,{"data-loc":"client/src/pages/admin/AdminUsers.tsx:218",className:"w-3 h-3 mr-1"}),"Admins"]}),e.jsxs(U,{"data-loc":"client/src/pages/admin/AdminUsers.tsx:220",className:`cursor-pointer text-xs ${n==="user"?"bg-cyan-500/20 text-cyan-300 border-cyan-500/30":"bg-white/5 text-soft-gray border-white/5 hover:text-warm-white"}`,onClick:()=>{f(n==="user"?"":"user"),r(0)},children:[e.jsx(F,{"data-loc":"client/src/pages/admin/AdminUsers.tsx:224",className:"w-3 h-3 mr-1"}),"Members"]})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:231",className:"flex gap-2",children:[e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:232",className:"relative flex-1 max-w-md",children:[e.jsx(K,{"data-loc":"client/src/pages/admin/AdminUsers.tsx:233",className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-soft-gray/50"}),e.jsx(R,{"data-loc":"client/src/pages/admin/AdminUsers.tsx:234",value:u,onChange:s=>A(s.target.value),onKeyDown:s=>s.key==="Enter"&&v(),placeholder:"Search by name or email…",className:"pl-9 bg-surface-2 border-white/10 text-warm-white placeholder:text-soft-gray/40 focus:border-rose-glow/40"}),u&&e.jsx("button",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:242",onClick:E,className:"absolute right-3 top-1/2 -translate-y-1/2 text-soft-gray/50 hover:text-soft-gray",children:e.jsx(G,{"data-loc":"client/src/pages/admin/AdminUsers.tsx:243",className:"w-3.5 h-3.5"})})]}),e.jsx(a,{"data-loc":"client/src/pages/admin/AdminUsers.tsx:247",onClick:v,className:"bg-rose-glow/20 hover:bg-rose-glow/30 text-rose-300 border border-rose-glow/20 text-sm",children:"Search"})]}),M&&e.jsx("div",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:256",className:"flex items-center justify-center py-20",children:e.jsx($,{"data-loc":"client/src/pages/admin/AdminUsers.tsx:257",className:"w-6 h-6 text-rose-glow animate-spin"})}),C&&e.jsx("div",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:262",className:"bg-rose-glow/10 border border-rose-glow/20 rounded-lg p-4",children:e.jsx("p",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:263",className:"text-sm text-rose-glow",children:C.message})}),i&&e.jsxs(e.Fragment,{children:[e.jsx("div",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:269",className:"bg-surface-2 border border-white/5 rounded-lg overflow-hidden",children:e.jsxs("table",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:270",className:"w-full",children:[e.jsx("thead",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:271",children:e.jsxs("tr",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:272",className:"border-b border-white/5",children:[e.jsx("th",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:273",className:"text-left text-xs uppercase tracking-wider text-soft-gray px-4 py-3",children:"User"}),e.jsx("th",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:274",className:"text-left text-xs uppercase tracking-wider text-soft-gray px-4 py-3",children:"Role"}),e.jsx("th",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:275",className:"text-left text-xs uppercase tracking-wider text-soft-gray px-4 py-3",children:"Sessions"}),e.jsx("th",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:276",className:"text-left text-xs uppercase tracking-wider text-soft-gray px-4 py-3",children:"Messages"}),e.jsx("th",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:277",className:"text-left text-xs uppercase tracking-wider text-soft-gray px-4 py-3",children:"Last Active"}),e.jsx("th",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:278",className:"text-right text-xs uppercase tracking-wider text-soft-gray px-4 py-3",children:"Actions"})]})}),e.jsxs("tbody",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:281",children:[p.length===0&&e.jsx("tr",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:283",children:e.jsx("td",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:284",colSpan:6,className:"px-4 py-8 text-center text-soft-gray text-sm",children:d?`No users matching "${d}"`:"No users found"})}),p.map(s=>e.jsxs("tr",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:290",className:"border-b border-white/5 last:border-0 hover:bg-white/[0.02]",children:[e.jsx("td",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:291",className:"px-4 py-3",children:e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:292",className:"flex items-center gap-3",children:[e.jsx("div",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:293",className:"w-8 h-8 rounded-full bg-surface-3 flex items-center justify-center",children:s.role==="admin"?e.jsx(T,{"data-loc":"client/src/pages/admin/AdminUsers.tsx:294",className:"w-4 h-4 text-rose-glow"}):e.jsx(F,{"data-loc":"client/src/pages/admin/AdminUsers.tsx:294",className:"w-4 h-4 text-soft-gray"})}),e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:296",children:[e.jsx("p",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:297",className:"text-sm font-medium text-warm-white",children:s.userName||"Unnamed"}),e.jsx("p",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:298",className:"text-xs text-soft-gray",children:s.email||`ID: ${s.userId}`})]})]})}),e.jsx("td",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:302",className:"px-4 py-3",children:e.jsx("span",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:303",className:`text-xs font-mono uppercase px-2 py-0.5 rounded ${s.role==="admin"?"bg-rose-glow/10 text-rose-glow":"bg-white/5 text-soft-gray"}`,children:s.role})}),e.jsx("td",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:307",className:"px-4 py-3 text-sm font-mono text-warm-white",children:s.totalSessions??0}),e.jsx("td",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:308",className:"px-4 py-3 text-sm font-mono text-warm-white",children:s.totalMessages??0}),e.jsx("td",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:309",className:"px-4 py-3 text-xs text-soft-gray",children:s.lastSignedIn?new Date(s.lastSignedIn).toLocaleDateString():"Never"}),e.jsx("td",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:312",className:"px-4 py-3 text-right",children:e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:313",className:"flex items-center justify-end gap-2",children:[e.jsx(a,{"data-loc":"client/src/pages/admin/AdminUsers.tsx:314",variant:"outline",size:"sm",onClick:()=>P(s.userId,s.role),disabled:k.isPending,className:"text-xs bg-transparent border-white/10 text-soft-gray hover:text-warm-white",children:s.role==="admin"?"Demote":"Promote"}),s.role!=="admin"&&e.jsx(a,{"data-loc":"client/src/pages/admin/AdminUsers.tsx:325",variant:"outline",size:"sm",onClick:()=>L(s.userId,s.userName||`User #${s.userId}`),className:"text-xs bg-transparent border-red-900/30 text-red-500/70 hover:text-red-400 hover:border-red-700/50 hover:bg-red-900/10",title:"Permanently delete this user and all their data",children:e.jsx(D,{"data-loc":"client/src/pages/admin/AdminUsers.tsx:332",className:"w-3.5 h-3.5"})})]})})]},s.userId))]})]})}),e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:343",className:"flex items-center justify-between",children:[e.jsx("p",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:344",className:"text-xs text-soft-gray",children:d?`${p.length} result${p.length!==1?"s":""} for "${d}"`:`Showing ${o*g+1}–${Math.min((o+1)*g,i.total)} of ${i.total}`}),e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminUsers.tsx:349",className:"flex gap-2",children:[e.jsx(a,{"data-loc":"client/src/pages/admin/AdminUsers.tsx:350",variant:"outline",size:"sm",onClick:()=>r(s=>Math.max(0,s-1)),disabled:o===0,className:"bg-transparent border-white/10 text-soft-gray",children:e.jsx(Q,{"data-loc":"client/src/pages/admin/AdminUsers.tsx:351",className:"w-4 h-4"})}),e.jsx(a,{"data-loc":"client/src/pages/admin/AdminUsers.tsx:353",variant:"outline",size:"sm",onClick:()=>r(s=>s+1),disabled:(o+1)*g>=i.total,className:"bg-transparent border-white/10 text-soft-gray",children:e.jsx(X,{"data-loc":"client/src/pages/admin/AdminUsers.tsx:354",className:"w-4 h-4"})})]})]})]})]})})}export{ae as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.