1import{h as p,a as v,u as y,w as b,V as w,ai as A,j as e,Y as l,$ as c,B as x,a2 as C,U as T,a3 as r,a4 as m,aq as k,as as U,at as M,au as o,av as n,aw as R,ax as t,O as B,aR as L}from"./index-BA-hDO3C.js";import{B as d}from"./badge-BmS2sdGI.js";import{S as h}from"./shield-BxDR8zf3.js";import{M as E}from"./mail-ZTV35zlk.js";import{B as D}from"./building-2-B59OQuVd.js";import{U as q}from"./user-check-DaHvBzHb.js";import{C as S}from"./calendar-DSpXbRC4.js";import{f as H}from"./format-CW0G_LzU.js";/** 2 * @license lucide-react v0.453.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const O=p("ToggleLeft",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"8",cy:"12",r:"2",key:"1nvbw3"}]]);/** 7 * @license lucide-react v0.453.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const Y=p("ToggleRight",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"16",cy:"12",r:"2",key:"4ma0v8"}]]);function J(){const{user:i}=v(),[,j]=y(),{toast:u}=b(),{data:a,isLoading:f,error:N}=w({queryKey:["/api/admin/users"],enabled:!!i}),g=A({mutationFn:async s=>(await B("POST",`/api/admin/users/${s}/toggle-admin`)).json(),onSuccess:s=>{u({title:"Admin status updated",description:s.message}),L.invalidateQueries({queryKey:["/api/admin/users"]})},onError:s=>{u({title:"Error updating admin status",description:(s==null?void 0:s.message)||"Failed to update admin privileges",variant:"destructive"})}});return f?e.jsx("div",{className:"container mx-auto py-8 px-4",children:e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("div",{className:"text-center",children:"Loading users..."})})}):N?e.jsx("div",{className:"container mx-auto py-8 px-4",children:e.jsx(l,{className:"max-w-2xl mx-auto",children:e.jsx(c,{className:"pt-6",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx(h,{className:"h-12 w-12 text-muted-foreground mx-auto"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Access Denied"}),e.jsx("p",{className:"text-muted-foreground",children:"You don't have permission to access this page."}),e.jsx(x,{onClick:()=>j("/"),children:"Return to Home"})]})})})}):e.jsx("div",{className:"container mx-auto py-8 px-4",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(x,{onClick:()=>j("/admin"),variant:"ghost",size:"sm",children:[e.jsx(C,{className:"h-4 w-4 mr-2"}),"Back to Dashboard"]}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"User Management"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Manage user accounts and permissions"})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(d,{variant:"outline",children:[e.jsx(T,{className:"h-3 w-3 mr-1"}),(a==null?void 0:a.length)||0," total users"]})})]}),e.jsxs(l,{children:[e.jsxs(r,{children:[e.jsx(m,{children:"All Users"}),e.jsx(k,{children:"View and manage user accounts, permissions, and activity"})]}),e.jsx(c,{children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(U,{children:[e.jsx(M,{children:e.jsxs(o,{children:[e.jsx(n,{children:"User"}),e.jsx(n,{children:"Email"}),e.jsx(n,{children:"Role"}),e.jsx(n,{children:"Data"}),e.jsx(n,{children:"Outreach"}),e.jsx(n,{children:"Joined"}),e.jsx(n,{className:"text-right",children:"Actions"})]})}),e.jsxs(R,{children:[a==null?void 0:a.map(s=>e.jsxs(o,{children:[e.jsx(t,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[s.isAdmin&&e.jsx(h,{className:"h-4 w-4 text-blue-600"}),s.username]})}),e.jsx(t,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{className:"h-3 w-3 text-muted-foreground"}),s.email]})}),e.jsx(t,{children:s.isAdmin?e.jsx(d,{variant:"default",children:"Admin"}):s.isGuest?e.jsx(d,{variant:"secondary",children:"Guest"}):e.jsx(d,{variant:"outline",children:"User"})}),e.jsx(t,{children:e.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(D,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{children:s.companies})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(q,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{children:s.contacts})]})]})}),e.jsx(t,{children:s.outreachEnabled?e.jsxs(d,{variant:"default",className:"text-xs",children:[e.jsx(Y,{className:"h-3 w-3 mr-1"}),"Enabled"]}):e.jsxs(d,{variant:"outline",className:"text-xs",children:[e.jsx(O,{className:"h-3 w-3 mr-1"}),"Disabled"]})}),e.jsx(t,{children:e.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx(S,{className:"h-3 w-3"}),H(new Date(s.createdAt),"MMM d, yyyy")]})}),e.jsxs(t,{className:"text-right",children:[s.id!==(i==null?void 0:i.id)&&e.jsxs(x,{onClick:()=>g.mutate(s.id),variant:s.isAdmin?"destructive":"outline",size:"sm",disabled:g.isPending,children:[e.jsx(h,{className:"h-3 w-3 mr-1"}),s.isAdmin?"Remove Admin":"Make Admin"]}),s.id===(i==null?void 0:i.id)&&e.jsx(d,{variant:"secondary",children:"You"})]})]},s.id)),(!a||a.length===0)&&e.jsx(o,{children:e.jsx(t,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No users found"})})]})]})})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs(l,{children:[e.jsx(r,{className:"pb-3",children:e.jsx(m,{className:"text-sm font-medium",children:"Total Admins"})}),e.jsxs(c,{children:[e.jsx("div",{className:"text-2xl font-bold",children:(a==null?void 0:a.filter(s=>s.isAdmin).length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Users with admin privileges"})]})]}),e.jsxs(l,{children:[e.jsx(r,{className:"pb-3",children:e.jsx(m,{className:"text-sm font-medium",children:"Active Users"})}),e.jsxs(c,{children:[e.jsx("div",{className:"text-2xl font-bold",children:(a==null?void 0:a.filter(s=>s.companies>0||s.contacts>0).length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Users with data in system"})]})]}),e.jsxs(l,{children:[e.jsx(r,{className:"pb-3",children:e.jsx(m,{className:"text-sm font-medium",children:"Outreach Users"})}),e.jsxs(c,{children:[e.jsx("div",{className:"text-2xl font-bold",children:(a==null?void 0:a.filter(s=>s.outreachEnabled).length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Users with outreach enabled"})]})]})]})]})})}export{J 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.