"use strict";(self.webpackChunkkns_reports=self.webpackChunkkns_reports||[]).push([[19481],{24659:(e,s,t)=>{t.d(s,{A:()=>u});t(65043);var i=t(67784),n=t(4701),l=t(17392),a=t(10155),r=t(70579);const o=(0,n.A)({}),d=e=>{let{onClick:s}=e;return(0,r.jsx)(l.A,{onClick:s,children:(0,r.jsx)(a.A,{})})},u=e=>{const s=o();return(0,r.jsx)(i.A,{InputProps:{...s,endAdornment:(0,r.jsxs)(r.Fragment,{children:[" ",e.iscross&&(0,r.jsx)(d,{onClick:null!==e&&void 0!==e&&e.textclear?e.textclear:""})]})},...e})}},19481:(e,s,t)=>{t.r(s),t.d(s,{default:()=>g});var i=t(65043),n=t(11906),l=t(68903),a=t(38624),r=t(96446),o=t(73216),d=t(24659),u=t(63516),c=t(73033),v=t(14556),m=t(66675),p=t(11852),h=t(80884),x=(t(62369),t(96801)),y=t(70579);const A={serviceTypeName:"",status:""},j=c.Ik().shape({serviceTypeName:c.Yj().required("Service Type Name required"),status:c.Ik().nullable().required("Select Status")}),N=(0,x.Gq)("enuseloc"),f=N&&Object.keys(N).length>0?N.user_id:null,T=[];const g=function(e){const s=[{id:"Active",name:"Active"},{id:"InActive",name:"InActive"}],t=(0,o.zy)(),c=(null===t||void 0===t?void 0:t.state)._original||"";console.log(c,"optionData"),(0,i.useEffect)((()=>{c&&N({...x,serviceTypeName:null===c||void 0===c?void 0:c.service_name,status:{id:null===c||void 0===c?void 0:c.status,name:null===c||void 0===c?void 0:c.status}})}),[c]);const[x,N]=(0,i.useState)(A),g=i.useRef(null),b=(0,v.wA)(),S=(0,o.Zp)(),[k,C]=(0,i.useState)([]),I=(0,v.d4)((e=>{var s;return null===(s=e.bd.getFunctionalityPermissionDetail)||void 0===s?void 0:s.data})),z=(0,i.useRef)("NO"),E=(0,i.useRef)("NO");(0,i.useEffect)((()=>{const e={userID:f,functionalityID:518,functionalityItemIDs:T};return b((0,p.P8M)(e)),()=>{b((0,p.qo7)())}}),[]),(0,i.useEffect)((()=>(I&&518===(null===I||void 0===I?void 0:I.functionalityID)&&(C(I),z.current=null===I||void 0===I?void 0:I.permission_report,E.current=null===I||void 0===I?void 0:I.permission_admin),()=>{C([]),z.current="NO",E.current="NO"})),[I]);const D=()=>{N({...A})},O=()=>{S(-1)};return(0,y.jsx)(y.Fragment,{children:(0,y.jsxs)("div",{className:"component-list",style:{marginTop:"20px"},children:[(0,y.jsxs)(n.A,{onClick:O,children:[(0,y.jsx)(m.A,{}),"Update Service Type"]}),k&&Object.keys(k).length>0&&518===(null===k||void 0===k?void 0:k.functionalityID)&&("YES"===(null===k||void 0===k?void 0:k.permission_admin)||"YES"===(null===k||void 0===k?void 0:k.AddAPFQuery))?(0,y.jsx)(u.l1,{enableReinitialize:!0,innerRef:g,initialValues:x,validationSchema:j,onSubmit:async(e,s)=>{var t,i;const n={serviceTypeID:null===c||void 0===c?void 0:c.id,serviceName:(null===e||void 0===e?void 0:e.serviceTypeName)||"",status:null!==(t=e.status)&&void 0!==t&&t.id?null===(i=e.status)||void 0===i?void 0:i.id:""};console.log(n,"payload"),s.setSubmitting(!0),await b((0,h.guP)(n)),s.resetForm({}),O(),D()},children:e=>{let{errors:t,handleSubmit:i,handleChange:o,handleBlur:c,setFieldValue:v,isSubmitting:m,isValid:p,touched:h,values:A}=e;return(0,y.jsx)(u.lV,{onSubmit:i,children:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("div",{className:"reports-list",children:(0,y.jsxs)("div",{className:"component-form",children:[(0,y.jsx)(l.Ay,{item:!0,xs:12,sm:12,md:12,lg:12,p:1,children:(0,y.jsx)(d.A,{name:"serviceTypeName",fullWidth:!0,id:"serviceTypeName",placeholder:"Service Type Name",type:"text",onBlur:c,value:x.serviceTypeName,onChange:(e,s)=>{v("serviceTypeName",s),N({...x,serviceTypeName:e.target.value})},error:h.serviceTypeName&&Boolean(t.serviceTypeName),helperText:h.serviceTypeName&&t.serviceTypeName,size:"small",label:"Service Type Name*",variant:"outlined"})}),(0,y.jsx)(l.Ay,{item:!0,xs:12,sm:12,md:12,lg:12,p:1,children:(0,y.jsx)(a.A,{name:"status",value:A.status,fullWidth:!0,options:s||[],onBlur:c,size:"small",getOptionLabel:e=>e.name||"",onChange:(e,s)=>{v("status",s),N({...x,status:s})},renderInput:e=>(0,y.jsx)(d.A,{...e,fullWidth:!0,label:"Status *",name:"status",variant:"outlined",helperText:t.status&&t.status,error:t.status&&Boolean(t.status)})})})]})}),(0,y.jsxs)(l.Ay,{className:"d-flex justify-content-center",p:2,children:[(0,y.jsxs)(r.A,{mx:2,children:[" ",(0,y.jsx)(n.A,{text:"CANCEL",variant:"contained",color:"secondary",size:"medium",type:"reset",onClick:()=>D(),children:"RESET"})]}),(0,y.jsx)(r.A,{children:(0,y.jsx)(n.A,{type:"submit",text:"SAVE",variant:"contained",size:"medium",disabled:m,children:"Add"})})]})]})})}}):(0,y.jsx)("div",{className:"common-header-label-bold",children:"You don't have permission to access this page!"})]})})}},10155:(e,s,t)=>{var i=t(24994);s.A=void 0;var n=i(t(40039)),l=t(70579);s.A=(0,n.default)((0,l.jsx)("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Clear")},66675:(e,s,t)=>{var i=t(24994);s.A=void 0;var n=i(t(40039)),l=t(70579);s.A=(0,n.default)((0,l.jsx)("path",{d:"M3 18h13v-2H3zm0-5h10v-2H3zm0-7v2h13V6zm18 9.59L17.42 12 21 8.41 19.59 7l-5 5 5 5z"}),"MenuOpen")},62369:()=>{}}]);
//# sourceMappingURL=19481.f4ef6933.chunk.js.map