1import{j as e,H as T,P as k,b as O,C as S,a as R,B as x,d as P,a5 as D,bL as I,J as F,bM as A,I as L,a0 as H,r as g,bN as U,u as W,x as _,z as G}from"./index.kaq7r257.js";import{I as Y}from"./IconWarning.C7-yQ4Wn.js";import{C}from"./Checkbox.Dxi2QSuA.js";import{A as B}from"./Alert.x3aVpUxs.js";import{c as j,e as v,d as V,a as b}from"./array.BzGIDaHM.js";import{I as M}from"./IconChevron.Cli4eeSq.js";import{e as z}from"./regex.CzJ4SXqX.js";const J=j({gdprConsent:v().required("Must be checked").oneOf([!0],"Must be checked"),treatmentConsent:v().required("Must be checked").oneOf([!0],"Must be checked"),abilityConfirmation:v().required("Must be checked").oneOf([!0],"Must be checked")}),K={gdprConsent:!1,treatmentConsent:!1,abilityConfirmation:!1};function Q({initialValues:t,childName:s,onSubmit:h}){return e.jsxs("div",{className:"max-w-[684px] mx-auto my-20 space-y-6",children:[e.jsxs("div",{className:"text-center space-y-6",children:[e.jsxs(T,{level:1,children:["Consent to ",s,"'s' treatment"]}),e.jsxs("p",{children:[s,"âs wellbeing is our top priority. By consenting below, you allow us to support their growth in a safe and secure environment."]})]}),e.jsx(k,{initialValues:t||K,onSubmit:h,validationSchema:J,children:({handleChange:n,isSubmitting:i,errors:d,handleSubmit:u,values:o,submitCount:a})=>e.jsx("form",{onSubmit:u,noValidate:!0,children:e.jsxs(O,{children:[e.jsx(S,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs(C,{name:"gdprConsent",checked:o.gdprConsent,onChange:n,hideError:!0,children:["I consent to the"," ",e.jsx("a",{href:"https://www.helloself.com/privacy-promise",target:"_blank",rel:"noreferrer",children:"processing of data"})," ","regarding ",s,"'s care under GDPR."," "]}),e.jsxs(C,{name:"treatmentConsent",checked:o.treatmentConsent,onChange:n,hideError:!0,children:["I consent for ",s," to be assessed and treated by HelloSelf"]}),e.jsxs(C,{name:"abilityConfirmation",checked:o.abilityConfirmation,onChange:n,hideError:!0,children:["I confirm that ",s," has the intellectual and IT ability to engage in remote therapy and to use HelloSelf's platform technological features"]}),e.jsxs("p",{children:["By accepting these"," ",e.jsx("a",{href:"https://www.helloself.com/terms-and-conditions",target:"_blank",rel:"noreferrer",children:"terms and conditions"}),", I confirm that all legal guardians of ",s," are aware and consent to"," ",s,"'s treatment. Please contact us, if you have questions."]}),Object.keys(d).length&&a>0?e.jsx(B,{type:"error",children:e.jsxs("div",{className:"flex items-start space-x-2 gap-2",children:[e.jsx("div",{children:e.jsx(Y,{})}),e.jsxs("span",{children:["We need your full consent to your child's treatment before we can proceed. If you have any questions or concerns, please contact us at"," ",e.jsx("a",{href:"mailto:[email protected]",children:"[email protected]"}),"."]})]})}):null]})}),e.jsx(R,{children:e.jsx("div",{className:"flex justify-end items-center",children:e.jsx(x,{isProcessing:i,type:"submit",disabled:i,children:"Continue"})})})]})})})]})}const w=["gp","psychiatrist","school","familyMember","other","referringOrg"],$=()=>{const t=P(D),s=t.partnerCamhsChildren&&t.partnerCamhsChildren[0],h=!!s&&s.addToCareTeamOnLink==="REFERRING_PARTNER_ORG_UNIT",n=s==null?void 0:s.referralOrgUnit.id,i=((s==null?void 0:s.referralOrgUnit.fullName)||"unknown").split("/").slice(1).join(" / ");return{includeReferOrg:h,referOrgId:n,referOrgName:i}},X=j({careTeamChoice:V(j({recipientType:b().oneOf([...w]).required("Required"),selected:v().required("Required")})).length(w.length)});function Z({careTeamList:t,childName:s,onSubmit:h,onBack:n}){const i={careTeamList:t},{includeReferOrg:d,referOrgName:u}=$(),o=I.find(a=>a.recipientType==="referringOrg");return o&&(o.shown=d,o.label=u),e.jsxs("div",{className:"max-w-[684px] mx-auto my-20 space-y-6",children:[e.jsxs("div",{className:"text-center space-y-6",children:[e.jsxs(T,{level:1,children:["Create ",s,"'s care team"]}),e.jsxs("p",{children:["We recommend forming a care team, which is clinically proven to benefit progress, as our therapist can notify other invested parties to support ",s,"âs growth."]})]}
1),e.jsx(k,{initialValues:i,onSubmit:h,validationSchema:X,children:({isSubmitting:a,handleSubmit:f,setFieldValue:c,values:r})=>e.jsx("form",{onSubmit:f,noValidate:!0,children:e.jsxs(O,{children:[e.jsx(S,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(B,{type:"info",children:e.jsxs("div",{className:"flex items-start space-x-2 gap-2",children:[e.jsx("div",{children:e.jsx(F,{})}),s,"âs therapist will only share information when they feel itâs relevant, with who itâs relevant to. Youâll be notified when this happens."]})}),e.jsxs("p",{children:["I give my permission for letters regarding ",s," and family's needs to be sent to the following recipients:"]}),e.jsx(A,{name:"careTeamList",children:()=>I.filter(({shown:l})=>l).map(({label:l,recipientType:m},N)=>e.jsx(C,{name:`careTeamList.${N}.selected`,value:m,checked:r.careTeamList.indexOf(m)>-1,onChange:y=>{const p=r.careTeamList.slice(),E=y.currentTarget.value,q=p.indexOf(E);q>-1?p.splice(q,1):p.push(E),c("careTeamList",p)},hideError:!0,children:l},m))})]})}),e.jsx(R,{children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(x,{onClick:()=>n(r),variant:"tertiary",children:e.jsxs("div",{className:"flex items-center gap-2 text-green-500",children:[e.jsx(M,{}),e.jsx("span",{children:"Back"})]})}),e.jsx(x,{isProcessing:a,type:"submit",disabled:a,children:"Continue"})]})})]})})})]})}const ee=j({careTeam:V().of(j({recipientType:b().oneOf([...w]).required("Required"),recipientName:b(),recipientEmail:b().matches(z,"Invalid email")})).max(w.length)});function se({onSubmit:t,onBack:s,careTeam:h,childName:n,initialValues:i}){const d=I.filter(({recipientType:c})=>h.includes(c)),{referOrgId:u,referOrgName:o}=$(),f={careTeam:d.map(c=>{const r=((i==null?void 0:i.careTeam)||[]).find(({recipientType:m})=>m===c.recipientType),l={recipientType:c.recipientType,recipientName:(r==null?void 0:r.recipientName)||"",recipientEmail:(r==null?void 0:r.recipientEmail)||""};return c.recipientType==="referringOrg"&&(l.organisationId=u,l.recipientName=o),l})};return e.jsxs("div",{className:"max-w-[684px] mx-auto my-20 space-y-6",children:[e.jsxs("div",{className:"text-center space-y-6",children:[e.jsxs(T,{level:1,children:["Create ",n,"'s care team"]}),e.jsxs("p",{children:["We recommend forming a care team, which is clinically proven to benefit progress, as our therapist can notify other invested parties to support ",n,"âs growth."]})]}),e.jsx(k,{initialValues:f,onSubmit:t,validationSchema:ee,children:({handleChange:c,isSubmitting:r,handleSubmit:l,values:m})=>e.jsx("form",{onSubmit:l,noValidate:!0,children:e.jsxs(O,{children:[e.jsx(S,{children:e.jsxs("div",{className:"space-y-6",children:[d.length===0?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Youâve not selected anybody for ",n,"âs Care Team."]}),e.jsx("p",{children:"If youâd like to add people at a later date please get in touch with the therapist directly."})]}):e.jsxs("p",{children:["Please add the details of ",n,"âs Care Team below. If you donât have these now, you can add them at a later date."," "]}),e.jsx(A,{name:"careTeam",children:()=>d.map(({label:N,recipientType:y},p)=>e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{children:N}),y!=="referringOrg"&&e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"flex-1",children:e.jsx(L,{type:"text",name:`careTeam.${p}.recipientName`,onChange:c,value:m.careTeam[p].recipientName,label:"Name",hideValidationIcon:!0})}),e.jsx("div",{className:"flex-1",children:e.jsx(L,{type:"text",name:`careTeam.${p}.recipientEmail`,onChange:c,value:m.careTeam[p].recipientEmail,label:"Email address",hideValidationIcon:!0})})]})]},y))})]})}),e.jsx(R,{children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(x,{onClick:()=>s(m),variant:"tertiary",children:e.jsxs("div",{className:"flex items-center gap-2 text-green-500",children:[e.jsx(M,{}),e.jsx("span",{children:"Back"})]})}),e.jsx(x,{isProcessing:r,type:"submit",disabled:r,children:"Submit"})]})})]})})})]})}function re({childName:t}){return e.jsxs("div",{className:"max-w-[684px] mx-auto my-20 space-y-6 text-center",children:[e.jsx(T,{level:1,children:"Thank y
1ou"}),e.jsxs("p",{children:["Thank you for giving your consent, we'll now begin pairing ",t," with a therapist. "]}),e.jsx("p",{children:"We are setting up your guardian account and will be in touch when we have found a therapist match."})]})}const te=async t=>await H.post("partners-write","camhs-parent-consent",t);function he(){const[t,s]=g.useState(1),[h,n]=g.useState(),[i,d]=g.useState([]),[u,o]=g.useState(),a=P(U),f=W(),c=_();if(!a){f.push("/dashboard");return}if(t===1&&a.treatmentConsentGivenAt){f.push("/dashboard");return}switch(t){case 1:return e.jsx(Q,{initialValues:h,childName:a.referralName,onSubmit:r=>{n(r),s(2)}});case 2:return e.jsx("div",{children:e.jsx(Z,{careTeamList:i,childName:a.referralName,onSubmit:r=>{d(r.careTeamList),s(3)},onBack:r=>{d(r.careTeamList),s(1)}})});case 3:return i?e.jsx(se,{initialValues:u,childName:a.referralName,careTeam:i,onSubmit:async r=>{const l={partnerCamhsChildId:a.partnerCamhsChildId,consents:r.careTeam};await te(l),c(G()),s(4)},onBack:r=>{o(r),s(2)}}):void 0;case 4:return e.jsx(re,{childName:a.referralName})}}export{he as default}; 2//# sourceMappingURL=CamhsConsentRoute.CN1uKkGI.js.map
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.