PageSourceSearch

https://beetlai.com/assets/OrgTreePage-C6bVVWXl.js

js beetlai.com collected 2026-10-02 01:25:03 UTC 7,641 bytes, 1 lines download raw bytes

1import{q as e}from"./index-Chw7iKGq.js";import{e as l}from"./vendor-feOCaMQ1.js";import{a as R,S as I}from"./http-BvY171ik.js";import{m as W}from"./api-CyA8PGIP.js";function L(){const[s,m]=l.useState({nodes:[],roots:[]}),[n,c]=l.useState(null),[o,y]=l.useState(""),[j,f]=l.useState(()=>new Set),[x,h]=l.useState(!0),[g,u]=l.useState(""),p=l.useCallback(async()=>{var t;h(!0);try{const a=await W.orgTree();m(a||{nodes:[],roots:[]}),!n&&((t=a==null?void 0:a.roots)!=null&&t.length)&&c(a.roots[0]),u("")}catch(a){u((a==null?void 0:a.message)||"Failed to load org tree.")}finally{h(!1)}},[n]);l.useEffect(()=>{p()},[]);const b=l.useMemo(()=>Object.fromEntries((s.nodes||[]).map(t=>[t.id,t])),[s.nodes]),w=l.useMemo(()=>{const t={};for(const a of s.nodes||[]){const i=a.manager_id||"__roots__";(t[i]||(t[i]=[])).push(a)}return Object.values(t).forEach(a=>a.sort((i,d)=>(i.display_name||"").localeCompare(d.display_name||""))),t},[s.nodes]),_=l.useMemo(()=>{const t=(s.roots||[]).map(d=>b[d]).filter(Boolean);if(!o.trim())return t;const a=o.toLowerCase();return(s.nodes||[]).filter(d=>[d.display_name,d.email,d.designation,d.department].some(z=>String(z||"").toLowerCase().includes(a))).slice(0,50)},[s,b,o]),r=n?b[n]:null,C=r?w[r.id]||[]:[],v=r&&r.manager_id?b[r.manager_id]:null,k=t=>{f(a=>{const i=new Set(a);return i.has(t)?i.delete(t):i.add(t),i})},S=l.useMemo(()=>{const t=s.nodes||[],a=new Set(t.map(i=>i.manager_id).filter(Boolean)).size;return{total:t.length,managers:a,ic:t.length-a,departments:new Set(t.map(i=>i.department).filter(Boolean)).size}},[s.nodes]);return e.jsxs(R,{eyebrow:"HR · Directory",title:"Org Tree",subtitle:"See who reports to whom across the company. Click any name to drill into their team.",appLayoutTitle:"HR · Org Tree",children:[g&&e.jsx("div",{className:"alert-error",children:g}),e.jsxs("div",{className:"hr-stat-grid",children:[e.jsx(N,{label:"Total employees",value:S.total}),e.jsx(N,{label:"Managers",value:S.managers}),e.jsx(N,{label:"Individual contributors",value:S.ic}),e.jsx(N,{label:"Departments",value:S.departments})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(280px, 380px) minmax(0, 1fr)",gap:16},children:[e.jsxs("div",{className:"hr-card",style:{display:"flex",flexDirection:"column",maxHeight:"calc(100vh - 320px)"},children:[e.jsx("div",{className:"hr-card-head",children:e.jsx("div",{style:{flex:1},children:e.jsx("input",{className:"form-input",placeholder:"Search by name, email, role…",value:o,onChange:t=>y(t.target.value)})})}),e.jsx("div",{style:{overflowY:"auto",padding:10},children:x?e.jsx("div",{style:{color:"var(--text3)",padding:12},children:"Loading…"}):_.length===0?e.jsx("div",{className:"hr-empty",children:e.jsx("div",{className:"hr-empty-title",children:"No employees match"})}):_.map(t=>e.jsx(T,{node:t,depth:0,childrenByManager:w,activeId:n,onSelect:c,collapsed:j,onToggle:k,searchActive:!!o.trim()},t.id))})]}),e.jsx("div",{className:"hr-card",style:{minHeight:280},children:r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hr-card-head",children:[e.jsxs("div",{style:{display:"flex",gap:14,alignItems:"center",minWidth:0},children:[e.jsx("div",{className:"hr-avatar tinted",style:{width:52,height:52,borderRadius:14,fontSize:18},children:(r.display_name||"?").slice(0,2).toUpperCase()}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("h3",{className:"hr-card-title",style:{fontSize:17},children:r.display_name}),e.jsxs("p",{className:"hr-card-subtitle",children:[r.designation||"—",r.department?` · ${r.department}`:"",r.email?` · ${r.email}`:""]})]})]}),e.jsx(I,{status:r.status})]}),v&&e.jsxs("div",{className:"hr-card-body",style:{paddingBottom:0},children:[e.jsx("div",{style:{fontSize:11,fontWeight:800,letterSpacing:".06em",textTransform:"uppercase",color:"var(--text3)",marginBottom:8},children:"Reports to"}),e.jsxs("button",{type:"button",onClick:()=>c(v.id),className:"hr-list-item",style:{width:"100%"},children:[e.jsx("div",{className:"hr-avatar",children:(v.display_name||"?").slice(0,2).toUpperCase()}),e.jsxs("div",{className:"hr-list-item-copy",children:[e.jsx("div",{className:"hr-list-item-title",children:v.display_name}),e.jsx("div",{className:"hr-list-item-meta",children:v.designation||"—"})]}),e.jsx("span",{style:{color:"var(--text3)"},children:"↑"})]})]}),e.jsxs("div",{className:"hr-card-body",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10},children:[e.jsx("div",{style:{fontSize:11,fontWeight:800,letterSpacing:".06em",textTransform:"uppercase",color:"var(--text3)"},children:"Direct reports"}),e.jsx("span",{className:"hr-count-pill",children:C.length})]}),C.length===0?e.jsx("div",{style:{color:"var(--text3)",fontSize:13},children:"Individual contributor — no direct reports."}):e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:10},children:C.map(t=>e.jsxs("button",{type:"button",onClick:()=>c(t.id),className:"hr-list-item",style:{width:"100%"},children:[e.jsx("div",{className:"hr-avatar",children:(t.display_name||"?").slice(0,2).toUpperCase()}),e.jsxs("div",{className:"hr-list-item-copy",children:[e.jsx("div",{className:"hr-list-item-title",children:t.display_name}),e.jsx("div",{className:"hr-list-item-meta",children:t.designation||"—"})]}),e.jsx("span",{className:"hr-count-pill",children:(w[t.id]||[]).length})]},t.id))})]})]}):e.jsxs("div",{className:"hr-detail-empty",children:[e.jsx("div",{style:{fontSize:14,fontWeight:700,color:"var(--text)"},children:"Select an employee"}),e.jsx("div",{children:"Pick anyone on the left to see their team."})]})})]})]})}function N({label:s,value:m}){return e.jsxs("div",{className:"hr-stat-card",children:[e.jsx("div",{className:"hr-stat-label",children:s}),e.jsx("div",{className:"hr-stat-value",children:m})]})}function T({node:s,depth:m,childrenByManager:n,activeId:c,onSelect:o,collapsed:y,onToggle:j,searchActive:f}){const x=n[s.id]||[],h=x.length>0,g=!y.has(s.id)||f,u=c===s.id;return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"20px minmax(0, 1fr) auto",gap:6,alignItems:"center",paddingLeft:m*14,paddingRight:6,paddingTop:4,paddingBottom:4,borderRadius:8,cursor:"pointer",background:u?"rgba(99,102,241,.08)":"transparent"},children:[h?e.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),j(s.id)},style:{width:20,height:20,border:"none",background:"transparent",curs
1or:"pointer",color:"var(--text3)",fontSize:11,padding:0},children:g?"▾":"▸"}):e.jsx("span",{}),e.jsxs("button",{type:"button",onClick:()=>o(s.id),style:{display:"flex",alignItems:"center",gap:8,border:"none",background:"transparent",padding:"4px 6px",cursor:"pointer",textAlign:"left",minWidth:0,fontFamily:"inherit"},children:[e.jsx("div",{style:{width:24,height:24,borderRadius:7,background:"var(--surface2)",color:"var(--text2)",display:"flex",alignItems:"center",justifyContent:"center",fontWeight:700,fontSize:10,flexShrink:0},children:(s.display_name||"?").slice(0,2).toUpperCase()}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:u?"var(--accent)":"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s.display_name}),e.jsx("div",{style:{fontSize:11,color:"var(--text3)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s.designation||s.department||"—"})]})]}),h&&e.jsx("span",{className:"hr-count-pill",children:x.length})]}),g&&h&&x.map(p=>e.jsx(T,{node:p,depth:m+1,childrenByManager:n,activeId:c,onSelect:o,collapsed:y,onToggle:j,searchActive:f},p.id))]})}export{L 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.