PageSourceSearch

https://yopla.base44.app/assets/UsersView-CgSh1XZq.js

js yopla.base44.app collected 2026-10-03 03:12:44 UTC 24,618 bytes, 6 lines download raw bytes

1import{t as pe,j as e,v as he,B as ne,a as N,az as _e,aV as ue,bW as re,aB as oe,ci as fe,o as je,am as be,an as ge,ao as ve,ap as Ne,aE as ke,ai as P,aq as ye,x as Ce,X as le,ar as we,a9 as se,i as ie,h as k,aw as K,y as Se,d as R}from"./index-DD9WYyJa.js";import{S as Ue}from"./ShellPage-pg-Dmr9R.js";import{S as Le}from"./ShellSection-CPf233FT.js";import{S as Y,a as J,b as z,c as G,d as q}from"./select-DYyMw9Ju.js";import{S as ce}from"./shield-DszDm0Rf.js";import{B as te}from"./badge-C-fR5zPV.js";import{H as Te}from"./HubSpotLink-BcIfmKCZ.js";import{S as A}from"./switch-nw8lyil0.js";import{C as Fe}from"./checkbox-Dd1KF2mu.js";import{U as We}from"./upload-CLc5GWNb.js";import{G as Ee}from"./grip-vertical-Df1rnxI_.js";import{S as Ie}from"./send-59E7nAmg.js";import"./ShellPageHeader-gjT95Y6w.js";import"./spacing-EL3ObQ_o.js";import"./index-BdQq_4o_.js";import"./index-3OJTDDTr.js";import"./index-pe0Q6-Ri.js";import"./index-FP_YzgxR.js";import"./chevron-up-BvRSDkdc.js";/**
2 * @license lucide-react v0.475.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 Pe=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],qe=pe("Cloud",Pe);function De({teamCount:n,clientCount:t,workspaceCount:i}){const _=[{icon:ce,label:"team",count:n},{icon:he,label:"clients",count:t},{icon:ne,label:"workspaces",count:i}];return e.jsx("div",{className:"flex items-center gap-6 text-sm text-stone-500",children:_.map(({icon:p,label:u,count:f})=>e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(p,{className:"w-3.5 h-3.5 text-stone-400"}),e.jsx("span",{className:"font-medium text-stone-900",children:f}),e.jsx("span",{children:u})]},u))})}const ae={admin:"bg-amber-50 text-amber-800 border border-amber-200",user:"bg-stone-50 text-stone-700 border border-stone-200"};function Be({user:n,profile:t,workspaceCount:i,workspaceNames:_,onEditProfile:p,displayName:u}){var L;const[f,r]=N.useState(!1),h=n._fromHubSpot,b=(t==null?void 0:t.proposal_title)&&(t==null?void 0:t.proposal_bio_short),v=(t==null?void 0:t.first_name)&&(t==null?void 0:t.last_name),g=ae[n.role]||ae.user,F=h?e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-stone-300 flex-shrink-0",title:"In HubSpot — no profile yet"}):!h&&(!v||!b)?e.jsx(oe,{className:"w-3.5 h-3.5 text-amber-500 flex-shrink-0"}):e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 flex-shrink-0",title:"Profile complete"}),W=h?n._hubspotJobTitle||"HubSpot only — click to set up profile":(t==null?void 0:t.proposal_title)||"";return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:`flex items-center justify-between p-4 cursor-pointer hover:bg-stone-50 transition-colors ${h?"opacity-70 hover:opacity-100":""}`,onClick:()=>p(n),children:[e.jsxs("div",{className:"flex items-center gap-4 min-w-0 flex-1",children:[e.jsx("div",{className:`w-9 h-9 rounded-full flex items-center justify-center flex-shrink-0 ${h?"bg-stone-50 border border-dashed border-stone-300":"bg-stone-100"}`,children:e.jsx("span",{className:`text-sm font-medium ${h?"text-stone-400":"text-stone-600"}`,children:(L=(u||"?")[0])==null?void 0:L.toUpperCase()})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:`font-medium truncate ${h?"text-stone-600":"text-stone-900"}`,children:u||e.jsx("span",{className:"text-stone-400 italic",children:"No name"})}),F]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-stone-500",children:[e.jsx("span",{className:"truncate",children:n.email}),W&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-stone-300",children:"·"}),e.jsx("span",{className:"text-stone-400 truncate",children:W})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",onClick:y=>y.stopPropagation(),children:[i>0&&e.jsxs("button",{onClick:y=>{y.stopPropagation(),r(!f)},className:"flex items-center gap-1 px-2 py-1 rounded-md text-xs text-stone-500 hover:bg-stone-100 transition-colors",title:`${i} workspace${i!==1?"s":""}`,children:[e.jsx(ne,{className:"w-3 h-3"}),i,f?e.jsx(_e,{className:"w-3 h-3"}):e.jsx(ue,{className:"w-3 h-3"})]}),h?e.jsxs(te,{className:"bg-stone-50 text-stone-400 border border-stone-200",children:[e.jsx(qe,{className:"w-3 h-3 mr-1"}),"HubSpot"]}):e.jsxs(te,{className:g,children:[n.role==="admin"?e.jsx(ce,{className:"w-3 h-3 mr-1"}):e.jsx(re,{className:"w-3 h-3 mr-1"}),n.role==="admin"?"Admin":"User"]})]})]}),f&&_.length>0&&e.jsx("div",{className:"px-4 pb-3 pl-[68px]",children:e.jsx("div",{className:"flex flex-wrap gap-1.5",children:_.map((y,D)=>e.jsx("span",{className:"text-xs text-stone-500 bg-stone-50 px-2 py-0.5 rounded",children:y},D))})})]})}function He({client:n}){var _,p;const t=fe(n),i=t&&t.toLowerCase()!==((_=n.email)==null?void 0:_.toLowerCase());return e.jsxs("div",{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-4 min-w-0 flex-1",children:[e.jsx("div",{className:"w-9 h-9 rounded-full bg-blue-50 flex items-center justify-center flex-shrink-0",children:e.jsx("span",{className:"text-sm font-medium text-blue-600",children:(p=(i?t:n.email)[0])==null?void 0:p.toUpperCase()})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium text-stone-900 truncate",children:i?t:e.jsx("span",{className:"text-stone-400 italic",children:"No name"})}),n.hubspot_contact_id&&e.jsx(Te,{hubspotId:n.hubspot_contact_id})]}),e.jsx("p",{className:"text-sm text-stone-500 truncate",children:n.email})]})]}),e.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-4",children:e.jsx("div",{className:"flex flex-wrap gap-1.5 justify-end max-w-xs",children:n.workspaces.map(u=>e.jsx("span",{className:"text-xs text-stone-600 bg-stone-50 px-2 py-0.5 rounded font-medium",children:u.name},u.id))})})]})}function Me({user:n,profile:t,displayName:i,onClose:_}){var H,$,C,E,I,B,M,O;const p=je(),[u,f]=N.useState(!1),[r,h]=N.useState({}),[b,v]=N.useState(!1),g=n==null?void 0:n._fromHubSpot;N.useEffect(()=>{n&&(h({first_name:(t==null?void 0:t.first_name)||(g?n.first_name:"")||(i==null?void 0:i.split(" ")[0])||"",last_name:(t==null?void 0:t.last_name)||(g?n.last_name:"")||(i==null?void 0:i.split(" ").slice(1).join(" "))||"",proposal_display_name:(t==null?void 0:t.proposal_display_name)||i||"",proposal_title:(t==null?void 0:t.proposal_title)||(g?n._hubspotJobTitle:"")||"",proposal_bio_short:(t==null?void 0:t.proposal_bio_short)||"",proposal_visibility:(t==null?void 0:t.proposal_visibility)!==!1,proposal_sort_order:(t==null?void 0:t.proposal_sort_order)||0,role:n.role||"user",feedback_enabled:!!n.feedback_enabled,is_founder:!!(t!=null&&t.is_founder),founder_photo_url:(t==null?void 0:t.founder_photo_url)||"",founder_track_record:(t==null?void 0:t.founder_track_record)||[]}),v(!1))},[n==null?void 0:n.id,t==null?void 0:t.id]);const j=(a,o)=>h(c=>({...c,[a]:o})),F=((H=r.first_name)==null?void 0:H.trim())&&(($=r.last_name)==null?void 0:$.trim())&&((C=r.proposal_title)==null?void 0:C.trim())&&((E=r.proposal_bio_short)==null?void 0:E.trim()),W=async a=>{var d;const o=(d=a.target.files)==null?void 0:d[0];if(!o)return;const{file_url:c}=await k.integrations.Core.UploadFile({file:o});j("founder_photo_url",c)},L=()=>{h(a=>({...a,founder_track_record:[...a.founder_track_record||[],""]}))},y=(a,o)=>{h(c=>{const d=[...c.founder_track_record||[]];return d[a]=o,{...c,founder_track_record:d}})},D=a=>{h(o=>({...o,founder_track_record:(o.founder_track_record||[]).filter((c,d)=>d!==a)}))},X=async()=>{var U;if(!n||!F)return;f(!0);const a=(U=n.email)==null?void 0:U.toLowerCase();if(!n._fromWorkspaceUser&&!g){const x={};n.role!==r.role&&(x.role=r.role),!!n.feedback_enabled!==r.feedback_enabled&&(x.feedback_enabled=r.feedback_enabled),Object.keys(x).length>0&&(await k.entities.User.update(n.id,x),x.feedback_enabled!==void 0&&window.dispatchEvent(new Event("feedback-setting-changed")))}
6const c=(await k.entities.WorkspaceUser.filter({user_email:a,status:"active"})).filter(x=>x.is_yopla_team),d={proposal_display_name:r.proposal_display_name,proposal_title:r.proposal_title,proposal_bio_short:r.proposal_bio_short,proposal_visibility:r.proposal_visibility,proposal_sort_order:r.proposal_sort_order,first_name:r.first_name,last_name:r.last_name,is_founder:r.is_founder,founder_photo_url:r.founder_photo_url,founder_track_record:r.founder_track_record};if(c.length>0)for(const x of c)await k.entities.WorkspaceUser.update(x.id,d);else await k.entities.WorkspaceUser.create({workspace_id:"global",user_email:a,user_name:[r.first_name,r.last_name].filter(Boolean).join(" "),role:"admin",is_yopla_team:!0,status:"active",...d});if(b&&g)try{await k.users.inviteUser(a,"user"),K.success(`Profile saved & invitation sent to ${a}`)}catch(x){K.success("Profile saved"),K.error(`Invite failed: ${x.message}`)}else K.success("Profile updated");p.invalidateQueries({queryKey:["allWorkspaceUsers"]}),p.invalidateQueries({queryKey:["allPlatformUsers"]}),f(!1),_()};return e.jsx(be,{open:!!n,onOpenChange:a=>!a&&_(),children:e.jsxs(ge,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(ve,{children:[e.jsx(Ne,{className:"text-lg font-medium",children:g?"Set up team profile":"Edit team member"}),e.jsx(ke,{children:n==null?void 0:n.email})]}),e.jsxs("div",{className:"space-y-5 py-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs font-medium text-stone-500 uppercase tracking-wide block mb-1.5",children:["First name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(P,{value:r.first_name||"",onChange:a=>j("first_name",a.target.value),placeholder:"First",className:(I=r.first_name)!=null&&I.trim()?"":"border-amber-300"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs font-medium text-stone-500 uppercase tracking-wide block mb-1.5",children:["Last name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(P,{value:r.last_name||"",onChange:a=>j("last_name",a.target.value),placeholder:"Last",className:(B=r.last_name)!=null&&B.trim()?"":"border-amber-300"})]})]}),!(n!=null&&n._fromWorkspaceUser)&&!g&&e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-stone-500 uppercase tracking-wide block mb-1.5",children:"Platform role"}),e.jsxs(Y,{value:r.role||"user",onValueChange:a=>j("role",a),children:[e.jsx(J,{children:e.jsx(z,{})}),e.jsxs(G,{children:[e.jsx(q,{value:"admin",children:"Admin — Full access"}),e.jsx(q,{value:"user",children:"User — Standard"})]})]})]}),e.jsx("div",{className:"flex items-end pb-1",children:e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(A,{checked:r.feedback_enabled||!1,onCheckedChange:a=>j("feedback_enabled",a)}),e.jsx("span",{className:"text-sm text-stone-600",children:"Feedback"})]})})]}),e.jsx("div",{className:"border-t border-stone-100 pt-4",children:e.jsx("p",{className:"text-xs font-medium text-stone-500 uppercase tracking-wide mb-3",children:"Proposal profile"})}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-stone-500 block mb-1.5",children:"Display name in proposals"}),e.jsx(P,{value:r.proposal_display_name||"",onChange:a=>j("proposal_display_name",a.target.value),placeholder:"e.g. Steph"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs font-medium text-stone-500 block mb-1.5",children:["Client-facing title ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(P,{value:r.proposal_title||"",onChange:a=>j("proposal_title",a.target.value),placeholder:"e.g. Operations and Delivery",className:(M=r.proposal_title)!=null&&M.trim()?"":"border-amber-300"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs font-medium text-stone-500 block mb-1.5",children:["Short bio ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(ye,{value:r.proposal_bio_short||"",onChange:a=>j("proposal_bio_short",a.target.value),placeholder:"1-3 sentences focused on role and responsibility.",className:`h-20 resize-none ${(O=r.proposal_bio_short)!=null&&O.trim()?"":"border-amber-300"}`})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 bg-stone-50 rounded-lg",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-stone-700",children:"Visible in proposals"}),e.jsx("p",{className:"text-xs text-stone-500",children:"Toggle off to hide from all proposals"})]}),e.jsx(A,{checked:r.proposal_visibility,onCheckedChange:a=>j("proposal_visibility",a)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-stone-500 block mb-1.5",children:"Sort order"}),e.jsx(P,{type:"number",value:r.proposal_sort_order,onChange:a=>j("proposal_sort_order",parseInt(a.target.value)||0),className:"w-20"}),e.jsx("p",{className:"text-xs text-stone-400 mt-1",children:"Lower = appears first"})]}),e.jsx("div",{className:"border-t border-stone-100 pt-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs font-medium text-stone-500 uppercase tracking-wide",children:"Founder Profile"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{htmlFor:"is_founder_toggle",className:"text-sm text-stone-600",children:"Founder"}),e.jsx(A,{id:"is_founder_toggle",checked:r.is_founder,onCheckedChange:a=>j("is_founder",a)})]})]})}),r.is_founder&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-stone-500 block mb-1.5",children:"Founder Photo"}),e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"w-32 h-40 rounded-lg overflow-hidden bg-stone-200 shrink-0 border border-stone-200",children:r.foun
6der_photo_url?e.jsx("img",{src:r.founder_photo_url,alt:"",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(re,{className:"w-10 h-10 text-stone-400"})})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"inline-flex items-center gap-2 px-4 py-2 bg-white border border-stone-200 rounded-lg text-sm text-stone-700 hover:bg-stone-50 cursor-pointer transition-colors",children:[e.jsx(We,{className:"w-4 h-4"}),"Upload photo",e.jsx("input",{type:"file",accept:"image/*",onChange:W,className:"hidden"})]}),r.founder_photo_url&&e.jsx("button",{onClick:()=>j("founder_photo_url",""),className:"block text-xs text-stone-400 hover:text-stone-600",children:"Remove photo"})]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("label",{className:"text-xs font-medium text-stone-500",children:"Track record highlights"}),e.jsxs("button",{onClick:L,type:"button",className:"text-xs text-stone-500 hover:text-stone-700 flex items-center gap-1",children:[e.jsx(Ce,{className:"w-3 h-3"})," Add item"]})]}),e.jsx("div",{className:"space-y-2",children:(r.founder_track_record||[]).map((a,o)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ee,{className:"w-4 h-4 text-stone-300 shrink-0 cursor-grab"}),e.jsx(P,{value:a,onChange:c=>y(o,c.target.value),placeholder:"Key achievement or credential",className:"flex-1"}),e.jsx("button",{onClick:()=>D(o),type:"button",className:"text-stone-400 hover:text-red-500 shrink-0",children:e.jsx(le,{className:"w-4 h-4"})})]},o))})]})]}),g&&e.jsxs("label",{className:"flex items-center gap-3 p-3 rounded-lg border border-stone-200 hover:border-stone-300 cursor-pointer transition-colors",children:[e.jsx(Fe,{checked:b,onCheckedChange:v}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ie,{className:"w-3.5 h-3.5 text-stone-500"}),e.jsx("span",{className:"text-sm font-medium text-stone-700",children:"Send platform invitation"})]}),e.jsx("p",{className:"text-xs text-stone-400 mt-0.5",children:"Invite this person to log in to the Yopla platform"})]})]}),!F&&e.jsxs("div",{className:"flex items-center gap-2 text-amber-700 bg-amber-50 border border-amber-200 rounded-lg p-3 text-sm",children:[e.jsx(oe,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{children:"First name, last name, title and bio are all required."})]})]}),e.jsxs(we,{children:[e.jsx(se,{variant:"outline",onClick:_,children:"Cancel"}),e.jsxs(se,{onClick:X,disabled:u||!F,children:[u&&e.jsx(ie,{className:"w-4 h-4 animate-spin mr-2"}),"Save"]})]})]})})}function Q(n,t){var i;return(i=n.data)!=null&&i.first_name?[n.data.first_name,n.data.last_name].filter(Boolean).join(" "):n.first_name?[n.first_name,n.last_name].filter(Boolean).join(" "):t!=null&&t.first_name?[t.first_name,t.last_name].filter(Boolean).join(" "):t!=null&&t.proposal_display_name?t.proposal_display_name:n.full_name||""}function Oe(){const{data:n=[],isLoading:t}=R({queryKey:["allPlatformUsers"],queryFn:()=>k.entities.User.list("-created_date")}),{data:i=[],isLoading:_}=R({queryKey:["allWorkspaceUsers"],queryFn:()=>k.entities.WorkspaceUser.filter({status:"active"})}),{data:p=[]}=R({queryKey:["allWorkspacesForUsers"],queryFn:()=>k.entities.ClientWorkspace.filter({status:"active"})}),{data:u=[]}=R({queryKey:["allCompaniesForUsers"],queryFn:()=>k.entities.ClientCompany.list()}),{data:f,isLoading:r}=R({queryKey:["hubspotYoplaTeam"],queryFn:async()=>{var b;return((b=(await k.functions.invoke("listYoplaTeamHubspot",{})).data)==null?void 0:b.contacts)||[]},staleTime:300*1e3});return{allPlatformUsers:n,allWorkspaceUsers:i,workspaces:p,companies:u,hubspotTeam:f||[],isLoading:t||_||r}}function Re(){var O;const[n,t]=N.useState(""),[i,_]=N.useState("all"),[p,u]=N.useState("all"),[f,r]=N.useState(null),{allPlatformUsers:h,allWorkspaceUsers:b,workspaces:v,companies:g,hubspotTeam:j,isLoading:F}=Oe(),{teamUsers:W,profileIndex:L,teamWorkspaceIndex:y,clientUsers:D,wsMap:X,companyMap:H}=N.useMemo(()=>{const a=Object.fromEntries(v.map(s=>[s.id,s])),o=Object.fromEntries(g.map(s=>[s.id,s])),c={};b.forEach(s=>{var S,T,Z,ee;const l=(S=s.user_email)==null?void 0:S.toLowerCase();if(!l||!s.is_yopla_team)return;const m=c[l];m?s.workspace_id==="global"?c[l]={...s,is_founder:s.is_founder||m.is_founder,founder_photo_url:s.founder_photo_url||m.founder_photo_url,founder_track_record:(T
6=s.founder_track_record)!=null&&T.length?s.founder_track_record:m.founder_track_record}:(s.is_founder&&!m.is_founder&&(c[l].is_founder=!0),s.founder_photo_url&&!m.founder_photo_url&&(c[l].founder_photo_url=s.founder_photo_url),(Z=s.founder_track_record)!=null&&Z.length&&!((ee=m.founder_track_record)!=null&&ee.length)&&(c[l].founder_track_record=s.founder_track_record),s.proposal_bio_short&&!m.proposal_bio_short&&(c[l].proposal_bio_short=s.proposal_bio_short)):c[l]={...s}});const d={};b.forEach(s=>{var T;if(!s.is_yopla_team||s.workspace_id==="global")return;const l=(T=s.user_email)==null?void 0:T.toLowerCase();if(!l)return;d[l]||(d[l]=[]);const m=a[s.workspace_id],S=m?o[m.client_company_id]:null;d[l].push({id:s.workspace_id,name:(S==null?void 0:S.name)||(m==null?void 0:m.title)||"Unknown"})});const U=h.filter(s=>{var l;return s.role==="admin"||((l=s.email)==null?void 0:l.toLowerCase().endsWith("@yopla.co.uk"))}),x=new Set(U.map(s=>{var l;return(l=s.email)==null?void 0:l.toLowerCase()})),V=new Set(x),de=b.filter(s=>{var m;if(!s.is_yopla_team)return!1;const l=(m=s.user_email)==null?void 0:m.toLowerCase();return V.has(l)?!1:(V.add(l),!0)}).map(s=>({id:s.id,email:s.user_email,full_name:s.user_name||[s.first_name,s.last_name].filter(Boolean).join(" "),first_name:s.first_name,last_name:s.last_name,role:"user",_fromWorkspaceUser:!0})),me=j.filter(s=>!V.has(s.email)).map(s=>(V.add(s.email),{id:`hs-${s.hubspot_id}`,email:s.email,full_name:[s.first_name,s.last_name].filter(Boolean).join(" "),first_name:s.first_name,last_name:s.last_name,role:"user",_fromHubSpot:!0,_hubspotId:s.hubspot_id,_hubspotJobTitle:s.job_title})),xe=new Set(v.map(s=>s.id)),w={};return b.filter(s=>!s.is_yopla_team&&xe.has(s.workspace_id)).forEach(s=>{var T;const l=(T=s.user_email)==null?void 0:T.toLowerCase();w[l]||(w[l]={email:s.user_email,name:"",first_name:s.first_name,last_name:s.last_name,hubspot_contact_id:s.hubspot_contact_id,workspaces:[]});const m=a[s.workspace_id],S=m?o[m.client_company_id]:null;w[l].workspaces.push({id:s.workspace_id,name:(S==null?void 0:S.name)||(m==null?void 0:m.title)||"Unknown"}),s.first_name||s.last_name?(w[l].name=[s.first_name,s.last_name].filter(Boolean).join(" "),w[l].first_name=s.first_name,w[l].last_name=s.last_name):!w[l].name&&s.user_name&&(w[l].name=s.user_name),s.hubspot_contact_id&&(w[l].hubspot_contact_id=s.hubspot_contact_id)}),{teamUsers:[...U,...de,...me],profileIndex:c,teamWorkspaceIndex:d,clientUsers:Object.values(w),wsMap:a,companyMap:o}},[h,b,v,g,j]),$=N.useMemo(()=>v.map(a=>{const o=H[a.client_company_id];return{id:a.id,name:(o==null?void 0:o.name)||a.title||"Unknown"}}).sort((a,o)=>a.name.localeCompare(o.name)),[v,H]),C=n.toLowerCase(),E=W.filter(a=>{var d;if(i==="client")return!1;const o=(d=a.email)==null?void 0:d.toLowerCase(),c=L[o];return!(C&&!Q(a,c).toLowerCase().includes(C)&&!(o!=null&&o.includes(C))||p!=="all"&&!(y[o]||[]).some(x=>x.id===p))}),I=D.filter(a=>{var o,c;return!(i==="team"||C&&!((o=a.name)!=null&&o.toLowerCase().includes(C))&&!((c=a.email)!=null&&c.toLowerCase().includes(C))&&!a.workspaces.some(d=>d.name.toLowerCase().includes(C))||p!=="all"&&!a.workspaces.some(d=>d.id===p))}),B=i!=="all"||p!=="all"||n;if(F)return e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(ie,{className:"w-6 h-6 animate-spin text-stone-400"})});const M=f?L[(O=f.email)==null?void 0:O.toLowerCase()]||{}:{};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-lg font-medium text-stone-900",children:"Users"}),e.jsx(De,{teamCount:W.length,clientCount:D.length,workspaceCount:v.length})]})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1 max-w-xs",children:[e.jsx(Se,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-stone-400"}),e.jsx(P,{placeholder:"Search...",value:n,onChange:a=>t(a.target.value),className:"pl-9 h-9"})]}),e.jsxs(Y,{value:i,onValueChange:_,children:[e.jsx(J,{className:"w-[120px] h-9",children:e.jsx(z,{})}),e.jsxs(G,{children:[e.jsx(q,{value:"all",children:"Everyone"}),e.jsx(q,{value:"team",children:"Team"}),e.jsx(q,{value:"client",children:"Clients"})]})]}),e.jsxs(Y,{value:p,onValueChange:u,children:[e.jsx(J,{className:"w-[180px] h-9",children:e.jsx(z,{placeholder:"All workspaces"})}),e.jsxs(G,{children:[e.jsx(q,{value:"all",children:"All workspaces"}),$.map(a=>e.jsx(q,{value:a.id,children:a.name},a.id))]})]}),B&&e.jsxs("button",{onClick:()=>{t(""),_("all"),u("all")},className:"text-xs text-stone-400 hover:text-stone-600 transition-colors flex items-center gap-1",children:[e.jsx(le,{className:"w-3 h-3"}),"Clear"]})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-stone-200 divide-y divide-stone-100",children:[E.length>0&&e.jsxs(e.Fragment,{children:[i==="all"&&e.jsx("div",{className:"px-4 py-2 bg-stone-50/50",children:e.jsxs("p",{className:"text-[11px] font-medium text-stone-400 uppercase tracking-widest",children:["Team · ",E.length]})}),E.map(a=>{var U;const o=(U=a.email)==null?void 0:U.toLowerCase(),c=L[o]||{},d=(y[o]||[]).map(x=>x.name);return e.jsx(Be,{user:a,displayName:Q(a,c),profile:c,workspaceCount:d.length,workspaceNames:d,onEditProfile:x=>r(x)},a.id)})]}),I.length>0&&e.jsxs(e.Fragment,{children:[i==="all"&&e.jsx("div",{className:"px-4 py-2 bg-stone-50/50",children:e.jsxs("p",{className:"text-[11px] font-medium text-stone-400 uppercase tracking-widest",children:["Clients · ",I.length]})}),I.map(a=>e.jsx(He,{client:a},a.email))]}),E.length===0&&I.length===0&&e.jsxs("div",{className:"text-center py-16",children:[e.jsx("p",{className:"text-stone-400 text-sm",children:B?"No users match":"No users yet"}),!B&&e.jsx("p",{className:"text-stone-400 text-xs mt-1",children:"Team is sourced from HubSpot"})]})]}),e.jsx(Me,{user:f,profile:M,displayName:f?Q(f,M):"",onClose:()=>r(null)})]})}function is(){return e.jsx(Ue,{maxWidth:1320,children:e.jsx(Le,{title:"Team & users",subtitle:"Manage Yopla team members and invite app users.",children:e.jsx("div",{className:"py-4",children:e.jsx(Re,{})})})})}export{is 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.