"use strict";(self.webpackChunkkns_reports=self.webpackChunkkns_reports||[]).push([[27854],{27854:(e,i,n)=>{n.r(i),n.d(i,{default:()=>y});var s=n(65043),a=n(96446),l=n(68903),t=n(85865),r=n(11906),d=n(63516),o=n(74605),u=n(14256),c=n(78492),h=n(14556),m=n(73033),p=n(73216),x=n(67784),v=n(6994),j=n(70579);const y=()=>{const{EnquiryID:e,LoginuserId:i}=(0,p.g)();console.log("LoginuserId",i);const n=s.useRef(null),y=(0,h.wA)(),[f,b]=(0,s.useState)({}),[A,g]=(0,s.useState)(m.Ik().shape({})),k=(0,h.d4)((e=>{var i;return null===(i=e.crm.getSiteVisitFeedbackQuestion)||void 0===i?void 0:i.data}));(0,s.useEffect)((()=>{const e={userID:i};y((0,v.BlY)(e))}),[]),(0,s.useEffect)((()=>{if(k&&k){const e={},i={};k.forEach((n=>{e[n.id]="",n.value_type,i[n.id]=m.Yj().required("This field is required")})),b(e),g(m.Ik().shape(i))}}),[k]);const I=(0,p.Zp)(),_=()=>{b({})};return(0,j.jsx)(a.A,{sx:{height:"100%",width:"100%",overflow:"auto"},children:(0,j.jsxs)("div",{className:"component-list",children:[(0,j.jsx)(l.Ay,{container:!0,className:"d-flex justify-content-between align-items-center",py:1,children:(0,j.jsx)(l.Ay,{item:!0,className:"common-header-label",children:"Feedback Form"})}),(0,j.jsx)(d.l1,{enableReinitialize:!0,innerRef:n,initialValues:f,validationSchema:A,onSubmit:async(n,s)=>{const a=k&&k.map((e=>"MultipleChoice"===e.value_type?{questionID:e.id,optionID:n[e.id],answerValue:""}:{optionID:"",questionID:e.id,answerValue:n[e.id]})),l={userID:i,enquiryID:e||"",feedbackItems:a};s.setSubmitting(!0),await y((0,v.aON)(l)),_(),I(`/enquiry-profile/Feedback/${e}/${i}/thankyou`)},children:e=>{let{errors:i,handleSubmit:n,handleChange:s,setFieldValue:h,handleBlur:m,isSubmitting:p,isValid:v,touched:y,values:f}=e;return(0,j.jsx)(d.lV,{onSubmit:n,children:(0,j.jsx)(j.Fragment,{children:(0,j.jsxs)(l.Ay,{className:"component-form",children:[(0,j.jsxs)(l.Ay,{container:!0,children:[k&&k.map((e=>(0,j.jsxs)(l.Ay,{item:!0,xs:12,sm:12,md:12,lg:12,p:1,children:[(0,j.jsx)(l.Ay,{container:!0,children:(0,j.jsx)(l.Ay,{item:!0,xs:12,sm:12,md:12,lg:12,p:1,children:(0,j.jsxs)(t.A,{variant:"h6",children:[(0,j.jsxs)("span",{children:[e&&e.id,": "]}),e&&e.question_name+" ? *"]})})}),"MultipleChoice"===e.value_type?(0,j.jsx)(d.D0,{name:e.id,children:i=>{let{field:n}=i;return(0,j.jsx)(c.A,{...n,name:e.id,value:f[e.id],onChange:s,onBlur:m,children:e.value&&e.value.map((e=>(0,j.jsx)(o.A,{value:e.option_value_id,control:(0,j.jsx)(u.A,{}),label:e.option_value},e.option_value_id)))})}}):(0,j.jsx)(d.D0,{as:x.A,id:e.id,fullWidth:!0,size:"small",onBlur:m,name:e.id,value:f[e.id],onChange:s,label:e.question_name+" *",variant:"outlined",helperText:y[e.id]&&i[e.id],error:y[e.id]&&Boolean(i[e.id])}),"MultipleChoice"===e.value_type&&y[e.id]&&i[e.id]&&(0,j.jsx)(t.A,{variant:"body2",color:"error",children:i[e.id]})]},e.id))),(0,j.jsxs)(l.Ay,{item:!0,xs:12,sm:12,md:12,lg:12,p:1,children:[(0,j.jsx)(t.A,{variant:"h6",style:{color:"red"},children:"Disclaimer *"}),(0,j.jsx)(t.A,{variant:"body1",children:"Your feedback is valuable to us. Please provide your comments and suggestions in the form. We appreciate your input and strive to improve based on your feedback."})]})]}),(0,j.jsx)(l.Ay,{className:"d-flex justify-content-center ",p:2,children:(0,j.jsx)(a.A,{children:(0,j.jsx)(r.A,{type:"submit",text:"SAVE",variant:"contained",size:"medium",disabled:p,children:"SAVE"})})})]})})})}})]})})}}}]);
//# sourceMappingURL=27854.c3d931a8.chunk.js.map