"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[315],{6835:function(e,t,r){r.d(t,{LA:function(){return s},ez:function(){return o},j3:function(){return n}});var l=r(7387);let a="/surveys/",n=async()=>{let{data:e}=await (0,l.ZP)("".concat(a,"incomplete/"));return e},s=async e=>{let{data:t}=await (0,l.ZP)("".concat(a).concat(e,"/"));return t},o=async(e,t)=>{let{data:r}=await (0,l.ZP)("".concat(a).concat(e,"/"),{method:"PUT",data:t});return r}},989:function(e,t,r){r.d(t,{E:function(){return I},o:function(){return E}});var l=r(2322),a=r(2350),n=r(7661),s=r(6835),o=r(2308),i=r(9630),c=r(651),u=r(2716);let d=e=>{let{size:t,stroke:r,fill:a,onPress:n}=e;return r=r||"currentColor",a=a||"none",(0,l.jsx)(c.Z,{activeOpacity:1,onPress:n,children:(0,l.jsx)(i.G7,{style:{width:t||24,height:t||24},children:(0,l.jsx)(u.Svg,{width:"100%",height:"100%",viewBox:"0 0 24 24",preserveAspectRatio:"xMidYMid meet",fill:a,stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"feather feather-star",children:(0,l.jsx)(u.Polygon,{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})})})})};var h=e=>{let{rating:t=0,size:r=48,filledProps:a,emptyProps:n,onStarPress:s}=e;a=Object.assign({fill:"currentColor"},a),n=Object.assign({stroke:"currentColor"},n);let o=e=>{s&&s(e)};return(0,l.jsx)(i.G7,{className:"flex flex-row space-x-1.5",children:Array.from({length:5},(e,s)=>(0,l.jsx)(d,{onPress:()=>o(s+1),size:r,...s<t?a:n},"star-".concat(s+1)))})},m=r(8992),x=r(1783),f=r(110),p=r(7638),b=r(9991),g=r(2524),v=r.n(g),y=r(2784),w=r(7450),j=r(6769);let N="not_a_match",_="other",k={positive:{question:"What was your favorite part?",limit:3,options:[{label:"I received helpful knowledge and guidance",value:"helpful_knowledge"},{label:"I felt heard and understood",value:"heard_and_understood"},{label:"My practitioner's positive and supportive attitude",value:"positive_attitude"},{label:"I feel hopeful about improving my health",value:"hopeful"},{label:"My practitioner really got to know me",value:"got_to_know_me"},{label:"My recommendations are clear and manageable",value:"clear_and_manageable"},{label:"Other",value:_}]},neutral:{question:"What could we have done better?",limit:3,options:[{label:"My practitioner did not seem like a match for me",value:N},{label:"I did not receive helpful knowledge or guidance",value:"not_helpful_knowledge"},{label:"I did not feel heard or understood",value:"not_heard_or_understood"},{label:"My recommendations were not in depth enough for me",value:"not_in_depth"},{label:"Functional medicine doesn't sound like the right approach for me",value:"not_right_approach"},{label:"My recommendations were too overwhelming for me",value:"too_overwhelming"},{label:"Other",value:_}]},negative:{question:"What could we have done better?",limit:1,options:[]}};var P=r(810);let C="fixed h-screen inset-0 flex-1 items-center p-4",{useParams:M}=(0,w.X)(),G=e=>{let{survey:t}=e,{push:r}=(0,j.t)(),{clearPortal:a}=(0,x.vI)(),n=Intl.DateTimeFormat().resolvedOptions().timeZone,s=(0,p.Hg)(t.appointment.date,n,{dateFormat:"MMMM d"}).date;return(0,l.jsx)(o.Z,{title:"Your appointment on ".concat(s),containerClassName:C,body:(0,l.jsxs)(i.G7,{className:"mt-6 flex-1 flex-col items-center space-y-4",children:[(0,l.jsx)(i.G7,{className:"mt-4 flex items-center space-y-6",children:(0,l.jsx)(m.P,{className:"text-earth text-center text-lg font-bold",children:"\uD83C\uDF89 Thanks for your feedback!"})}),(0,l.jsxs)(m.P,{className:"text-earth text-center",children:["If there's anything else you'd like to share, please feel free to reach out to us at ",f.Xy]})]}),buttons:(0,l.jsx)(l.Fragment,{children:(0,l.jsx)(m.zx,{buttonClassName:"w-full bg-citrus border border-transparent hover:bg-white hover:border-earth !rounded-full text-center",textClassName:"!text-earth !font-bold !text-sm text-center",onPress:()=>{r(b._j.APPOINTMENTS.path),a()},text:"Return to Portal"})})})},S=e=>{let{survey:t,prefilledRating:r,onSubmit:n}=e,[c,u]=(0,y.useState)(r||0),[d,x]=(0,y.useState)(null),[f,b]=(0,y.useState)([]),[g,w]=(0,y.useState)(""),[j,M]=(0,y.useState)(!1),[G,S]=(0,y.useState)(""),E=(0,a.D)(async e=>(0,s.ez)(t.id,e)),I=d?k[d]:null,F=c>0&&(f.length>0||g.length>0)&&!E.isLoading,O=!E.isLoading,T=Intl.DateTimeFormat().resolvedOptions().timeZone,q=(0,p.Hg)(t.appointment.date,T,{dateFormat:"MMMM d"}).date,z="Please select a rating.",Z="Please share your feedback with us.",A=v()("w-full mb-1 rounded-lg p-4 bg-white text-base","border border-gray-300","focus:outline-none focus:ring-0 focus:border-skye"),L=e=>{u(e),e>3?"positive"!==d&&(b([]),w(""),x("positive")):e>1?"neutral"!==d&&(b([]),w(""),x("neutral")):"negative"!==d&&(b([]),w(""),x("negative"))},R=e=>{I&&(I.limit&&f.length===I.limit&&b(e=>e.slice(0,-1)),b(t=>t.includes(e)?t.filter(t=>t.value!==e.value):[...t,e]))},B=async e=>{let{skipped:t}=e;if(!I){S(Z);return}if(!t){if(c){if(I.options.length>0&&0===f.length||(0===I.options.length||f.find(e=>e.value===_))&&0===g.length){S(Z);return}}else{S(z);return}}t||M(!0);let r=f.filter(e=>e.value!==_).map(e=>e.label);g.length>0&&r.push(g);let l={skipped:t,rating:c,feedback:r.join(", "),open_to_change_practitioner:!!f.find(e=>e.value===N)};await E.mutateAsync(l,{onSuccess:()=>{M(!1),w(""),n(l)},onError:()=>{M(!1),n(l)}}).catch(e=>{console.error(e),M(!1),n(l)})};return(0,y.useEffect)(()=>{c&&G===z?S(""):f.length>0&&G===Z&&S("")},[c,f,G]),(0,l.jsx)(o.Z,{title:"Your appointment on ".concat(q),containerClassName:C,body:(0,l.jsxs)(i.G7,{className:"flex-3 mt-6 flex-col space-y-4",children:[(0,l.jsxs)(i.G7,{className:"mt-4 flex items-center space-y-6",children:[(0,l.jsxs)(m.P,{className:"text-earth text-center text-lg font-bold",children:["How was your appointment with ",t.practitioner_name,"?"]}),(0,l.jsx)(h,{rating:c,onStarPress:e=>L(e),size:32,filledProps:{fill:"#36190B",stroke:"#36190B"},emptyProps:{stroke:"#EEE"}}),I&&(0,l.jsxs)(i.G7,{className:"mt-4 flex w-full",children:[(0,l.jsx)(m.P,{className:"text-earth text-lg font-bold",children:I.question}),I.limit>1&&(0,l.jsxs)(m.P,{className:"text-earth text-brown-body my-1 text-sm font-medium italic",children:["Select up to ",I.limit]})||null,(0,l.jsx)(i.G7,{className:"mt-4 flex w-full flex-row flex-wrap gap-y-4",children:I.options.map((e,t)=>(0,l.jsx)(i.G7,{className:v()("group flex items-center justify-center",f.includes(e)&&"bg-earth","border-stone hover:bg-earth rounded-lg border px-4 py-2 shadow-sm","w-[calc(50%-8px)]",t%2==0?"mr-4":""),children:(0,l.jsx)(P.Z,{onPress:()=>R(e),className:"h-full w-full",children:(0,l.jsx)(m.P,{className:v()("text-earth font-medium group-hover:text-white",f.includes(e)&&"text-white"),children:e.label})})},e.value))}),0===I.options.length||f.find(e=>e.value===_)?(0,l.jsx)(i.G7,{className:"mt-4 flex w-full",children:(0,l.jsx)(i.oi,{multiline:!0,numberOfLines:2,maxLength:250,className:A,value:g,placeholder:"Type your feedback here",placeholderTextColor:"#A0AEC0",keyboardType:"default",onChangeText:w})}):null]}),G&&(0,l.jsx)(m.P,{className:"w-full text-center text-sm text-red-500",children:G})]}),(0,l.jsx)(i.G7,{className:"",children:(0,l.jsx)(i.G7,{className:"my-4 h-[2px] bg-gray-200"})}),(0,l.jsx)(m.P,{className:"text-earth text-center",children:"Honest reviews allow us to keep improving the quality of your membership experience. Your feedback will not be shared directly with your practitioner."})]}),buttons:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(m.zx,{disabled:!O,buttonClassName:v()("flex w-full bg-white border border-transparent !rounded-full text-center",O?"hover:bg-white hover:opacity-50":"opacity-10"),textClassName:"!text-earth !font-bold !text-sm text-center underline underline-offset-4",onPress:()=>B({skipped:!0}),text:"Skip"}),(0,l.jsx)(m.zx,{disabled:!F,buttonClassName:v()("flex w-full border border-transparent !rounded-full text-center",F?"bg-citrus hover:bg-white hover:border-earth":"bg-gray-50"),textClassName:v()("!font-bold !text-sm text-center",F?"!text-earth":"!text-gray-400"),onPress:()=>B({skipped:!1}),text:(0,l.jsxs)(i.G7,{className:"flex flex-row items-center justify-center",children:[(0,l.jsx)(m.P,{className:"text-sm",children:"Send Review"}),(0,l.jsx)(i.G7,{className:v()("ml-2",!j&&"hidden"),children:(0,l.jsx)(i.aN,{size:"small",color:"#36190B"})})]})})]})})},E=e=>{let{survey:t,prefilledRating:r}=e,[a,n]=(0,y.useState)(!1),s=t.completed_at||a;return(0,l.jsx)(i.G7,{children:s?(0,l.jsx)(G,{survey:t}):(0,l.jsx)(S,{survey:t,prefilledRating:r,onSubmit:()=>n(!0)})})};function I(){let{setPortalContent:e}=(0,x.vI)(),{push:t}=(0,j.t)(),{params:{survey_id:r,rating:a}}=M(),{data:o,isInitialLoading:c,isError:u}=(0,n.a)(r?{queryKey:["surveys",r],queryFn:()=>(0,s.LA)(r)}:{queryKey:[],queryFn:()=>Promise.resolve(null)});return((0,y.useEffect)(()=>{o&&e((0,l.jsx)(E,{survey:o.survey,prefilledRating:a}))},[o]),c)?(0,l.jsx)(i.G7,{className:"bg-cream mt-[20%] flex h-screen items-center",children:(0,l.jsx)(i.aN,{size:"large",color:"#36190B"})}):(u&&t(b._j.OVERVIEW.path),null)}}}]);