1import{r as i,j as e}from"./react-vendor-DKbO0zba.js";import{a8 as j,c as f,D as C,o as M,p as b,E as l}from"./index-BgbQzHQM.js";import{A as O}from"./AuthenticatedLayout-VR1oXQE6.js";import{C as L}from"./ConfirmDialog-d8DKbYmV.js";import{e as U,r as D,f as E}from"./admin-4s8lppNM.js";import{u as R}from"./useDebounce-p2IwmFvF.js";import{f as A}from"./AppTopBar-DvYCtcLp.js";import{S as F}from"./search-CbGBc7QD.js";import{S as k}from"./shield-C2V5hVJG.js";import"./usePublicPlans-CvFOroBj.js";import"./LanguageSwitcher-D95GkgE-.js";import"./OrgSwitcher-Bhjq4cv1.js";import"./framer-motion-DCn40pwX.js";import"./firebase-BWzRhu08.js";import"./invitations-CkPFcIRM.js";import"./sun-DdCRErpc.js";/** 2 * @license lucide-react v0.577.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 P=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],T=j("log-out",P);/** 7 * @license lucide-react v0.577.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 $=[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]],q=j("shield-off",$);function B(t){return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}function ae(){const{t}=f("system-admin"),{t:x}=f("common"),v=C(),[u,N]=i.useState(""),p=R(u,300),[a,d]=i.useState(null),[n,o]=i.useState(null),{data:m=[],isLoading:_}=M({queryKey:["admin-users",p],queryFn:()=>E(0,100,p||void 0)}),c=b({mutationFn:({userId:s,systemRole:r})=>U(s,r),onSuccess:(s,r)=>{v.invalidateQueries({queryKey:["admin-users"]}),l.success(r.systemRole?t("users.toasts.granted"):t("users.toasts.revoked")),d(null)},onError:s=>{var r,h;l.error(((h=(r=s==null?void 0:s.response)==null?void 0:r.data)==null?void 0:h.detail)||t("users.toasts.failed"))}}),g=b({mutationFn:s=>D(s),onSuccess:s=>{l.success(t("users.embedSignOut.toasts.done",{count:s.revoked_count})),o(null)},onError:()=>{l.error(t("users.embedSignOut.toasts.failed"))}}),w=s=>{d(s)},S=()=>{if(!a)return;const s=a.system_role==="super_admin"?null:"super_admin";c.mutate({userId:a.id,systemRole:s})},y=i.useMemo(()=>[...m].sort((s,r)=>s.system_role==="super_admin"&&r.system_role!=="super_admin"?-1:s.system_role!=="super_admin"&&r.system_role==="super_admin"?1:(s.email||"").localeCompare(r.email||"")),[m]);return e.jsx(O,{children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:[e.jsx("div",{className:"flex items-center justify-between mb-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(A,{className:"w-6 h-6 text-pink-500"}),e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:t("users.page.title")}),e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("users.page.countLabel",{count:m.length})})]})}),e.jsx("div",{className:"mb-6",children:e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(F,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{type:"text",value:u,onChange:s=>N(s.target.value),placeholder:t("users.searchPlaceholder"),className:"w-full pl-10 pr-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-pink-500 focus:border-transparent text-sm"})]})}),_?e.jsx("div",{className:"text-center py-12 text-gray-500",children:t("users.empty.loading")}):y.length===0?e.jsx("div",{className:"text-center py-12 text-gray-500 dark:text-gray-400",children:t("users.empty.none")}):e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-900/50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("users.table.columns.user")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("users.table.columns.email")}),e.jsx("th",{className:"px-4 py-3 text-center text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("users.table.columns.systemRole")}
11),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("users.table.columns.created")}),e.jsx("th",{className:"px-4 py-3 text-center text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:t("users.table.columns.actions")})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:y.map(s=>{var r;return e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50",children:[e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-200 dark:bg-gray-600 flex items-center justify-center text-sm font-medium text-gray-600 dark:text-gray-300",children:(((r=s.first_name)==null?void 0:r[0])||s.email[0]||"?").toUpperCase()}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:s.first_name&&s.last_name?`${s.first_name} ${s.last_name}`:s.username||s.email.split("@")[0]}),e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:["@",s.username||t("users.table.usernameFallback")]})]})]})}),e.jsx("td",{className:"px-4 py-3 text-sm text-gray-700 dark:text-gray-300",children:s.email}),e.jsx("td",{className:"px-4 py-3 text-center",children:s.system_role==="super_admin"?e.jsxs("span",{className:"inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-xs font-medium bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-400",children:[e.jsx(k,{className:"w-3 h-3"}),t("users.roleBadge.superAdmin")]}):e.jsx("span",{className:"text-xs text-gray-400",children:t("users.table.emptyDash")})}),e.jsx("td",{className:"px-4 py-3 text-sm text-gray-500 dark:text-gray-400",children:B(s.created_at)}),e.jsx("td",{className:"px-4 py-3 text-center",children:e.jsxs("div",{className:"inline-flex items-center gap-1",children:[e.jsx("button",{onClick:()=>w(s),className:`inline-flex items-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium transition-colors ${s.system_role==="super_admin"?"text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20":"text-purple-600 hover:bg-purple-50 dark:text-purple-400 dark:hover:bg-purple-900/20"}`,"aria-label":s.system_role==="super_admin"?t("users.tooltips.revoke"):t("users.tooltips.grant"),"data-help":s.system_role==="super_admin"?"system.users.revokeSuperAdmin":"system.users.grantSuperAdmin",children:s.system_role==="super_admin"?e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"w-3.5 h-3.5"}),t("users.actions.revoke")]}):e.jsxs(e.Fragment,{children:[e.jsx(k,{className:"w-3.5 h-3.5"}),t("users.actions.grant")]})}),e.jsxs("button",{onClick:()=>o(s),className:"inline-flex items-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700 transition-colors","aria-label":t("users.embedSignOut.tooltip"),"data-help":"system.users.embedSignOut",children:[e.jsx(T,{className:"w-3.5 h-3.5"}),t("users.embedSignOut.action")]})]})})]},s.id)})})]})})}),e.jsx(L,{isOpen:n!==null,title:t("users.embedSignOut.title"),body:t("users.embedSignOut.body",{email:(n==null?void 0:n.email)??""}),confirmLabel:t("users.embedSignOut.confirm"),cancelLabel:x("actions.cancel"),isLoading:g.isPending,danger:!0,confirmHelpId:"system.users.embedSignOutConfirm",onConfirm:()=>n&&g.mutate(n.id),onClose:()=>o(null)}),a&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-sm p-6 mx-4",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:a.system_role==="super_admin"?t("users.confirmModal.revokeTitle"):t("users.confirmModal.grantTitle")}),e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-1",children:[t("users.confirmModal.userLine")," ",e.jsx("strong",{children:a.email})]}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:a.system_role==="super_admin"?t("users.confirmModal.revokeBody"):t("users.confirmModal.grantBody")}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>d(null),"data-help":"common.dialog.cancel",className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:x("actions.cancel")}),e.jsx("button",{onClick:S,disabled:c.isPending,"data-help":a.system_role==="super_admin"?"system.users.revokeConfirm":"system.users.grantConfirm",className:`px-4 py-2 text-sm text-white rounded-lg disabled:opacity-50 transition-colors ${a.system_role==="super_admin"?"bg-red-600 hover:bg-red-700":"bg-purple-600 hover:bg-purple-700"}`,children:c.isPending?t("users.confirmModal.updatingBtn"):a.system_role==="super_admin"?t("users.confirmModal.revokeCta"):t("users.confirmModal.grantCta")})]})]})})]})})}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.