PageSourceSearch

https://care.soberpedia.ai/assets/PatientCustomLinkPage-C3obI1A_.js

js soberpedia.ai collected 2026-10-05 15:08:35 UTC 6,411 bytes, 1 lines download raw bytes

1import{r as t,j as e,L as P,u as G,d as M}from"./react-vendor-CU6Sz31W.js";import{u as E,dM as Y,al as I,b as O,au as H,g1 as D,ie as K,g2 as V,g9 as q,E as J,h as Q,i as x,S as C,l as W,g as $,ig as X,d as Z,ih as ee}from"./index-DEXJEDAi.js";import{R}from"./RoutePageHeader-9W0v4VlT.js";import"./firebase-w6DYUbFN.js";import"./payment-icons-Daq1K3F1.js";import"./RoutePageHeaderContent-FkxdZGox.js";const se=$("managePatientOnboarding"),te=1500;function ae({item:o,navigate:b}){const{userDoc:i,isTenantProfilePreview:g}=E(),{hasBlockingGates:r}=Y(),{branding:d}=I(),h=(d==null?void 0:d.accentColor)||O,m=t.useRef(!1),[s,p]=t.useState(null),[a,N]=t.useState(!1),[j,w]=t.useState(""),[S,k]=t.useState(!1),[T,v]=t.useState(!1),l=g?"Starting a form is disabled in preview. Patients see the form itself here.":i!=null&&i.clientId?"":"This link is only available to patients of a client organization.",u=t.useCallback(async()=>{var f;if(!(a||l)){m.current=!0,N(!0),w("");try{const n=H.currentUser;if(!n)throw new Error("Not authenticated");const U=await n.getIdToken(),y=await fetch(se,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${U}`},body:JSON.stringify({action:"openPatientSidebarClientForm",formId:o.formId,itemId:o.id})}),c=await y.json().catch(()=>null);if(!y.ok||!(c!=null&&c.success))throw new Error(y.status===404||y.status===409?"This form is no longer available.":(c==null?void 0:c.error)||"Unable to open this form.");if(!((f=c.data)!=null&&f.form))throw new Error("This form is no longer available.");k(!1),v(!1),p(c.data.form)}catch(n){w((n==null?void 0:n.message)||"Unable to open this form.")}finally{N(!1)}}},[o.formId,o.id,a,l]),z=t.useCallback((f={})=>{const n=D(s)?K(V(f.productSelectorSelections)):null;if(p(null),v(!1),k(!0),n){b(n);return}q.success("Your form has been submitted.")},[s,b]),_=t.useCallback(()=>{p(null),v(!0)},[]);t.useEffect(()=>{m.current||l||r||(m.current=!0,u())},[r,u,l]);const[A,L]=t.useState(!1);t.useEffect(()=>{if(m.current||l||!r)return;const f=setTimeout(()=>L(!0),te);return()=>clearTimeout(f)},[r,l]);const F=A&&r&&!a,B=!j&&!S&&!T&&!l&&!F;return e.jsxs("main",{className:"app-page-shell space-y-4 sm:space-y-6",children:[e.jsx(R,{title:o.label}),j?e.jsx(J,{reason:"error",title:"This form could not be opened",description:j,action:{label:"Try again",onClick:u}}):s?null:e.jsx("div",{className:"rounded-xl border border-subtle bg-surface-raised p-6 max-lg:p-4",children:S?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Q,{className:"mt-0.5 size-5 shrink-0 text-[var(--status-success-text)]","aria-hidden":"true"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-content-primary",children:"Submitted"}),e.jsx("p",{className:"text-sm leading-relaxed text-content-secondary",children:"Your response was sent to your care team. They will follow up if anything is needed."})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(x,{type:"button",variant:"outline",size:"sm",onClick:u,disabled:a,children:[a?e.jsx(C,{size:"sm",label:"Opening form"}):null,"Submit another"]}),e.jsx(x,{asChild:!0,variant:"ghost",size:"sm",children:e.jsx(P,{to:"/forms",children:"View your forms"})})]})]}):T?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm leading-relaxed text-content-secondary",children:"You closed this form before submitting it. Your answers were saved on this device, so you can pick up where you left off."}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(x,{type:"button",size:"sm",className:"text-white",style:{backgroundColor:h},onClick:u,disabled:a,children:[a?e.jsx(C,{size:"sm",label:"Opening form"}):null,"Resume form"]}),e.jsx(x,{asChild:!0,variant:"ghost",size:"sm",children:e.jsx(P,{to:"/forms",children:"View your forms"})})]})]}):F?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm leading-relaxed text-content-secondary",children:"Your care team has something else waiting for you, so this form has not opened yet. Finish that first, or open this form now and come back to it."}),e.jsx(x,{type:"button",size:"sm",className:"text-white",style:{backgroundColor:h},onClick:u,children:"Open this form now"})]}):B?e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(C,{size:"lg",label:"Opening form",delayMs:0,style:{color:h}}),e.jsx("p",{className:"text-sm leading-relaxed text-content-secondary",children:"Opening your form..."})]}):e.jsx("p",{className:"text-sm leading-relaxed text-content-secondary",children:l})}),s?e.jsx(W,{requiredForms:[s],purchasedProducts:[],reusableForm:null,prefillByFormId:{},showWelcomeFiller:!1,lockFormQueue:!0,submissionSource:"patient_sidebar",onComplete:z,onCancel:_}):null]})}function de(){var a;const{itemId:o}=G(),b=M(),{clientData:i,loading:g,userDoc:r}=E(),{branding:d}=I(),h=(d==null?void 0:d.accentColor)||O,m=(a=i==null?void 0:i.patientSidebar)==null?void 0:a.customItems,s=t.useMemo(()=>X({patientSidebar:{customItems:m}},o),[m,o]),p=!g&&!i&&!!(r!=null&&r.clientId);return g||p?e.jsx("div",{className:"flex min-h-[50vh] items-center justify-center",children:e.jsx(Z,{className:"size-6 animate-spin",style:{color:h}})}):s?s.target===ee.FORM?e.jsx(ae,{item:s,navigate:b}
1,s.id):e.jsxs("main",{className:"app-page-shell space-y-4 sm:space-y-6",children:[e.jsx(R,{title:e.jsx("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",className:"inline-block max-w-full truncate text-current hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 focus-visible:ring-offset-white dark:focus-visible:ring-offset-slate-950",children:s.label})}),e.jsx("iframe",{src:s.url,title:s.label,className:"h-[calc(100dvh-12rem)] min-h-[36rem] w-full border-0 bg-surface-raised",sandbox:"allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"})]}):e.jsx("main",{className:"app-page-shell",children:e.jsxs("div",{className:"rounded-xl border border-subtle bg-surface-raised p-6 text-center",children:[e.jsx("h2",{className:"font-display text-2xl font-semibold text-content-primary",children:"Link unavailable"}),e.jsx("p",{className:"mt-2 text-sm text-content-secondary",children:"This patient portal link is no longer available."})]})})}export{de 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.