PageSourceSearch

https://translatewithrobert.ai/assets/UserManagement-DkwFlWkv.js

js translatewithrobert.ai collected 2026-10-05 13:07:55 UTC 30,928 bytes, 1 lines download raw bytes

1import{r as n,aL as oe,j as e,O as me,P as xe,Q as he,T as pe,aC as be,V as ue,as as se,W as R,M as te,g as k,aM as ae,Y as je,$ as fe,X as le,Z as ee,A as Ne,C as ve,S as ge,at as M,au as O,av as Z,aw as J,ax as _,ay as B,az as H,aA as G,a0 as we}from"./index-CZOWUzv0.js";import{P as ye,a as Ce,b as L,c as ke,d as Se,e as De,f as Ae}from"./pagination-CN-lt3b5.js";import{D as Y}from"./departments-iWuY7abl.js";import{C as re}from"./camera-CWQvUqep.js";import{B as ne}from"./briefcase-BaOR8TuL.js";import{o as ie,Z as de,s as U}from"./schemas-mzGMho_E.js";import{C as Pe}from"./clock-zOLdTji6.js";import{P as ze}from"./pen-line-Dl4GTF5_.js";import{T as Fe}from"./trash-2-Pxaj3iL5.js";import"./chevron-left-CB1bxXaC.js";import"./more-horizontal-Dkj_apfW.js";import"./chevron-right-BZOPwnCu.js";const K=()=>{const t=n.useContext(oe);if(!t)throw new Error("useCompanyUsers must be used within a CompanyUsersProvider");return t},Ue=ie({firstName:U().min(2,"First name must be at least 2 characters").regex(/^[a-zA-Z\s'-]+$/,"First name can only contain letters, spaces, hyphens, and apostrophes"),lastName:U().min(2,"Last name must be at least 2 characters").regex(/^[a-zA-Z\s'-]+$/,"Last name can only contain letters, spaces, hyphens, and apostrophes"),email:U().email("Please enter a valid email address"),department:U().min(1,"Please select a department")}),Re=({isOpen:t,onClose:d})=>{const{inviteUser:z,isInviting:p}=K(),y=n.useRef(null),[c,u]=n.useState({firstName:"",lastName:"",email:"",department:"Marketing"}),[j,g]=n.useState(null),[F,f]=n.useState(""),[i,S]=n.useState({}),D=a=>{var o;const x=(o=a.target.files)==null?void 0:o[0];if(x){g(x);const h=new FileReader;h.onloadend=()=>{f(h.result)},h.readAsDataURL(x)}},N=a=>{i[a]&&S(x=>{const o={...x};return delete o[a],o})},w=()=>{u({firstName:"",lastName:"",email:"",department:"Marketing"}),g(null),f(""),S({})},m=()=>{w(),d()},C=async a=>{a.preventDefault(),S({});try{Ue.parse(c),await z({firstName:c.firstName,lastName:c.lastName,email:c.email,department:c.department,avatar:j}),m()}catch(x){if(x instanceof de){const o={};x.issues.forEach(h=>{h.path[0]&&(o[h.path[0].toString()]=h.message)}),S(o)}}};return e.jsx(me,{open:t,onOpenChange:a=>!a&&m(),children:e.jsxs(xe,{className:"gap-0 p-0 sm:max-w-md",children:[e.jsxs(he,{className:"border-b border-slate-100 bg-slate-50 p-6",children:[e.jsxs(pe,{className:"flex items-center text-lg font-bold text-slate-800",children:[e.jsx(be,{size:20,className:"mr-2 text-emerald-600"}),"Add New User"]}),e.jsx(ue,{className:"text-sm text-slate-500",children:"Send an invitation to a new team member"})]}),e.jsxs("form",{onSubmit:C,className:"space-y-4 p-6",children:[e.jsxs("div",{className:"mb-6 flex flex-col items-center",children:[e.jsxs("div",{className:"group relative",children:[e.jsx("div",{className:"flex h-20 w-20 items-center justify-center overflow-hidden rounded-full border-2 border-dashed border-slate-300 bg-slate-50",children:F?e.jsx("img",{src:F,alt:"Avatar preview",className:"h-full w-full object-cover"}):e.jsx(re,{size:24,className:"text-slate-300"})}),e.jsx("button",{title:"Upload Avatar",type:"button",onClick:()=>{var a;return(a=y.current)==null?void 0:a.click()},className:"absolute inset-0 flex items-center justify-center rounded-full bg-black/40 text-white opacity-0 transition-opacity group-hover:opacity-100",children:e.jsx(se,{size:20})})]}),e.jsx("button",{type:"button",onClick:()=>{var a;return(a=y.current)==null?void 0:a.click()},className:"mt-2 text-[10px] font-bold uppercase text-emerald-600 hover:underline",children:"Upload Avatar"}),e.jsx("input",{title:"Upload Avatar",type:"file",ref:y,className:"hidden",accept:"image/*",onChange:D})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block text-sm font-medium text-slate-700",children:"First Name"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3",children:e.jsx(R,{size:16,className:"text-slate-400"})}),e.jsx("input",{type:"text",value:c.firstName,onChange:a=>{u({...c,firstName:a.target.value}),N("firstName")},placeholder:"Jane",className:`w-full rounded-lg border py-2.5 pl-10 pr-3 outline-none transition-all focus:border-emerald-500 focus:ring-2 focus:ring-emerald-500 ${i.firstName?"border-red-500":"border-slate-300"}`})]}),i.firstName&&e.jsx("p",{className:"mt-1 text-xs text-red-500",children:i.firstName})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block text-sm font-medium text-slate-700",children:"Last Name"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3",children:e.jsx(R,{size:16,className:"text-slate-400"})}),e.jsx("input",{type:"text",value:c.lastName,onChange:a=>{u({...c,lastName:a.target.value}),N("lastName")},placeholder:"Doe",className:`w-full rounded-lg border py-2.5 pl-10 pr-3 outline-none transition-all focus:border-emerald-500 focus:ring-2 focus:ring-emerald-500 ${i.lastName?"border-red-500":"border-slate-300"}`})]}),i.lastName&&e.jsx("p",{className:"mt-1 text-xs text-red-500",children:i.lastName})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block text-sm font-medium text-slate-700",children:"Email Address"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3",children:e.jsx(te,{size:16,className:"text-slate-400"})}),e.jsx("input",{type:"email",value:c.email,onChange:a=>{u({...c,email:a.target.value}),N("email")},placeholder:"[email protected]",className:`w-full rounded-lg border py-2.5 pl-10 pr-3 outline-none transition-all focus:border-emerald-500 focus:ring-2 focus:ring-emerald-500 ${i.email?"border-red-500":"border-slate-300"}`})]}),i.email&&e.jsx("p",{className:"mt-1 text-xs text-red-500",children:i.email})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block text-sm font-medium text-slate-700",children:"Department"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3",children:e.jsx(ne,{size:16,className:"text-slate-400"})}),e.jsx("select",{title:"Select a department",value:c.department,onChange:a=>{u({...c,department:a.target.value}),N("department")},className:`w-full appearance-none rounded-lg border bg-white py-2.5 pl-10 pr-3 outline-none transition-all focus:ring-2 focus:ring-emerald-500 ${i.department?"border-red-500":"border-slate-300"}`,children:Y.map(a=>e.jsx("option",{value:a,children:a},a))})]}),i.department&&e.jsx("p",{className:"mt-1 text-xs text-red-500",children:i.department})]}),e.jsxs("div",{className:"flex space-x-3 pt-4",children:[e.jsx("button",{type:"button",onClick:m,disabled:p,className:"flex-1 rounded-lg border border-slate-300 py-2.5 font-medium text-slate-700 transition-colors hover:bg-slate-50 disabled:opacity-50",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:p,className:"flex flex-1 items-center justify-center rounded-lg bg-emerald-600 py-2.5 font-medium text-white shadow-sm transition-colors hover:bg-emerald-700 disabled:opacity-50",children:p?e.jsxs(e.Fragment,{children:[e.jsx(k,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Invitation"})]})]})]})})},Ee=ie({firstName:U().min(2,"First name must be at least 2 characters").regex(/^[a-zA-Z\s'-]+$/,"First name can only contain letters, space
1s, hyphens, and apostrophes"),lastName:U().min(2,"Last name must be at least 2 characters").regex(/^[a-zA-Z\s'-]+$/,"Last name can only contain letters, spaces, hyphens, and apostrophes"),department:U().min(1,"Please select a department")}),Ie=({user:t,onClose:d,initialTab:z="Overview"})=>{const{editUser:p,deleteUser:y,resendInvitation:c,isEditing:u,isDeleting:j,isResending:g}=K(),F=n.useRef(null),[f,i]=n.useState(z),[S,D]=n.useState(!1),[N,w]=n.useState(!1),[m,C]=n.useState({firstName:"",lastName:"",department:""}),[a,x]=n.useState(null),[o,h]=n.useState(""),[b,A]=n.useState({});if(n.useEffect(()=>{t&&(C({firstName:t.firstName,lastName:t.lastName,department:t.department||"Marketing"}),h(t.avatar||""),x(null),A({}))},[t]),n.useEffect(()=>{i(z)},[z]),!t)return null;const W=l=>{var r;const s=(r=l.target.files)==null?void 0:r[0];if(s){x(s);const v=new FileReader;v.onloadend=()=>{h(v.result)},v.readAsDataURL(s)}},E=l=>{b[l]&&A(s=>{const r={...s};return delete r[l],r})},q=async()=>{A({});try{Ee.parse(m),await p(t._id,{firstName:m.firstName,lastName:m.lastName,department:m.department,avatar:a}),d()}catch(l){if(l instanceof de){const s={};l.issues.forEach(r=>{r.path[0]&&(s[r.path[0].toString()]=r.message)}),A(s)}}},Q=async()=>{await y(t._id),D(!1),d()},V=async()=>{await c(t.email),w(!1)},T=l=>l?new Date(l).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}):"N/A",P=`${t.firstName} ${t.lastName}`,$=t.status==="pending";return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4 backdrop-blur-sm duration-200 animate-in fade-in",children:e.jsxs("div",{className:"flex h-[85vh] w-full max-w-[1200px] overflow-hidden rounded-2xl bg-white shadow-2xl duration-200 animate-in zoom-in-95",children:[e.jsxs("div",{className:"flex w-80 shrink-0 flex-col overflow-y-auto border-r border-slate-200 bg-slate-50 p-8",children:[e.jsxs("div",{className:"mb-8 flex flex-col items-center text-center",children:[e.jsx("div",{className:"mb-4 flex h-24 w-24 items-center justify-center overflow-hidden rounded-full border-4 border-white bg-white text-slate-400 shadow-sm",children:t.avatar?e.jsx("img",{src:t.avatar,alt:P,className:"h-full w-full object-cover"}):e.jsx(R,{size:48})}),e.jsx("h2",{className:"mb-1 text-xl font-bold leading-tight text-slate-900",children:P}),e.jsx("p",{className:"mb-3 text-sm text-slate-500",children:t.role}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:`rounded-full border px-2.5 py-0.5 text-[10px] font-bold uppercase tracking-wide ${t.status==="active"?"border-emerald-200 bg-emerald-50 text-emerald-700":t.status==="pending"?"border-amber-200 bg-amber-50 text-amber-700":"border-slate-200 bg-slate-50 text-slate-500"}`,children:t.status||"Active"})}),$&&e.jsx("button",{onClick:()=>w(!0),disabled:g,className:"mt-4 flex items-center rounded-lg border border-amber-200 bg-amber-50 px-4 py-2 text-xs font-bold text-amber-700 transition-colors hover:bg-amber-100",children:g?e.jsxs(e.Fragment,{children:[e.jsx(k,{size:14,className:"mr-2 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ae,{size:14,className:"mr-2"}),"Resend Invitation"]})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"mb-4 text-xs font-bold uppercase tracking-wider text-slate-400",children:"Contact Info"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start",children:[e.jsx(te,{size:16,className:"mr-3 mt-0.5 shrink-0 text-slate-400"}),e.jsx("p",{className:"break-all text-sm text-slate-600",children:t.email})]}),e.jsxs("div",{className:"flex items-start",children:[e.jsx(ne,{size:16,className:"mr-3 mt-0.5 shrink-0 text-slate-400"}),e.jsx("p",{className:"text-sm text-slate-600",children:t.department||"Not assigned"})]})]})]}),e.jsxs("div",{className:"border-t border-slate-200 pt-6",children:[e.jsx("h3",{className:"mb-4 text-xs font-bold uppercase tracking-wider text-slate-400",children:"Account Stats"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start",children:[e.jsx(je,{size:16,className:"mr-3 mt-0.5 shrink-0 text-slate-400"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Joined"}),e.jsx("p",{className:"text-sm font-medium text-slate-800",children:T(t.lastActive)})]})]}),e.jsxs("div",{className:"flex items-start",children:[e.jsx(Pe,{size:16,className:"mr-3 mt-0.5 shrink-0 text-slate-400"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Last Active"}),e.jsx("p",{className:"text-sm font-medium text-slate-800",children:T(t.lastActive)})]})]})]})]})]})]}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col bg-white",children:[e.jsxs("div",{className:"flex h-16 shrink-0 items-center justify-between border-b border-slate-100 bg-white px-8",children:[e.jsx("h2",{className:"text-lg font-bold text-slate-800",children:"User Details"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{className:"flex items-center rounded-lg px-3 py-2 text-sm font-medium text-slate-500 transition hover:bg-slate-50 hover:text-slate-800",children:[e.jsx(fe,{size:16,className:"mr-2"})," Export Data"]}),e.jsx("div",{className:"h-6 w-px bg-slate-200"}),e.jsx("button",{onClick:d,className:"rounded-full bg-slate-50 p-2 text-slate-400 transition-colors hover:bg-slate-100 hover:text-slate-600","aria-label":"Close",children:e.jsx(le,{size:20})})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto bg-white p-8",children:[e.jsxs("div",{className:"mb-8 grid grid-cols-3 gap-6",children:[e.jsxs("div",{className:"rounded-xl border border-slate-100 bg-white p-5 shadow-sm transition-shadow hover:shadow-md",children:[e.jsx("div",{className:"mb-2 flex items-start justify-between",children:e.jsx("div",{className:"rounded-lg bg-blue-50 p-2 text-blue-600",children:e.jsx(ee,{size:20})})}),e.jsx("p",{className:"text-xs font-bold uppercase tracking-wider text-slate-500",children:"Jobs Submitted"}),e.jsx("h3",{className:"mt-1 text-2xl font-bold text-slate-800",children:"-"})]}),e.jsxs("div",{className:"rounded-xl border border-slate-100 bg-white p-5 shadow-sm transition-shadow hover:shadow-md",children:[e.jsx("div",{className:"mb-2 flex items-start justify-between",children:e.jsx("div",{className:"rounded-lg bg-purple-50 p-2 text-purple-600",children:e.jsx(Ne,{size:20})})}),e.jsx("p",{className:"text-xs font-bold uppercase tracking-wider text-slate-500",children:"Words Processed"}),e.jsx("h3",{className:"mt-1 text-2xl font-bold text-slate-800",children:"-"})]}),e.jsxs("div",{className:"rounded-xl border border-slate-100 bg-white p-5 shadow-sm transition-shadow hover:shadow-md",children:[e.jsx("div",{className:"mb-2 flex items-start justify-between",children:e.jsx("div",{className:"rounded-lg bg-emerald-50 p-2 text-emerald-600",children:e.jsx(ve,{size:20})})}),e.jsx("p",{className:"text-xs font-bold uppercase tracking-wider text-slate-500",children:"Completion Rate"}),e.jsx("h3",{className:"mt-1 text-2xl font-bold text-slate-800",children:"-"})]})]}),e.jsx("div",{className:"mb-6 border-b border-slate-200",children:e.jsx("div",{className:"flex space-x-6",children:["Overview","Job History","Settings"].map(l=>e.jsx("button",{onClick:()=>i(l),className:`border-b-2 px-1 pb-3 text-sm font-medium transition-colors ${f===l?"border-emerald-500 text-emerald-600":"border-transparent text-slate-500 hover:text-slate-800"}`,children:l},l))})}),e.jsxs("div",{className:"duration-200 animate-in fade-in",children:[f==="Overview"&&e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"rounded-xl border border-slate-100 bg-slate-50 p-6",children:[e.jsx("h4",{className:"mb-4 text-sm font-bold text-slate-800",children:"User Information"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-xs text-slate-500",children:"Full Name"}),e.jsx("p",{className:"text-sm font-medium text-slate-800",children:P})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-xs text-slate-500",children:"Email"}),e.jsx("p",{className:"text-sm font-medium text-slate-800",children:t.email})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-xs text-slate-500",children:"Department"}),e.jsx("p",{className:"text-sm font-medium text-slate-800",children:t.department||"Not assigned"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-xs text-slate-500",children:"Role"}),e.jsx("p",{className:"text-sm font-medium text-slate-800",children:t.role})]})]})]})}),f==="Job History"&&e.jsxs("div",{className:"py-12 text-center text-slate-500",children:[e.jsx(ee,{size:48,className:"mx-auto mb-4 text-slate-300"}),e.jsx("p",{className:"text-sm",children:"Job history will be available soon."})]}),f==="Settings"&&e.jsxs("div",{className:"max-w-lg space-y-6",children:[e.jsxs("div",{className:"mb-6 rounded-xl border border-slate-100 bg-slate-50 p-6",children:[e.jsxs("h4",{className:"mb-4 flex items-center text-sm font-bold text-slate-800",children:[e.jsx(re,{size:16,className:"mr-2 text-emerald-600"})," ","Profile Picture"]}),e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsx("div",{className:"flex h-20 w-20 shrink-0 items-center justify-center overflow-hidden rounded-full border border-slate-200 bg-white shadow-sm",children:o?e.jsx("img",{src:o,alt:P,className:"h-full w-full object-cover"}):e.jsx(R,{size:32,className:"text-slate-300"})}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("button",{onClick:()=>{var l;return(l=F.current)==null?void 0:l.click()},className:"rounded-lg border border-slate-300 bg-white px-4 py-2 text-xs font-bold text-slate-700 shadow-sm transition hover:bg-slate-50",children:"Change Photo"}),o&&e.jsx("button",{onClick:()=>{h(""),x(null)},className:"text-left text-xs font-bold text-red-500 hover:underline",children:"Remove Photo"}),e.jsx("input",{type:"file",ref:F,className:"hidden",accept:"image/*",onChange:W,"aria-label":"Upload Profile Picture"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-slate-700",children:"First Name"}),e.jsx("input",{type:"text",className:`w-full rounded-lg border p-2.5 text-sm outline-none focus:ring-2 focus:ring-emerald-500 ${b.firstName?"border-red-500":"border-slate-300"}`,value:m.firstName,onChange:l=>{C({...m,firstName:l.target.value}),E("firstName")},"aria-label":"First Name"}),b.firstName&&e.jsx("p",{className:"mt-1 text-xs text-red-500",children:b.firstName})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-slate-700",children:"Last Name"}),e.jsx("input",{type:"text",className:`w-full rounded-lg border p-2.5 text-sm outline-none focus:ring-2 focus:ring-emerald-500 ${b.lastName?"border-red-500":"border-slate-300"}`,value:m.lastName,onChange:l=>{C({...m,lastName:l.target.value}),E("lastName")},"aria-label":"Last Name"}),b.lastName&&e.jsx("p",{className:"mt-1 text-xs text-red-500",children:b.lastName})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-slate-700",children:"Department"}),e.jsx("select",{title:"Select Domain",className:`w-full rounded-lg border bg-white p-2.5 text-sm outline-none focus:ring-2 focus:ring-emerald-500 ${b.department?"border-red-500":"border-slate-300"}`,value:m.department,onChange:l=>{C({...m,department:l.target.value}),E("department")},children:Y.map(l=>e.jsx("option",{value:l,children:l},l))}),b.department&&e.jsx("p",{className:"mt-1 text-xs text-red-500",children:b.department})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx("button",{onClick:q,disabled:u,className:"flex items-center rounded-lg bg-emerald-600 px-6 py-2.5 text-sm font-bold text-white shadow-sm transition-all hover:bg-emerald-700 active:scale-95 disabled:opacity-50",children:u?e.jsxs(e.Fragment,{children:[e.jsx(k,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save Changes"}),e.jsx("button",{className:"rounded-lg border border-slate-300 px-6 py-2.5 text-sm font-medium text-slate-700 transition-colors hover:bg-slate-50",children:"Reset Password"})]}),e.jsxs("div",{className:"mt-6 border-t border-slate-200 pt-6",children:[e.jsx("h4",{className:"mb-2 text-sm font-bold text-red-600",children:"Danger Zone"}),e.jsx("button",{onClick:()=>D(!0),disabled:j,className:"flex items-center rounded-lg border border-red-200 bg-red-50 px-4 py-2 text-sm font-medium text-red-700 hover:bg-red-100 disabled:opacity-50",children:j?e.jsxs(e.Fragment,{children:[e.jsx(k,{size:16,className:"mr-2 animate-spin"}),"Deleting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ge,{size:16,className:"mr-2"})," Deactivate User"]})})]})]})]})]})]})]})}),e.jsx(M,{open:S,onOpenChange:D,children:e.jsxs(O,{children:[e.jsxs(Z,{children:[e.jsx(J,{children:"Are you sure?"}),e.jsxs(_,{children:["This action cannot be undone. This will permanently remove"," ",e.jsx("strong",{children:P})," from your organization and delete all associated data."]})]}),e.jsxs(B,{children:[e.jsx(H,{disabled:j,children:"Cancel"}),e.jsx(G,{onClick:Q,disabled:j,className:"bg-red-600 hover:bg-red-700 focus:ring-red-600",children:j?e.jsxs(e.Fragment,{children:[e.jsx(k,{className:"mr-2 h-4 w-4 animate-spin"}),"Deleting..."]}):"Delete User"})]})]})}),e.jsx(M,{open:N,onOpenChange:w,children:e.jsxs(O,{children:[e.jsxs(Z,{children:[e.jsx(J,{children:"Resend Invitation"}),e.jsxs(_,{children:["This will send a new invitation email to"," ",e.jsx("strong",{children:t.email}
1),". The previous invitation link will remain valid."]})]}),e.jsxs(B,{children:[e.jsx(H,{disabled:g,children:"Cancel"}),e.jsx(G,{onClick:V,disabled:g,className:"bg-emerald-600 hover:bg-emerald-700 focus:ring-emerald-600",children:g?e.jsxs(e.Fragment,{children:[e.jsx(k,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Resend Invitation"})]})]})})]})},Te=[{value:"",label:"All Statuses"},{value:"active",label:"Active"},{value:"pending",label:"Pending"},{value:"inactive",label:"Inactive"}],Qe=()=>{var P,$,l;const{users:t,pagination:d,isLoading:z,filters:p,setSearch:y,setStatus:c,setDepartment:u,setPage:j,deleteUser:g,resendInvitation:F,isDeleting:f,isResending:i}=K(),[S,D]=n.useState(!1),[N,w]=n.useState(null),[m,C]=n.useState("Overview"),[a,x]=n.useState({open:!1,user:null}),[o,h]=n.useState({open:!1,user:null}),[b,A]=n.useState(p.search),W=s=>{s.preventDefault(),y(b)},E=()=>{A(""),y("")},q=async()=>{a.user&&(await g(a.user._id),x({open:!1,user:null}),(N==null?void 0:N._id)===a.user._id&&w(null))},Q=async()=>{o.user&&(await F(o.user.email),h({open:!1,user:null}))},V=s=>s?new Date(s).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}):"N/A",T=()=>{if(!d)return[];const{currentPage:s,totalPages:r}=d,v=[];if(r<=7)for(let I=1;I<=r;I++)v.push(I);else{v.push(1),s>3&&v.push("ellipsis");const I=Math.max(2,s-1),ce=Math.min(r-1,s+1);for(let X=I;X<=ce;X++)v.push(X);s<r-2&&v.push("ellipsis"),v.push(r)}return v};return e.jsxs("div",{className:"relative space-y-8",children:[e.jsxs("div",{className:"flex items-end justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-slate-800",children:"User Management"}),e.jsx("p",{className:"mt-1 text-slate-500",children:"Manage company users and their access"})]}),e.jsxs("button",{onClick:()=>D(!0),className:"flex items-center rounded-lg bg-emerald-600 px-4 py-2 font-medium text-white shadow-sm hover:bg-emerald-700",children:[e.jsx(se,{size:18,className:"mr-2"})," Add User"]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-xl border border-slate-200 bg-white p-6 shadow-sm",children:[e.jsx("p",{className:"text-xs font-semibold uppercase text-slate-500",children:"Total Users"}),e.jsxs("div",{className:"mt-1 flex items-end",children:[e.jsx("h3",{className:"text-3xl font-bold text-slate-800",children:(d==null?void 0:d.total)||0}),e.jsx("span",{className:"mb-1 ml-2 text-xs font-medium text-emerald-600",children:"↗ +5%"})]}),e.jsx("p",{className:"mt-1 text-xs text-slate-400",children:"vs. last month"})]}),e.jsxs("div",{className:"rounded-xl border border-slate-200 bg-white p-6 shadow-sm",children:[e.jsx("p",{className:"text-xs font-semibold uppercase text-slate-500",children:"Total Requests"}),e.jsx("h3",{className:"mt-1 text-3xl font-bold text-slate-800",children:"-"}),e.jsx("p",{className:"mt-1 text-xs text-slate-400",children:"translation jobs"})]}),e.jsxs("div",{className:"rounded-xl border border-slate-200 bg-white p-6 shadow-sm",children:[e.jsx("p",{className:"text-xs font-semibold uppercase text-slate-500",children:"Top User"}),e.jsx("h3",{className:"mt-1 text-2xl font-bold text-slate-800",children:"-"}),e.jsx("p",{className:"mt-1 text-xs text-slate-400",children:"jobs completed"})]})]}),e.jsxs("div",{className:"overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm",children:[e.jsxs("div",{className:"flex gap-4 border-b border-slate-100 bg-white px-6 py-4",children:[e.jsxs("form",{onSubmit:W,className:"relative max-w-md flex-1",children:[e.jsx(we,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx("input",{type:"text",placeholder:"Search by name or email...",value:b,onChange:s=>A(s.target.value),className:"w-full rounded border border-slate-300 px-3 py-2 pl-9 pr-8 text-sm outline-none focus:border-emerald-500"}),b&&e.jsx("button",{type:"button",onClick:E,className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600","aria-label":"Clear search",children:e.jsx(le,{size:14})})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("select",{title:"select domain",value:p.department,onChange:s=>u(s.target.value),className:"rounded border border-slate-300 bg-white px-3 py-2 text-sm outline-none",children:[e.jsx("option",{value:"",children:"All Departments"}),Y.map(s=>e.jsx("option",{value:s,children:s},s))]}),e.jsx("select",{title:"Status",value:p.status,onChange:s=>c(s.target.value),className:"rounded border border-slate-300 bg-white px-3 py-2 text-sm outline-none",children:Te.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))})]}),z?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(k,{className:"h-8 w-8 animate-spin text-emerald-600"})}):t.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-slate-500",children:[e.jsx(R,{size:48,className:"mb-4 text-slate-300"}),e.jsx("p",{className:"text-sm",children:"No users found"}),(p.search||p.status||p.department)&&e.jsx("button",{onClick:()=>{A(""),y(""),c(""),u("")},className:"mt-2 text-xs text-emerald-600 hover:underline",children:"Clear filters"})]}):e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{className:"border-b border-slate-100 bg-white text-xs uppercase text-slate-500",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-4 font-medium",children:e.jsx("input",{type:"checkbox","aria-label":"select all"})}),e.jsx("th",{className:"px-6 py-4 font-medium",children:"User Name"}),e.jsx("th",{className:"px-6 py-4 font-medium",children:"Email"}),e.jsx("th",{className:"px-6 py-4 font-medium",children:"Department"}),e.jsx("th",{className:"px-6 py-4 font-medium",children:"Last Active"}),e.jsx("th",{className:"px-6 py-4 font-medium",children:"Jobs"}),e.jsx("th",{className:"px-6 py-4 font-medium",children:"Status"}),e.jsx("th",{className:"px-6 py-4 text-right font-medium",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-100",children:t.map(s=>e.jsxs("tr",{onClick:()=>{w(s),C("Overview")},className:"cursor-pointer transition-colors hover:bg-slate-50",children:[e.jsx("td",{className:"px-6 py-4",onClick:r=>r.stopPropagation(),children:e.jsx("input",{type:"checkbox","aria-label":"select user"})}),e.jsx("td",{className:"px-6 py-4 font-medium text-slate-800",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center overflow-hidden rounded-full border border-slate-200 bg-slate-100",children:s.avatar?e.jsx("img",{src:s.avatar,alt:`${s.firstName} ${s.lastName}`,className:"h-full w-full object-cover"}):e.jsx(R,{size:14,className:"text-slate-400"})}),s.firstName," ",s.lastName]})}),e.jsx("td",{className:"px-6 py-4 text-slate-600",children:s.email}),e.jsx("td",{className:"px-6 py-4 text-slate-600",children:s.department||"-"}),e.jsx("td",{className:"px-6 py-4 text-slate-600",children:V(s.lastActive)}),e.jsx("td",{className:"px-6 py-4 text-slate-600",children:"-"}),e.jsx("td",{className:"px-6 py-4",children:e.jsx("span",{className:`rounded px-2 py-1 text-[10px] font-bold uppercase ${s.status==="active"?"bg-emerald-600 text-white":s.status==="pending"?"bg-amber-500 text-white":"bg-slate-200 text-slate-600"}`,children:s.status||"Active"})}),e.jsx("td",{className:"px-6 py-4 text-right",onClick:r=>r.stopPropagation(),children:e.jsxs("div",{className:"flex items-center justify-end space-x-2 text-slate-400",children:[s.status==="pending"&&e.jsx("button",{onClick:()=>h({open:!0,user:s}),className:"rounded border p-1 hover:text-amber-600",title:"Resend Invitation",children:e.jsx(ae,{size:14})}),e.jsx("button",{onClick:()=>{w(s),C("Settings")},className:"rounded border p-1 hover:text-emerald-600",title:"Edit User",children:e.jsx(ze,{size:14})}),e.jsx("button",{onClick:()=>x({open:!0,user:s}),className:"p-1 hover:text-red-600",title:"Delete User",children:e.jsx(Fe,{size:14})})]})})]},s._id))})]}),d&&d.totalPages>1&&e.jsx("div",{className:"border-t border-slate-100 px-6 py-4",children:e.jsx(ye,{children:e.jsxs(Ce,{children:[e.jsx(L,{children:e.jsx(ke,{onClick:()=>
1d.hasPrev&&j(p.page-1),className:d.hasPrev?"cursor-pointer":"pointer-events-none opacity-50"})}),T().map((s,r)=>s==="ellipsis"?e.jsx(L,{children:e.jsx(Se,{})},`ellipsis-${r}`):e.jsx(L,{children:e.jsx(De,{onClick:()=>j(s),isActive:s===d.currentPage,className:"cursor-pointer",children:s})},s)),e.jsx(L,{children:e.jsx(Ae,{onClick:()=>d.hasNext&&j(p.page+1),className:d.hasNext?"cursor-pointer":"pointer-events-none opacity-50"})})]})})})]}),e.jsx(Re,{isOpen:S,onClose:()=>D(!1)}),e.jsx(Ie,{user:N,onClose:()=>w(null),initialTab:m}),e.jsx(M,{open:a.open,onOpenChange:s=>!s&&x({open:!1,user:null}),children:e.jsxs(O,{children:[e.jsxs(Z,{children:[e.jsx(J,{children:"Delete User"}),e.jsxs(_,{children:["Are you sure you want to remove"," ",e.jsxs("strong",{children:[(P=a.user)==null?void 0:P.firstName," ",($=a.user)==null?void 0:$.lastName]}),"? This action cannot be undone."]})]}),e.jsxs(B,{children:[e.jsx(H,{disabled:f,children:"Cancel"}),e.jsx(G,{onClick:q,disabled:f,className:"bg-red-600 hover:bg-red-700 focus:ring-red-600",children:f?e.jsxs(e.Fragment,{children:[e.jsx(k,{className:"mr-2 h-4 w-4 animate-spin"}),"Deleting..."]}):"Delete"})]})]})}),e.jsx(M,{open:o.open,onOpenChange:s=>!s&&h({open:!1,user:null}),children:e.jsxs(O,{children:[e.jsxs(Z,{children:[e.jsx(J,{children:"Resend Invitation"}),e.jsxs(_,{children:["Send a new invitation email to"," ",e.jsx("strong",{children:(l=o.user)==null?void 0:l.email}),"?"]})]}),e.jsxs(B,{children:[e.jsx(H,{disabled:i,children:"Cancel"}),e.jsx(G,{onClick:Q,disabled:i,className:"bg-emerald-600 hover:bg-emerald-700 focus:ring-emerald-600",children:i?e.jsxs(e.Fragment,{children:[e.jsx(k,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Invitation"})]})]})})]})};export{Qe as UserManagement};

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.