PageSourceSearch

https://resolveit.ai/assets/dashboard-BLttDU2u.js

js resolveit.ai collected 2026-10-05 15:17:08 UTC 29,809 bytes, 3 lines download raw bytes

1import{k as Me,q as Re,j as e,cm as ts,aC as as,aw as ne,a9 as is,s as ns,t as rs,r as o,l as k,v as x,L as F,C as d,w,x as C,y as ls,a as m,B as c,f as Pe,g as os,av as N,o as ke,aN as cs,aq as $e,bc as ds,Y as Z,d4 as ee,U as ms,Z as se,_ as te,$ as ae,z as f,I as S,ag as I,ah as T,ai as M,aj as R,al as p,T as us,cX as xs,dj as ps,c6 as hs,aU as Fe,aL as js,a4 as gs,a7 as ys,E as Oe,cQ as Be,bb as vs,aV as fs,W as h}from"./pages-admin-CBNFTGIo.js";import{D as Ns,a as bs,b as ws,c as Cs}from"./index-DvZyzSM2.js";import"./pages-user-DBgyi5oE.js";import"./pages-public-Dm5I1a-v.js";const Ee={consumer:"#1B3A6B",therapy:"#0D7377",corporate:"#B8860B"},Le={consumer:ne,therapy:as,corporate:ts},Ie={consumer:"Consumer",therapy:"Health",corporate:"Corporate"};function Ss(){const{contexts:n,activeContext:a,switchContext:u}=Me(),[,r]=Re();if(n.length<2||!a||!n.find(l=>l.product===a))return null;const K=Le[a],b=Ee[a];async function z(l){if(l===a)return;const $=n.find(P=>P.product===l);await u(l)&&$&&r($.defaultPath)}return e.jsxs(Ns,{children:[e.jsx(bs,{asChild:!0,children:e.jsxs("button",{className:"flex items-center gap-1.5 px-2 py-1 rounded-md text-xs font-medium text-white/90 hover:text-white transition-colors cursor-pointer",style:{backgroundColor:`${b}40`},"data-testid":"button-context-switcher",children:[e.jsx(K,{className:"h-3.5 w-3.5",style:{color:b}}),e.jsx("span",{className:"hidden sm:inline",children:Ie[a]}),e.jsx(is,{className:"h-3 w-3 opacity-60"})]})}),e.jsx(ws,{align:"start",className:"w-48 rounded-xl shadow-xl border-border/50",children:n.map(l=>{const $=Le[l.product],O=Ee[l.product],P=l.product===a;return e.jsxs(Cs,{onClick:()=>z(l.product),className:`cursor-pointer ${P?"font-semibold":""}`,"data-testid":`menu-context-${l.product}`,children:[e.jsx($,{className:"mr-2 h-4 w-4",style:{color:O}}),e.jsx("span",{children:Ie[l.product]}),P&&e.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"Active"})]},l.product)})})]})}const Te={admin:"bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400",manager:"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",employee:"bg-gray-100 text-gray-700 dark:bg-gray-900/30 dark:text-gray-400"},ie={active:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",inactive:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400",frozen:"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",resolved:"bg-emerald-100 text-emerald-700",closed:"bg-gray-100 text-gray-600",invite_sent:"bg-yellow-100 text-yellow-700",pending:"bg-yellow-100 text-yellow-700"};function Is(){const{user:n}=Me(),{toast:a}=ns(),u=rs(),[,r]=Re(),[B,K]=o.useState(""),[b,z]=o.useState(""),[l,$]=o.useState(""),[O,P]=o.useState(!1),[Q,re]=o.useState(""),[le,De]=o.useState("employee"),[Ue,oe]=o.useState(!1),[ce,de]=o.useState(""),[qe,me]=o.useState(!1),[D,ue]=o.useState(""),[U,xe]=o.useState(""),[ks,$s]=o.useState(!1),[pe,Ae]=o.useState(""),[he,Ke]=o.useState(""),[H,je]=o.useState(""),[E,ge]=o.useState(""),[_,ye]=o.useState(""),ze=(()=>{const t=new URLSearchParams(window.location.search).get("tab");return t&&["roster","sessions","billing","invitations","directory","profile"].includes(t)?t:"roster"})(),[j,Qe]=o.useState(ze),{data:y,isLoading:He}=k({queryKey:["/api/corp/my-company"]}),i=y?.companyId,q=y?.companyRole||"employee",v=q==="admin",V=q==="manager",L=v||V,{data:Y,isLoading:_e}=k({queryKey:["/api/corp/companies",i,"members",B,b,l],queryFn:async()=>{const s=new URLSearchParams;B&&s.set("search",B),b&&b!=="all"&&s.set("role",b),l&&l!=="all"&&s.set("status",l);const t=await fetch(`/api/corp/companies/${i}/members?${s}`,{credentials:"include"});if(!t.ok)throw new Error("Failed to fetch");return t.json()},enabled:!!i}),{data:ve}=k({queryKey:["/api/corp/companies",i,"sessions"],enabled:!!i&&j==="sessions"}),{data:g}=k({queryKey:["/api/corp/companies",i,"billing"],enabled:!!i&&j==="billing"}),{data:fe}=k({queryKey:["/api/corp/companies",i,"invitations"],enabled:!!i&&j==="invitations"}),{data:Ne}=k({queryKey:["/api/corp/companies",i,"directory"],enabled:!!i&&j==="directory"}),G=x({mutationFn:async({email:s,role:t})=>h("POST",`/api/corp/companies/${i}/invitations`,{email:s,role:t}),onSuccess:()=>{a({title:"Invitation sent"}
1),P(!1),re(""),u.invalidateQueries({queryKey:["/api/corp/companies",i,"invitations"]})},onError:s=>{a({title:"Failed to send invitation",description:s.message,variant:"destructive"})}}),be=x({mutationFn:async({emails:s,role:t})=>(await h("POST",`/api/corp/companies/${i}/invitations/bulk`,{emails:s,role:t})).json(),onSuccess:s=>{a({title:`Invited ${s.succeeded} of ${s.total}`}),oe(!1),de(""),u.invalidateQueries({queryKey:["/api/corp/companies",i,"invitations"]})},onError:s=>{a({title:"Bulk invite failed",description:s.message,variant:"destructive"})}}),Ve=x({mutationFn:async({memberId:s,companyRole:t})=>h("PATCH",`/api/corp/companies/${i}/members/${s}/role`,{companyRole:t}),onSuccess:()=>{a({title:"Role updated"}),u.invalidateQueries({queryKey:["/api/corp/companies",i,"members"]})},onError:s=>{a({title:"Failed to update role",description:s.message,variant:"destructive"})}}),Ye=x({mutationFn:async({memberId:s,status:t})=>h("PATCH",`/api/corp/companies/${i}/members/${s}/status`,{status:t}),onSuccess:()=>{a({title:"Status updated"}),u.invalidateQueries({queryKey:["/api/corp/companies",i,"members"]})},onError:s=>{a({title:"Failed to update status",description:s.message,variant:"destructive"})}}),Ge=x({mutationFn:async s=>h("DELETE",`/api/corp/companies/${i}/members/${s}`),onSuccess:()=>{a({title:"Member removed"}),u.invalidateQueries({queryKey:["/api/corp/companies",i,"members"]})},onError:s=>{a({title:"Failed to remove member",description:s.message,variant:"destructive"})}}),Xe=x({mutationFn:async({memberId:s,newPassword:t})=>h("POST",`/api/corp/companies/${i}/members/${s}/reset-password`,{newPassword:t}),onSuccess:()=>{a({title:"Password reset successfully"})},onError:s=>{a({title:"Failed to reset password",description:s.message,variant:"destructive"})}}),Je=x({mutationFn:async({sessionId:s,frozen:t})=>h("PATCH",`/api/corp/companies/${i}/sessions/${s}/freeze`,{frozen:t}),onSuccess:()=>{a({title:"Session updated"}),u.invalidateQueries({queryKey:["/api/corp/companies",i,"sessions"]})}}),We=x({mutationFn:async s=>h("PATCH",`/api/corp/companies/${i}/sessions/${s}/archive`,{}),onSuccess:()=>{a({title:"Session archived"}),u.invalidateQueries({queryKey:["/api/corp/companies",i,"sessions"]})}}),we=x({mutationFn:async({name:s,employeeUserId:t})=>h("POST",`/api/corp/companies/${i}/sessions`,{name:s,employeeUserId:t}),onSuccess:()=>{a({title:"Session created"}),me(!1),ue(""),xe(""),u.invalidateQueries({queryKey:["/api/corp/companies",i,"sessions"]})},onError:s=>{a({title:"Failed to create session",description:s.message,variant:"destructive"})}}),Ce=x({mutationFn:async()=>(await h("POST",`/api/corp/companies/${i}/billing/portal`,{})).json(),onSuccess:s=>{s.url&&window.open(s.url,"_blank")},onError:s=>{a({title:"Failed to open billing portal",description:s.message,variant:"destructive"})}}),Ze=x({mutationFn:async()=>h("POST","/api/corp/leave-company",{}),onSuccess:()=>{a({title:"You have left the company"}),u.invalidateQueries({queryKey:["/api/corp/my-company"]}
1),u.invalidateQueries({queryKey:["/api/user"]}),r("/")},onError:s=>{a({title:"Failed to leave company",description:s.message,variant:"destructive"})}}),X=x({mutationFn:async({firstName:s,lastName:t})=>h("PATCH","/api/corp/my-profile",{firstName:s,lastName:t}),onSuccess:()=>{a({title:"Profile updated"}),u.invalidateQueries({queryKey:["/api/auth/me"]}),u.invalidateQueries({queryKey:["/api/corp/my-profile"]})},onError:s=>{a({title:"Failed to update profile",description:s.message,variant:"destructive"})}}),J=x({mutationFn:async({currentPassword:s,newPassword:t})=>h("POST","/api/corp/change-password",{currentPassword:s,newPassword:t}),onSuccess:()=>{a({title:"Password changed successfully"}),je(""),ge(""),ye("")},onError:s=>{a({title:"Failed to change password",description:s.message,variant:"destructive"})}}),Se=o.useRef(null),W=x({mutationFn:async s=>{const t=new FormData;t.append("logo",s);const A=await fetch(`/api/corp/companies/${i}/logo`,{method:"POST",body:t,credentials:"include"});if(!A.ok){const ss=await A.json().catch(()=>({}));throw new Error(ss.error||"Upload failed")}return A.json()},onSuccess:()=>{a({title:"Logo uploaded successfully"}),u.invalidateQueries({queryKey:["/api/corp/my-company"]})},onError:s=>{a({title:"Failed to upload logo",description:s.message,variant:"destructive"})}});if(He)return e.jsx("div",{className:"flex items-center justify-center min-h-screen","data-testid":"corporate-dashboard-loading",children:e.jsx(F,{className:"h-8 w-8 animate-spin text-[#B8860B]"})});if(!y?.hasCompany)return e.jsx("div",{className:"flex items-center justify-center min-h-screen bg-gradient-to-b from-[#1a2e4a] to-[#0f1f35] p-4","data-testid":"corporate-no-company",children:e.jsxs(d,{className:"w-full max-w-md",children:[e.jsxs(w,{children:[e.jsx(C,{"data-testid":"text-no-company",children:"No Company Found"}),e.jsx(ls,{children:"You're not part of a company yet."})]}),e.jsxs(m,{className:"space-y-3",children:[e.jsxs(c,{onClick:()=>r("/corporate/setup"),className:"w-full bg-[#B8860B]","data-testid":"button-setup-company",children:[e.jsx(Pe,{className:"mr-2 h-4 w-4"})," Set Up Your Company"]}),e.jsx(c,{onClick:()=>r("/"),variant:"outline",className:"w-full","data-testid":"button-go-home",children:"Go Home"})]})]})});const es=[{key:"roster",label:"Team",icon:ne},{key:"sessions",label:"Sessions",icon:ke},...v?[{key:"billing",label:"Billing",icon:cs}]:[],...L?[{key:"invitations",label:"Invitations",icon:$e}]:[],{key:"directory",label:"Directory",icon:Pe},{key:"profile",label:"My Profile",icon:ds}];return e.jsxs("div",{className:"flex flex-col min-h-screen bg-background","data-testid":"corporate-dashboard",children:[e.jsxs("div",{className:"bg-[#B8860B] text-white px-4 py-2 flex items-center justify-between flex-shrink-0","data-testid":"corporate-banner",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[y.companyLogoUrl?e.jsx("img",{src:y.companyLogoUrl,alt:y.companyName,className:"h-7 w-auto max-w-[100px] object-contain rounded","data-testid":"img-company-logo-banner"}):e.jsx(os,{className:"h-5 w-5"}),e.jsx("span",{className:"font-semibold text-sm",children:y.companyName}),e.jsx(N,{variant:"outline",className:"text-white/80 border-white/30 text-xs",children:q})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ss,{}),e.jsxs("span",{className:"text-xs text-white/70 hidden sm:block",children:[n?.firstName," ",n?.lastName]})]})]}),e.jsx("div",{className:"border-b bg-background/95 backdrop-blur px-4 overflow-x-auto",children:e.jsx("div",{className:"flex gap-1",children:es.map(s=>{const t=s.icon;return e.jsxs("button",{onClick:()=>Qe(s.key),className:`flex items-center gap-1.5 px-3 py-2.5 text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${j===s.key?"border-[#B8860B] text-[#B8860B]":"border-transparent text-muted-foreground hover:text-foreground"}`,"data-testid":`tab-${s.key}`,children:[e.jsx(t,{className:"h-4 w-4"}),s.label]},s.key)})})}),e.jsxs("main",{className:"flex-1 p-4 sm:p-6 max-w-7xl mx-auto w-full","data-testid":"corporate-content",children:[j==="roster"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[e.jsx("h2",{className:"text-xl font-bold","data-testid":"text-roster-title",children:"Team Roster"}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[L&&e.jsxs(Z,{open:O,onOpenChange:P,children:[e.jsx(ee,{asChild:!0,children:e.jsxs(c,{size:"sm",className:"bg-[#B8860B]","data-testid":"button-invite-employee",children:[e.jsx(ms,{className:"h-4 w-4 mr-1"})," Invite"]})}),e.jsxs(se,{children:[e.jsx(te,{children:e.jsx(ae,{children:"Invite Employee"})}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsxs("div",{children:[e.jsx(f,{children:"Email"}),e.jsx(S,{value:Q,onChange:s=>re(s.target.value),placeholder:"[email protected]","data-testid":"input-invite-email"})]}),v&&e.jsxs("div",{children:[e.jsx(f,{children:"Role"}),e.jsxs(I,{value:le,onValueChange:De,children:[e.jsx(T,{"data-testid":"select-invite-role",children:e.jsx(M,{})}),e.jsxs(R,{children:[e.jsx(p,{value:"employee",children:"Employee"}),e.jsx(p,{value:"manager",children:"Manager"}),e.jsx(p,{value:"admin",children:"Admin"})]})]})]}),e.jsxs(c,{className:"w-full bg-[#B8860B]",onClick:()=>G.mutate({email:Q,role:le}),disabled:!Q||G.isPending,"data-testid":"button-send-invite",children:[G.isPending?e.jsx(F,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx($e,{className:"h-4 w-4 mr-1"}),"Send Invitation"]})]})]})]}),v&&e.jsxs(Z,{open:Ue,onOpenChange:oe,children:[e.jsx(ee,{asChild:!0,children:e.jsxs(c,{size:"sm",variant:"outline","data-testid":"button-bulk-invite",children:[e.jsx(ne,{className:"h-4 w-4 mr-1"})," Bulk Invite"]})}),e.jsxs(se,{children:[e.jsx(te,{children:e.jsx(ae,{children:"Bulk Invite"})}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsxs("div",{children:[e.jsx(f,{children:"Emails (one per line)"}),e.jsx(us,{value:ce,onChange:s=>de(s.target.value),placeholder:`[email protected]
2[email protected]`,rows:5,"data-testid":"input-bulk-emails"})]}),e.jsx(c,{className:"w-full bg-[#B8860B]",onClick:()=>{const s=ce.split(`
3`).map(t=>t.trim()).filter(t=>t.includes("@"));be.mutate({emails:s,role:"employee"})},disabled:be.isPending,"data-testid":"button-send-bulk-invite",children:"Send Invitations"})]})]})]})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(xs,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(S,{className:"pl-9",placeholder:"Search by name or email...",value:B,onChange:s=>K(s.target.value),"data-testid":"input-search-members"})]}),e.jsxs(I,{value:b,onValueChange:z,children:[e.jsx(T,{className:"w-[140px]","data-testid":"select-role-filter",children:e.jsx(M,{placeholder:"All roles"})}),e.jsxs(R,{children:[e.jsx(p,{value:"all",children:"All roles"}),e.jsx(p,{value:"admin",children:"Admin"}),e.jsx(p,{value:"manager",children:"Manager"}),e.jsx(p,{value:"employee",children:"Employee"})]})]}),e.jsxs(I,{value:l,onValueChange:$,children:[e.jsx(T,{className:"w-[140px]","data-testid":"select-status-filter",children:e.jsx(M,{placeholder:"All statuses"})}),e.jsxs(R,{children:[e.jsx(p,{value:"all",children:"All statuses"}),e.jsx(p,{value:"active",children:"Active"}),e.jsx(p,{value:"inactive",children:"Inactive"})]})]})]}),_e?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(F,{className:"h-6 w-6 animate-spin text-[#B8860B]"})}):Y?.length?e.jsx("div",{className:"space-y-2",children:Y.map(s=>e.jsx(d,{"data-testid":`card-member-${s.id}`,children:e.jsxs(m,{className:"flex items-center justify-between py-3 px-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-9 w-9 rounded-full bg-[#B8860B]/10 flex items-center justify-center text-sm font-medium text-[#B8860B]",children:(s.firstName?.[0]||s.email[0]).toUpperCase()}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm","data-testid":`text-member-name-${s.id}`,children:s.firstName&&s.lastName?`${s.firstName} ${s.lastName}`:s.email}),s.firstName&&e.jsx("div",{className:"text-xs text-muted-foreground",children:s.email})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{className:`${Te[s.companyRole]||""} hover:opacity-80`,variant:"secondary","data-testid":`badge-role-${s.id}`,children:s.companyRole}),e.jsx(N,{className:`${ie[s.status]||""} hover:opacity-80`,variant:"secondary","data-testid":`badge-status-${s.id}`,children:s.status}),s.userId!==n?.id&&(v||V&&s.managerUserId===n?.id)&&e.jsxs("div",{className:"flex gap-1",children:[v&&e.jsxs(I,{value:s.companyRole,onValueChange:t=>Ve.mutate({memberId:s.id,companyRole:t}),children:[e.jsx(T,{className:"h-7 w-24 text-xs","data-testid":`select-change-role-${s.id}`,children:e.jsx(M,{})}),e.jsxs(R,{children:[e.jsx(p,{value:"employee",children:"Employee"}),e.jsx(p,{value:"manager",children:"Manager"}),e.jsx(p,{value:"admin",children:"Admin"})]})]}),e.jsx(c,{size:"sm",variant:"ghost",className:"h-7 px-2",onClick:()=>Ye.mutate({memberId:s.id,status:s.status==="active"?"inactive":"active"}),"data-testid":`button-toggle-status-${s.id}`,children:s.status==="active"?e.jsx(ps,{className:"h-3.5 w-3.5"}):e.jsx(hs,{className:"h-3.5 w-3.5"})}),e.jsx(c,{size:"sm",variant:"ghost",className:"h-7 px-2",onClick:()=>{const t=prompt("Enter new password for this member (min 8 characters):");t&&t.length>=8?Xe.mutate({memberId:s.id,newPassword:t}):t&&a({title:"Password must be at least 8 characters",variant:"destructive"})},"data-testid":`button-reset-password-${s.id}`,children:e.jsx(Fe,{className:"h-3.5 w-3.5"})}),e.jsx(c,{size:"sm",variant:"ghost",className:"h-7 px-2 text-destructive",onClick:()=>{confirm("Remove this member from the company?")&&Ge.mutate(s.id)},"data-testid":`button-remove-${s.id}`,children:e.jsx(js,{className:"h-3.5 w-3.5"})})]})]})]})},s.id))}):e.jsx(d,{children:e.jsx(m,{className:"py-12 text-center text-muted-foreground",children:"No team members found"})})]}),j==="sessions"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-xl font-bold","data-testid":"text-sessions-title",children:v?"Company Sessions":V?"Team Sessions":"My Sessions"}),L&&e.jsxs(Z,{open:qe,onOpenChange:me,children:[e.jsx(ee,{asChild:!0,children:e.jsxs(c,{size:"sm",className:"bg-[#B8860B]","data-testid":"button-create-session",children:[e.jsx(ke,{className:"h-4 w-4 mr-1"})," New Session"]})}),e.jsxs(se,{children:[e.jsx(te,{children:e.jsx(ae,{children:"Create Corporate RESOLVEit Session"})}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsxs("div",{children:[e.jsx(f,{children:"Session Name"}),e.jsx(S,{value:D,onChange:s=>ue(s.target.value),placeholder:"e.g. Team Collaboration Improvement","data-testid":"input-session-name"})]}),e.jsxs("div",{children:[e.jsx(f,{children:"Employee"}),e.jsxs(I,{value:U,onValueChange:xe,children:[e.jsx(T,{"data-testid":"select-session-employee",children:e.jsx(M,{placeholder:"Select employee"})}),e.jsx(R,{children:Y?.filter(s=>s.status==="active").map(s=>e.jsxs(p,{value:String(s.userId),children:[s.firstName," ",s.lastName," 
3(",s.email,")"]},s.userId))})]})]}),e.jsx(c,{className:"w-full bg-[#B8860B]",onClick:()=>{D&&U&&we.mutate({name:D,employeeUserId:parseInt(U)})},disabled:!D||!U||we.isPending,"data-testid":"button-submit-session",children:"Create Session"})]})]})]})]}),ve?.length?e.jsx("div",{className:"space-y-2",children:ve.map(s=>e.jsx(d,{"data-testid":`card-session-${s.id}`,children:e.jsxs(m,{className:"flex items-center justify-between py-3 px-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm","data-testid":`text-session-name-${s.id}`,children:s.name||`Session #${s.id}`}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Created ",new Date(s.createdAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{className:ie[s.status]||"",variant:"secondary","data-testid":`badge-session-status-${s.id}`,children:s.status}),L&&s.status!=="closed"&&s.status!=="resolved"&&e.jsxs(e.Fragment,{children:[e.jsx(c,{size:"sm",variant:"ghost",className:"h-7 px-2",onClick:()=>Je.mutate({sessionId:s.id,frozen:s.status!=="frozen"}),"data-testid":`button-freeze-${s.id}`,children:e.jsx(gs,{className:"h-3.5 w-3.5"})}),e.jsx(c,{size:"sm",variant:"ghost",className:"h-7 px-2",onClick:()=>We.mutate(s.id),"data-testid":`button-archive-${s.id}`,children:e.jsx(ys,{className:"h-3.5 w-3.5"})})]})]})]})},s.id))}):e.jsx(d,{children:e.jsx(m,{className:"py-12 text-center text-muted-foreground",children:"No sessions found"})})]}),j==="billing"&&v&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-xl font-bold","data-testid":"text-billing-title",children:"Billing"}),g?e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs(d,{"data-testid":"card-seat-count",children:[e.jsx(w,{className:"pb-2",children:e.jsx(C,{className:"text-sm text-muted-foreground",children:"Active Seats"})}),e.jsxs(m,{children:[e.jsx("div",{className:"text-2xl font-bold","data-testid":"text-seat-count",children:g.activeEmployees}),g.subscription&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[g.subscription.seat
3Count," billed"]})]})]}),e.jsxs(d,{"data-testid":"card-per-seat-cost",children:[e.jsx(w,{className:"pb-2",children:e.jsx(C,{className:"text-sm text-muted-foreground",children:"Per Seat Cost"})}),e.jsx(m,{children:e.jsxs("div",{className:"text-2xl font-bold","data-testid":"text-per-seat-cost",children:[g.subscription?`$${(g.subscription.perSeatPriceCents/100).toFixed(2)}`:"—","/mo"]})})]}),e.jsxs(d,{"data-testid":"card-subscription-status",children:[e.jsx(w,{className:"pb-2",children:e.jsx(C,{className:"text-sm text-muted-foreground",children:"Status"})}),e.jsx(m,{children:e.jsx(N,{className:g.subscription?.status==="active"?"bg-green-100 text-green-700":"bg-gray-100 text-gray-600","data-testid":"text-subscription-status",children:g.subscription?.status||"No subscription"})})]}),e.jsxs(d,{"data-testid":"card-next-billing",children:[e.jsx(w,{className:"pb-2",children:e.jsx(C,{className:"text-sm text-muted-foreground",children:"Next Billing"})}),e.jsx(m,{children:e.jsx("div",{className:"text-sm font-medium","data-testid":"text-next-billing",children:g.subscription?.currentPeriodEnd?new Date(g.subscription.currentPeriodEnd).toLocaleDateString():"—"})})]})]}):e.jsx(d,{children:e.jsx(m,{className:"py-8 text-center text-muted-foreground",children:"Loading billing..."})}),g?.stripeCustomerId&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(c,{variant:"outline",onClick:()=>Ce.mutate(),disabled:Ce.isPending,"data-testid":"button-billing-portal",children:[e.jsx(Oe,{className:"h-4 w-4 mr-1"}),"Manage Payment Method"]})}),i&&e.jsx(Ps,{companyId:i})]}),j==="invitations"&&L&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-xl font-bold","data-testid":"text-invitations-title",children:"Invitations"}),fe?.length?e.jsx("div",{className:"space-y-2",children:fe.map(s=>e.jsx(d,{"data-testid":`card-invitation-${s.id}`,children:e.jsxs(m,{className:"flex items-center justify-between py-3 px-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:s.email}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Invited by ",s.inviterFirstName," ",s.inviterLastName," • ",new Date(s.createdAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{variant:"outline",children:s.role}),e.jsx(N,{className:ie[s.status]||"bg-gray-100 text-gray-600",variant:"secondary",children:s.status})]})]})},s.id))}):e.jsx(d,{children:e.jsx(m,{className:"py-12 text-center text-muted-foreground",children:"No invitations sent yet"})})]}),j==="directory"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-xl font-bold","data-testid":"text-directory-title",children:"Company Directory"}),Ne?.length?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:Ne.map(s=>e.jsx(d,{"data-testid":`card-directory-${s.userId}`,children:e.jsxs(m,{className:"flex items-center gap-3 py-3 px-4",children:[e.jsx("div",{className:"h-9 w-9 rounded-full bg-[#B8860B]/10 flex items-center justify-center text-sm font-medium text-[#B8860B]",children:s.firstName[0].toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium text-sm truncate",children:[s.firstName," ",s.lastName]}),e.jsx(N,{className:`${Te[s.companyRole]||""} text-xs mt-0.5`,variant:"secondary",children:s.companyRole})]})]})},s.userId))}):e.jsx(d,{children:e.jsx(m,{className:"py-12 text-center text-muted-foreground",children:"No employees found"})})]}),j==="profile"&&e.jsxs("div",{className:"space-y-6","data-testid":"profile-section",children:[v&&e.jsxs(d,{children:[e.jsx(w,{children:e.jsxs(C,{className:"flex items-center gap-2",children:[e.jsx(Be,{className:"h-4 w-4"})," Company Logo"]})}),e.jsx(m,{className:"space-y-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[y.companyLogoUrl?e.jsx("div",{className:"border rounded-lg p-3 bg-muted/40 flex items-center justify-center w-32 h-20",children:e.jsx("img",{src:y.companyLogoUrl,alt:"Company logo",className:"max-h-full max-w-full object-contain","data-testid":"img-company-logo-preview"})}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-3 bg-muted/20 flex flex-col items-center justify-center w-32 h-20 text-muted-foreground",children:[e.jsx(Be,{className:"h-6 w-6 mb-1"}),e.jsx("span",{className:"text-xs",children:"No logo"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("input",{ref:Se,type:"file",accept:"image/jpeg,image/png",className:"hidden","data-testid":"input-logo-file",onChange:s=>{const t=s.target.files?.[0];t&&W.mutate(t),s.target.value=""}}),e.jsxs(c,{variant:"outline",size:"sm",onClick:()=>
3Se.current?.click(),disabled:W.isPending,"data-testid":"button-upload-logo",children:[W.isPending?e.jsx(F,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(vs,{className:"h-4 w-4 mr-2"}),y.companyLogoUrl?"Replace Logo":"Upload Logo"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"JPEG or PNG, max 2MB"})]})]})})]}),e.jsxs(d,{children:[e.jsx(w,{children:e.jsxs(C,{className:"flex items-center gap-2",children:[e.jsx(fs,{className:"h-4 w-4"})," Edit Profile"]})}),e.jsxs(m,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(f,{htmlFor:"profileFirstName",children:"First Name"}),e.jsx(S,{id:"profileFirstName",value:pe||n?.firstName||"",onChange:s=>Ae(s.target.value),"data-testid":"input-profile-first-name"})]}),e.jsxs("div",{children:[e.jsx(f,{htmlFor:"profileLastName",children:"Last Name"}),e.jsx(S,{id:"profileLastName",value:he||n?.lastName||"",onChange:s=>Ke(s.target.value),"data-testid":"input-profile-last-name"})]})]}),e.jsxs(c,{onClick:()=>X.mutate({firstName:pe||n?.firstName||"",lastName:he||n?.lastName||""}),disabled:X.isPending,"data-testid":"button-save-profile",children:[X.isPending?e.jsx(F,{className:"h-4 w-4 animate-spin mr-2"}):null,"Save Profile"]})]})]}),e.jsxs(d,{children:[e.jsx(w,{children:e.jsxs(C,{className:"flex items-center gap-2",children:[e.jsx(Fe,{className:"h-4 w-4"})," Change Password"]})}),e.jsxs(m,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(f,{htmlFor:"currentPassword",children:"Current Password"}),e.jsx(S,{id:"currentPassword",type:"password",value:H,onChange:s=>je(s.target.value),"data-testid":"input-current-password"})]}),e.jsxs("div",{children:[e.jsx(f,{htmlFor:"newPassword",children:"New Password"}),e.jsx(S,{id:"newPassword",type:"password",value:E,onChange:s=>ge(s.target.value),"data-testid":"input-new-password"})]}),e.jsxs("div",{children:[e.jsx(f,{htmlFor:"confirmPassword",children:"Confirm New Password"}),e.jsx(S,{id:"confirmPassword",type:"password",value:_,onChange:s=>ye(s.target.value),"data-testid":"input-confirm-password"})]}),e.jsxs(c,{onClick:()=>{if(E!==_){a({title:"Passwords do not match",variant:"destructive"});return}if(E.length<8){a({title:"Password must be at least 8 characters",variant:"destructive"});return}J.mutate({currentPassword:H,newPassword:E})},disabled:J.isPending||!H||!E||!_,"data-testid":"button-change-password",children:[J.isPending?e.jsx(F,{className:"h-4 w-4 animate-spin mr-2"}):null,"Change Password"]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsxs("p",{children:["Email: ",n?.email]}),e.jsxs("p",{children:["Role: ",q]})]})]}),!v&&e.jsx("div",{className:"mt-8 pt-4 border-t",children:e.jsx(c,{variant:"ghost",size:"sm",className:"text-destructive",onClick:()=>{confirm("Are you sure you want to leave this company?")&&Ze.mutate()},"data-testid":"button-leave-company",children:"Leave Company"})})]})]})}function Ps({companyId:n}){const{data:a,isLoading:u}=k({queryKey:["/api/corp/companies",n,"payment-history"],queryFn:async()=>{const r=await fetch(`/api/corp/companies/${n}/payment-history`);if(!r.ok)throw new Error("Failed to fetch payment history");return r.json()},enabled:!!n&&n>0});return u?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading payment history..."}):a?.length?e.jsxs("div",{className:"mt-6 space-y-3",children:[e.jsx("h3",{className:"text-lg font-semibold","data-testid":"text-payment-history-title",children:"Payment History"}),e.jsx("div",{className:"space-y-2",children:a.map(r=>e.jsx(d,{"data-testid":`card-invoice-${r.id}`,children:e.jsxs(m,{className:"flex items-center justify-between py-3 px-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm font-medium",children:["$",(r.amountPaid/100).toFixed(2)," ",r.currency.toUpperCase()]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:new Date(r.created*1e3).toLocaleDateString()})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{className:r.status==="paid"?"bg-green-100 text-green-700":"bg-gray-100 text-gray-600",variant:"secondary",children:r.status}),r.invoiceUrl&&e.jsx("a",{href:r.invoiceUrl,target:"_blank",rel:"noopener noreferrer","data-testid":`link-invoice-${r.id}`,children:e.jsx(Oe,{className:"h-3.5 w-3.5 text-muted-foreground hover:text-foreground"})})]})]})},r.id))})]}):null}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.