PageSourceSearch

https://portal.heyfilo.ai/assets/TeamManagementPage-CXKTdtua.js

js heyfilo.ai collected 2026-10-05 14:28:39 UTC 16,828 bytes, 16 lines download raw bytes

1import{ag as A,A as ue,d as xe,r as l,i as X,g as Z,k as M,j as e,P as ee,B as N,I as he,U as be,az as pe,J as se,aA as fe,N as I,T as te,z as m,aB as w,X as le}from"./index-BIdkve2-.js";import{C as ae}from"./ConfirmDialog-WSQPel74.js";import"./triangle-alert-YYr4p_EE.js";/**
2 * @license lucide-react v0.400.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 ve=A("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/**
7 * @license lucide-react v0.400.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 ye=A("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);/**
12 * @license lucide-react v0.400.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const ge=A("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]),E={workflows:"Workflow",content:"Content",guidelines:"Guideline",publishing:"Publishing",scheduling:"Schedule",ideation:"Ideas",integrations:"Integrations",dashboard:"Dashboard"},ie={dashboard:!1,content:!1,workflows:!1,scheduling:!1,publishing:!1,ideation:!1,guidelines:!1,integrations:!1,team_management:!1};function je({inviteUrl:n,onClose:t}){const d=()=>{navigator.clipboard.writeText(n),m.success("Invite link copied!")};return e.jsx("div",{className:"fixed inset-0 z-50 bg-black/40 overflow-y-auto",role:"presentation",onClick:t,children:e.jsx("div",{className:"min-h-full flex items-start sm:items-center justify-center p-0 sm:p-4",onClick:u=>u.stopPropagation(),children:e.jsxs("div",{className:"bg-white w-full max-h-[100dvh] sm:max-h-[calc(100vh-2rem)] sm:max-w-md overflow-hidden flex flex-col rounded-none sm:rounded-2xl border-0 sm:border sm:border-claude-border shadow-none sm:shadow-dropdown p-4 sm:p-6",children:[e.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between mb-4 bg-white/85 backdrop-blur-md py-2",children:[e.jsx("h3",{className:"font-semibold text-claude-text",children:"Invitation Sent"}),e.jsx("button",{onClick:t,className:"p-2 rounded-lg text-claude-text-tertiary hover:text-claude-text hover:bg-claude-bg-alt","aria-label":"Close",children:e.jsx(le,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"text-sm text-claude-text-secondary mb-3",children:"Share this invite link with the recipient:"}),e.jsxs("div",{className:"flex items-center gap-2 bg-claude-bg-alt rounded-xl border border-claude-border px-3 py-2 mb-4",children:[e.jsx("span",{className:"text-xs text-claude-text truncate flex-1",children:n}),e.jsx("button",{onClick:d,className:"text-claude-accent hover:text-claude-accent-hover flex-shrink-0",children:e.jsx(ve,{className:"h-4 w-4"})})]}),e.jsx(N,{className:"w-full",size:"sm",onClick:d,children:"Copy invite link"})]})})})}function we(n){return n.map(t=>({module:t,can_view:!0,can_create:!0,can_edit:!0,can_delete:!0,can_approve:!0}))}function Ne({member:n,permissions:t,setPermissions:d,onClose:u,onSave:b,isSaving:o}){var p;return e.jsx("div",{className:"fixed inset-0 z-50 bg-black/40 overflow-y-auto",role:"presentation",onClick:u,children:e.jsx("div",{className:"min-h-full flex items-start sm:items-center justify-center p-0 sm:p-4",onClick:r=>r.stopPropagation(),children:e.jsxs("div",{className:"bg-white w-full max-h-[100dvh] sm:max-h-[calc(100vh-2rem)] sm:max-w-lg overflow-hidden flex flex-col rounded-none sm:rounded-2xl border-0 sm:border sm:border-claude-border shadow-none sm:shadow-dropdown p-4 sm:p-6",children:[e.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between mb-4 bg-white/85 backdrop-blur-md py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"font-semibold text-claude-text",children:"Edit permissions"}),e.jsx("p",{className:"text-xs text-claude-text-tertiary truncate",children:(p=n.user)==null?void 0:p.email})]}),e.jsx("button",{onClick:u,className:"p-2 rounded-lg text-claude-text-tertiary hover:text-claude-text hover:bg-claude-bg-alt","aria-label":"Close",children:e.jsx(le,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"text-xs font-semibold text-claude-text-secondary mb-3",children:"Module Permissions (full access for selected modules)"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(E).map(([r,v])=>e.jsxs("label",{className:"flex items-center gap-3 border border-claude-border rounded-xl p-3 cursor-pointer hover:bg-claude-bg-alt transition-colors",children:[e.jsx("input",{type:"checkbox",checked:t[r]||!1,onChange:x=>d({...t,[r]:x.target.checked}),className:"rounded border-claude-border text-claude-accent focus:ring-primary-200 h-4 w-4"}),e.jsx("span",{className:"text-sm text-claude-text font-medium",children:v})]},r))}),e.jsxs("div",{className:"mt-6 flex flex-col sm:flex-row gap-2",children:[e.jsx(N,{type:"button",variant:"secondary",className:"w-full",onClick:u,disabled:o,children:"Cancel"}),e.jsx(N,{type:"button",className:"w-full",onClick:b,disabled:o,children:o?"Saving…":"Save permissions"})]})]})})})}function Me(){var J;
16const n=ue(),{user:t,isReadOnlyTenant:d}=xe(),[u,b]=l.useState(!1),[o,p]=l.useState(null),[r,v]=l.useState(null),[x,L]=l.useState(""),[ne,re]=l.useState(!1),[k,q]=l.useState(""),[h,_]=l.useState(null),[F,D]=l.useState(!1),[T,O]=l.useState(null),z=l.useRef(),[C,P]=l.useState(null),[R,K]=l.useState({}),[S,Q]=l.useState({...ie}),U=()=>{L(""),re(!1),q(""),_(null),Q({...ie})},ce=Object.values(S).some(s=>s);l.useEffect(()=>{if(!x||!x.includes("@")){_(null);return}clearTimeout(z.current),D(!0),z.current=setTimeout(async()=>{try{const{data:s}=await X.validateEmail(x);_(s)}catch{_(null)}finally{D(!1)}},500)},[x]);const{data:f,isLoading:B}=Z({queryKey:["team-members"],queryFn:async()=>(await w.listMembers()).data,refetchOnMount:"always"}),{data:y}=Z({queryKey:["pending-invitations-tenant"],queryFn:async()=>(await w.listInvitations()).data,refetchOnMount:"always"}),$=M({mutationFn:s=>X.revoke(s),onSuccess:()=>{m.success("Invitation revoked"),n.invalidateQueries({queryKey:["pending-invitations-tenant"]})},onError:()=>m.error("Failed to revoke invitation"),onSettled:()=>v(null)}),Y=M({mutationFn:async()=>{const s=Object.entries(S).filter(([i,a])=>a).map(([i])=>({module:i,can_view:!0,can_create:!0,can_edit:!0,can_delete:!0,can_approve:!0}));return(await w.invite({email:x,is_admin:ne,module_permissions:s,access_duration:k||void 0})).data},onSuccess:s=>{U(),n.invalidateQueries({queryKey:["pending-invitations-tenant"]}),(s==null?void 0:s.status)==="added"?(m.success("Member added successfully"),n.invalidateQueries({queryKey:["team-members"]}),b(!1)):s!=null&&s.invite_url?(O(s.invite_url),b(!1)):(m.success("Invitation sent"),n.invalidateQueries({queryKey:["team-members"]}),b(!1))},onError:s=>{var i,a,c,g,j;return m.error(((c=(a=(i=s.response)==null?void 0:i.data)==null?void 0:a.email)==null?void 0:c[0])||((j=(g=s.response)==null?void 0:g.data)==null?void 0:j.detail)||"Failed to send invitation")}}),H=M({mutationFn:s=>w.removeMember(s),onSuccess:()=>{m.success("Member removed"),n.invalidateQueries({queryKey:["team-members"]})},onError:()=>m.error("Failed to remove member"),onSettled:()=>p(null)}),V=M({mutationFn:async s=>{const i=Object.entries(s.permissions).filter(([a,c])=>c).map(([a])=>a);return w.updateMemberPermissions(s.memberId,we(i))},onSuccess:()=>{m.success("Permissions updated"),n.invalidateQueries({queryKey:["team-members"]}),P(null)},onError:()=>m.error("Failed to update permissions")}),de=B,W=Array.isArray(f)?f:(f==null?void 0:f.results)||[],G=Array.isArray(y)?y:(y==null?void 0:y.results)||[];if(B&&!f)return e.jsx(ee,{});const oe=!!(t!=null&&t.is_admin||t!=null&&t.is_superuser),me=s=>{const i=new Set((s.module_permissions||[]).map(c=>c.module)),a={};
16Object.keys(E).forEach(c=>{a[c]=i.has(c)}),K(a),P(s)};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between mb-6",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-2xl font-semibold text-claude-text tracking-tight",children:"Team"}),e.jsx("p",{className:"text-sm text-claude-text-tertiary mt-1",children:"Manage workspace members"})]}),!d&&e.jsxs(N,{onClick:()=>{u&&U(),b(!u)},className:"w-full sm:w-auto",children:[e.jsx(ge,{className:"h-4 w-4"})," Invite Member"]})]}),!d&&u&&e.jsxs("div",{className:"bg-claude-surface rounded-2xl border border-claude-border shadow-soft p-6 mb-6",children:[e.jsx("h3",{className:"font-medium text-claude-text mb-4",children:"Invite to workspace"}),e.jsx("div",{className:"flex flex-col md:flex-row md:flex-wrap gap-4 items-stretch md:items-end",children:e.jsxs("div",{className:"flex-1 min-w-0 md:min-w-[200px]",children:[e.jsx(he,{id:"invite-email",label:"Email Address",type:"email",value:x,onChange:s=>L(s.target.value),placeholder:"[email protected]"}),F&&e.jsx("p",{className:"mt-1.5 text-xs text-claude-text-tertiary",children:"Checking email..."}),!F&&h&&e.jsx("p",{className:`mt-1.5 text-xs ${h.already_member?"text-claude-danger":"text-claude-text-tertiary"}`,children:h.already_member?"This person is already a member of this workspace.":h.exists?"User found — they will be added or notified of their new access.":"New user — an invite link will be generated."})]})}),e.jsxs("div",{className:"mt-6 border-t border-claude-border pt-6",children:[e.jsx("p",{className:"text-xs font-semibold text-claude-text-secondary mb-3",children:"Module Permissions (full access for selected modules)"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3 mb-6",children:Object.entries(E).map(([s,i])=>e.jsxs("label",{className:"flex items-center gap-3 border border-claude-border rounded-xl p-3 cursor-pointer hover:bg-claude-bg-alt transition-colors",children:[e.jsx("input",{type:"checkbox",checked:S[s]||!1,onChange:a=>Q({...S,[s]:a.target.checked}),className:"rounded border-claude-border text-claude-accent focus:ring-primary-200 h-4 w-4"}),e.jsx("span",{className:"text-sm text-claude-text font-medium",children:i})]},s))}),e.jsxs("div",{className:"mb-6",children:[e.jsx("p",{className:"text-xs font-semibold text-claude-text-secondary mb-3",children:"Access Duration"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:[{value:"",label:"No limit"},{value:"1_day",label:"1 Day"},{value:"1_week",label:"1 Week"},{value:"1_month",label:"1 Month"},{value:"1_year",label:"1 Year"}].map(s=>e.jsx("button",{type:"button",onClick:()=>q(s.value),className:`px-3 py-1.5 text-xs font-medium rounded-lg border transition-colors ${k===s.value?"border-claude-accent bg-claude-accent/10 text-claude-accent":"border-claude-border text-claude-text-secondary hover:bg-claude-bg-alt"}`,children:s.label},s.value))}),k&&e.jsxs("p",{className:"text-xs text-claude-text-tertiary mt-2",children:["Access will automatically expire after ",k.replace("_"," "),"."]})]}),e.jsxs("div",{className:"flex flex-col items-start gap-2",children:[e.jsx(N,{onClick:()=>Y.mutate(),disabled:!x||Y.isPending||(h==null?void 0:h.already_member)||!ce,className:"w-full sm:w-auto",children:"Send Invite"}),e.jsx("p",{className:"text-xs text-claude-text-tertiary",children:"Select at least one module."})]})]})]}),e.jsx("div",{className:"bg-claude-surface rounded-2xl border border-claude-border shadow-soft overflow-hidden",children:de?e.jsx("div",{className:"py-16",children:e.jsx(ee,{})}):W.length===0?e.jsxs("div",{className:"flex flex-col items-center py-16",children:[e.jsx("div",{className:"h-12 w-12 rounded-2xl bg-claude-bg-alt flex items-center justify-center mb-3",children:e.jsx(be,{className:"h-5 w-5 text-claude-text-tertiary"})}),e.jsx("p",{className:"text-sm text-claude-text-secondary font-medium",children:"No members yet"})]}):e.jsx("div",{className:"divide-y divide-claude-border/50",children:W.map(s=>{var i,a,c,g,j;return e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between px-4 sm:px-6 py-4 hover:bg-claude-surface-hover transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-9 w-9 rounded-full bg-claude-accent-light text-claude-accent-text flex items-center justify-center text-xs font-semibold",children:s.user&&pe(`${s.user.first_name||""} ${s.user.last_name||""}`.trim()||s.user.email||"?")}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-medium text-claude-text",children:[(i=s.user)==null?void 0:i.first_name," ",(a=s.user)==null?void 0:a.last_name]}),e.jsx("p",{className:"text-xs text-claude-text-tertiary",children:(c=s.user)==null?void 0:c.email})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 justify-between sm:justify-end",children:[s.is_admin&&e.jsxs(se,{className:"bg-purple-50 text-purple-700",children:[e.jsx(fe,{className:"h-3 w-3 mr-1"})," Admin"]}),e.jsxs("span",{className:"text-xs text-claude-text-tertiary",children:[((g=s.module_permissions)==null?void 0:g.length)||0," modules"]}),s.access_expires_at&&e.jsx("span",{className:`text-xs ${new Date(s.access_expires_at)<new Date?"text-red-500":"text-amber-600"}`,children:new Date(s.access_expires_at)<new Date?"Expired":`Expires ${I(s.access_expires_at)}`}),e.jsx("span",{className:"text-xs text-claude-text-tertiary",children:I(s.created_at)}),!d&&oe&&!s.is_admin&&e.jsx("button",{onClick:()=>me(s),className:"p-1.5 rounded-lg hover:bg-claude-bg-alt transition-colors text-claude-text-tertiary hover:text-claude-text","aria-label":"Edit permissions",title:"Edit permissions",children:e.jsx(ye,{className:"h-3.5 w-3.5"})}
16),!d&&((j=s.user)==null?void 0:j.id)!==(t==null?void 0:t.id)&&e.jsx("button",{onClick:()=>p(s),className:"p-1.5 rounded-lg hover:bg-red-50 transition-colors text-claude-text-tertiary hover:text-red-600",children:e.jsx(te,{className:"h-3.5 w-3.5"})})]})]},s.id)})})}),G.length>0&&e.jsxs("div",{className:"mt-6",children:[e.jsx("h3",{className:"text-sm font-semibold text-claude-text mb-3",children:"Pending Invitations"}),e.jsx("div",{className:"bg-claude-surface rounded-2xl border border-claude-border shadow-soft overflow-hidden",children:e.jsx("div",{className:"divide-y divide-claude-border/50",children:G.map(s=>e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 hover:bg-claude-surface-hover transition-colors",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-claude-text",children:s.email}),e.jsxs("p",{className:"text-xs text-claude-text-tertiary mt-0.5",children:["Role: ",e.jsx("span",{children:s.is_admin?"Admin":"Member"})," · Sent ",I(s.created_at)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(se,{className:"bg-claude-warning-light text-claude-warning",children:"Pending"}),!d&&e.jsx("button",{onClick:()=>v({id:s.id,email:s.email}),className:"p-1.5 rounded-lg hover:bg-red-50 transition-colors text-claude-text-tertiary hover:text-red-600",children:e.jsx(te,{className:"h-3.5 w-3.5"})})]})]},s.id))})})]}),T&&e.jsx(je,{inviteUrl:T,onClose:()=>O(null)}),C&&e.jsx(Ne,{member:C,permissions:R,setPermissions:K,onClose:()=>P(null),onSave:()=>V.mutate({memberId:C.id,permissions:R}),isSaving:V.isPending}),e.jsx(ae,{open:o!==null,title:"Remove this member?",description:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium text-claude-text",children:(J=o==null?void 0:o.user)==null?void 0:J.email})," ","will lose access to this workspace and everything in it. You can invite them again later."]}),confirmLabel:"Remove member",isLoading:H.isPending,onConfirm:()=>o&&H.mutate(o.id),onCancel:()=>p(null)}),e.jsx(ae,{open:r!==null,title:"Revoke this invitation?",description:e.jsxs(e.Fragment,{children:["The invite link sent to"," ",e.jsx("span",{className:"font-medium text-claude-text",children:r==null?void 0:r.email})," will stop working. You can send a new invitation at any time."]}),confirmLabel:"Revoke invitation",isLoading:$.isPending,onConfirm:()=>r&&$.mutate(r.id),onCancel:()=>v(null)})]})}export{Me as TeamManagementPage};

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.