"use strict";(self.webpackChunkkns_reports=self.webpackChunkkns_reports||[]).push([[50570],{50570:(e,i,n)=>{n.r(i),n.d(i,{default:()=>_});var l=n(65043),s=n(68903),a=n(11906),t=n(85865),r=n(96446),d=n(63516),o=n(74605),c=n(14256),u=n(78492),h=n(14556),m=n(73033),p=n(73216),x=n(66675),v=n(67784),j=n(6994),A=n(37965),y=n(77739),f=n(96801),g=n(70579);const _=e=>{const i=(0,p.zy)().state,n=i._original;console.log("EPRowData",i),console.log("EPData",n);const _=l.useRef(null),b=(0,h.wA)(),[k,S]=(0,l.useState)({}),[q,C]=(0,l.useState)(m.Ik().shape({})),D=(0,h.d4)((e=>{var i;return null===(i=e.crm.getSiteVisitFeedbackQuestion)||void 0===i?void 0:i.data})),V=(0,f.Gq)("enuseloc"),w=V&&Object.keys(V).length>0?V.user_id:null,z=n.enquiry_id||"";(0,l.useEffect)((()=>{b((0,j.BlY)(null))}),[b]),(0,l.useEffect)((()=>{if(D){const e={},i={};D.forEach((n=>{e[n.id]="",n.value_type,i[n.id]=m.Yj().required("This field is required")})),S(e),C(m.Ik().shape(i))}}),[D]);const I=(0,p.Zp)(),E=()=>{I(-1)},F=()=>{S({})};return(0,g.jsxs)("div",{className:"component-list",children:[(0,g.jsx)(s.Ay,{container:!0,className:"align-items-center",children:(0,g.jsxs)(s.Ay,{item:!0,xs:12,sm:12,md:6,lg:3,className:"d-flex justify-content-start ",children:[(0,g.jsxs)(a.A,{style:{marginTop:"22px"},onClick:E,children:[" ",(0,g.jsx)(x.A,{})]}),(0,g.jsx)("p",{style:{marginTop:"38px"},children:"Feedback Form"}),"\xa0\xa0",(0,g.jsx)(g.Fragment,{children:(0,g.jsx)(y.A,{title:"Share",arrow:!0,children:(0,g.jsx)(A.A,{sx:{cursor:"pointer",color:"#765ae8",marginTop:"35px"},onClick:async()=>{I(`/enquiry-profile/Feedback/${z}/${w}`)},title:"Add"})})})]})}),(0,g.jsx)(d.l1,{enableReinitialize:!0,innerRef:_,initialValues:k,validationSchema:q,onSubmit:async(e,n)=>{var l,s;const a=D.map((i=>"MultipleChoice"===i.value_type?{questionID:i.id,optionID:e[i.id],answerValue:""}:{optionID:"",questionID:i.id,answerValue:e[i.id]})),t={enquiryID:null!==i&&void 0!==i&&null!==(l=i._original)&&void 0!==l&&l.enquiry_id?null===i||void 0===i||null===(s=i._original)||void 0===s?void 0:s.enquiry_id:"",feedbackItems:a};n.setSubmitting(!0),await b((0,j.aON)(t)),F(),E()},children:e=>{let{errors:i,handleSubmit:n,handleChange:l,handleBlur:h,isSubmitting:m,isValid:p,touched:x,values:j}=e;return(0,g.jsx)(d.lV,{onSubmit:n,children:(0,g.jsx)(g.Fragment,{children:(0,g.jsxs)(s.Ay,{className:"component-form",children:[(0,g.jsx)(s.Ay,{container:!0,children:D.map((e=>(0,g.jsxs)(s.Ay,{item:!0,xs:12,sm:12,md:12,lg:12,p:1,children:[(0,g.jsx)(s.Ay,{container:!0,children:(0,g.jsx)(s.Ay,{item:!0,xs:12,sm:12,md:12,lg:12,p:1,children:(0,g.jsxs)(t.A,{variant:"h6",children:[(0,g.jsxs)("span",{children:[e&&e.id,": "]}),e&&e.question_name+" ? *"]})})}),"MultipleChoice"===e.value_type?(0,g.jsx)(d.D0,{name:e.id,children:i=>{let{field:n}=i;return(0,g.jsx)(u.A,{...n,name:e.id,value:j[e.id],onChange:l,onBlur:h,children:e.value.map((e=>(0,g.jsx)(o.A,{value:e.option_value_id,control:(0,g.jsx)(c.A,{}),label:e.option_value},e.option_value_id)))})}}):(0,g.jsx)(d.D0,{as:v.A,id:e.id,fullWidth:!0,size:"small",onBlur:h,name:e.id,value:j[e.id],onChange:l,label:e.question_name+" *",variant:"outlined",helperText:x[e.id]&&i[e.id],error:x[e.id]&&Boolean(i[e.id])}),"MultipleChoice"===e.value_type&&x[e.id]&&i[e.id]&&(0,g.jsx)(t.A,{variant:"body2",color:"error",children:i[e.id]})]},e.id)))}),(0,g.jsx)(s.Ay,{className:"d-flex justify-content-center ",p:2,children:(0,g.jsx)(r.A,{children:(0,g.jsx)(a.A,{type:"submit",text:"SAVE",variant:"contained",size:"medium",disabled:m,children:"SAVE"})})})]})})})}})]})}},66675:(e,i,n)=>{var l=n(24994);i.A=void 0;var s=l(n(40039)),a=n(70579);i.A=(0,s.default)((0,a.jsx)("path",{d:"M3 18h13v-2H3zm0-5h10v-2H3zm0-7v2h13V6zm18 9.59L17.42 12 21 8.41 19.59 7l-5 5 5 5z"}),"MenuOpen")},37965:(e,i,n)=>{var l=n(24994);i.A=void 0;var s=l(n(40039)),a=n(70579);i.A=(0,s.default)((0,a.jsx)("path",{d:"M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81 1.66 0 3-1.34 3-3s-1.34-3-3-3-3 1.34-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9c-1.66 0-3 1.34-3 3s1.34 3 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.16c-.05.21-.08.43-.08.65 0 1.61 1.31 2.92 2.92 2.92 1.61 0 2.92-1.31 2.92-2.92s-1.31-2.92-2.92-2.92"}),"Share")}}]);
//# sourceMappingURL=50570.9daad19a.chunk.js.map