PageSourceSearch

https://app.goforma.com/assets/ViewAsClient-CHXcDK4Z-r2.js

js goforma.com collected 2026-09-26 00:14:14 UTC 5,024 bytes, 1 lines download raw bytes

1import{u as k,b as P,a as A,e as u,ab as f,s as j,r as F,d as E,j as e,S as y,Q as B,B as m,L as N,h as S,aQ as q,V as L,Z as Q}from"./index-B3qMwixp-r2.js";import{P as R}from"./PersonCell-DqGXF8oB-r2.js";import{C as b}from"./circle-user-round-D67sPXNE-r2.js";function T(){var p,g;const{companyRec:i=""}=k(),d=P(),x=A(),r=u({mutationFn:async s=>{const a=await f.post("/ops/view-as/ensure-user",{company_rec:i,contact_rec:s});if(!(a!=null&&a.user_id))throw new Error("Could not resolve an account for that contact.");return j(a.user_id,{company_id:i})},onSuccess:()=>{x.clear(),d("/")}}),[w,v]=F.useState(!1),{data:t,isLoading:C,isError:_,error:c}=E({queryKey:["ops","company-clients",i],queryFn:()=>f.get("/ops/company-clients",{query:{company_rec:i}}),enabled:!!i}),n=u({mutationFn:s=>j(s,{company_id:i}),onSuccess:()=>{x.clear(),d("/")}}),o=((t==null?void 0:t.candidates)??[]).filter(s=>s.has_login);!w&&o.length===1&&!n.isPending&&!n.isError&&(v(!0),n.mutate(o[0].user_id));const l=s=>e.jsx("div",{className:"mx-auto max-w-lg px-4 py-10",children:e.jsx(L,{children:e.jsx(Q,{className:"p-6 flex flex-col gap-4",children:s})})});if(C||n.isPending)return l(e.jsxs("div",{className:"flex items-center gap-3 text-gf-mid",children:[e.jsx(y,{className:"text-gf-teal h-5 w-5"}),n.isPending?"Opening their dashboard…":"Finding the client…"]}));if(_)return l(e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(B,{className:"mt-0.5 h-5 w-5 text-status-danger-fg"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-heading-sm text-gf-slate m-0",children:"Couldn’t look that company up"}),e.jsx("p",{className:"text-body-sm text-gf-mid mt-1 m-0",children:c==null?void 0:c.message})]})]}),e.jsx(m,{asChild:!0,variant:"secondary",size:"sm",children:e.jsx(N,{to:"/ops/companies",className:"no-underline",children:"Back to companies"})})]}));const h=(t==null?void 0:t.company_name)||i;if(o.length===0){const s=(t==null?void 0:t.candidates)??[];return l(e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(S,{className:"mt-0.5 h-5 w-5 text-gf-mid"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-heading-sm text-gf-slate m-0",children:h}),e.jsx("p",{className:"text-body-sm text-gf-mid mt-1 m-0",children:s.length===0?"No contacts are linked to this company in Airtable, so there’s no dashboard to open.":"Nobody on this company has a dashboard login, so there’s nothing to view as."}),((t==null?void 0:t.staff_skipped)??0)>0&&e.jsx("p",{className:"text-body-sm text-gf-mid mt-2 m-0",children:"A GoForma team account is linked here — that’s us, not a client dashboard, so it isn’t offered."})]})]}),s.length>0&&e.jsx("ul",{className:"list-none m-0 p-0 flex flex-col gap-2",children:s.map(a=>e.jsxs("li",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("span",{className:"text-body-sm text-gf-slate",children:[a.name||a.email," ",e.jsx("span",{className:"text-caption text-gf-muted",children:"· no login"})]}),e.jsxs(m,{size:"sm",variant:"secondary",disabled:r.isPending||!a.email,onClick:()=>r.mutate(a.contact_rec),children:[r.isPending?e.jsx(y,{className:"w-3.5 h-3.5"}):e.jsx(b,{className:"w-3.5 h-3.5"}),"Create a login and view as"]})]},a.contact_rec))}),r.isError&&e.jsx("p",{className:"text-body-sm text-status-danger-fg m-0",children:((p=r.error)==null?void 0:p.message)||"Could not open that client’s dashboard."}),e.jsx("p",{className:"text-caption text-gf-muted m-0",children:"Most clients haven’t created a dashboard login yet, so this is expected. Creating one here sends them nothing — it just makes their dashboard openable for testing."}),e.jsx(m,{asChild:!0,variant:"secondary",size:"sm",children:e.jsx(N,{to:"/ops/companies",className:"no-underline",children:"Back to companies"})})]}))}return l(e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-heading-sm text-gf-slate m-0",children:h}),e.jsx("p",{className:"text-body-sm text-gf-mid mt-1 m-0",children:"More than one person here has a login. Whose dashboard do you want to see?"})]}),n.isError&&e.jsx("p",{className:"text-body-sm text-status-danger-fg m-0",children:(g=n.error)==null?void 0:g.message}),e.jsx("ul",{className:"list-none m-0 p-0 flex flex-col gap-1.5",children:o.map(s=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>
1n.mutate(s.user_id),className:"flex w-full items-center gap-3 rounded-md border border-gf-border px-3 py-2.5 text-left hover:border-gf-teal hover:bg-gf-light",children:[e.jsx(R,{name:s.name||s.email}),e.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-caption font-semibold text-gf-teal",children:["View as ",e.jsx(q,{className:"h-3.5 w-3.5"})]})]})},s.contact_rec))}),e.jsxs("p",{className:"text-caption text-gf-muted m-0 inline-flex items-center gap-1.5",children:[e.jsx(b,{className:"h-3.5 w-3.5"}),"You’ll see their dashboard as them. A banner stays on screen until you stop."]})]}))}export{T as ViewAsClientPage};

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.