"use strict";(self.webpackChunkkns_reports=self.webpackChunkkns_reports||[]).push([[27352],{24659:(e,t,n)=>{n.d(t,{A:()=>d});n(65043);var a=n(67784),i=n(4701),r=n(17392),s=n(10155),l=n(70579);const o=(0,i.A)({}),c=e=>{let{onClick:t}=e;return(0,l.jsx)(r.A,{onClick:t,children:(0,l.jsx)(s.A,{})})},d=e=>{const t=o();return(0,l.jsx)(a.A,{InputProps:{...t,endAdornment:(0,l.jsxs)(l.Fragment,{children:[" ",e.iscross&&(0,l.jsx)(c,{onClick:null!==e&&void 0!==e&&e.textclear?e.textclear:""})]})},...e})}},27352:(e,t,n)=>{n.r(t),n.d(t,{default:()=>f});var a=n(65043),i=n(11906),r=n(68903),s=n(96446),l=n(24659),o=n(63516),c=n(73033),d=n(14556),u=n(73216),m=n(66675),h=n(11852),v=n(5388),y=(n(73402),n(96801)),g=n(70579);(new Date).toISOString().substring(0,10);const x={userID:"",categoryName:""},p=c.Ik().shape({categoryName:c.Yj().nullable().required("Category Name is required")}),j=(0,y.Gq)("enuseloc"),N=j&&Object.keys(j).length>0?j.user_id:null,A=[];const f=function(e){const[t,n]=(0,a.useState)(!1),[c,y]=(0,a.useState)(x),j=a.useRef(null),f=(0,d.wA)(),b=(0,u.Zp)(),[C,S]=(0,a.useState)([]),k=(0,d.d4)((e=>{var t,n;return null===e||void 0===e||null===(t=e.bd)||void 0===t||null===(n=t.getFunctionalityPermissionDetail)||void 0===n?void 0:n.data})),I=(0,a.useRef)("NO"),z=(0,a.useRef)("NO");(0,a.useEffect)((()=>{const e={userID:N,functionalityID:506,functionalityItemIDs:A};return f((0,h.P8M)(e)),()=>{f((0,h.qo7)())}}),[]),(0,a.useEffect)((()=>(k&&506===(null===k||void 0===k?void 0:k.functionalityID)&&(S(k),I.current=null===k||void 0===k?void 0:k.permission_report,z.current=null===k||void 0===k?void 0:k.permission_admin),()=>{S([]),I.current="NO",z.current="NO"})),[k]);const D=()=>{b(-1)};return(0,g.jsx)(g.Fragment,{children:(0,g.jsxs)("div",{className:"component-list",style:{marginTop:"20px"},children:[(0,g.jsxs)(i.A,{onClick:D,children:[(0,g.jsx)(m.A,{})," Add Compliance Category"]}),C&&Object.keys(C).length>0&&506===(null===C||void 0===C?void 0:C.functionalityID)&&("YES"===(null===C||void 0===C?void 0:C.permission_admin)||"YES"===(null===C||void 0===C?void 0:C.AddAPFQuery))?(0,g.jsx)(o.l1,{enableReinitialize:!0,innerRef:j,initialValues:c,validationSchema:p,onSubmit:async(e,t)=>{const n={userID:N,categoryName:e.categoryName?e.categoryName:"",remarks:""};console.log("finalpayload",n),t.setSubmitting(!0),await f((0,v.nB)(n)),t.resetForm({}),D()},children:e=>{let{errors:t,handleSubmit:n,handleChange:a,handleBlur:d,setFieldValue:u,isSubmitting:m,isValid:h,touched:v,values:p}=e;return(0,g.jsx)(o.lV,{onSubmit:n,children:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"reports-list",children:(0,g.jsx)("div",{className:"component-form",children:(0,g.jsx)(r.Ay,{item:!0,xs:12,sm:12,md:12,lg:12,p:1,children:(0,g.jsx)(l.A,{name:"categoryName",fullWidth:!0,id:"categoryName",placeholder:"Category Name",type:"text",onBlur:d,value:c.categoryName,onChange:(e,t)=>{u("categoryName",t),y({...c,categoryName:e.target.value})},error:v.categoryName&&Boolean(t.categoryName),helperText:v.categoryName&&t.categoryName,size:"small",label:"Category Name",variant:"outlined"})})})}),(0,g.jsxs)(r.Ay,{className:"d-flex justify-content-end",p:2,children:[(0,g.jsxs)(s.A,{mx:2,children:[" ",(0,g.jsx)(i.A,{text:"CANCEL",variant:"contained",color:"secondary",size:"medium",type:"reset",onClick:()=>{y({...x})},children:"RESET"})]}),(0,g.jsx)(s.A,{children:(0,g.jsx)(i.A,{type:"submit",text:"SAVE",variant:"contained",size:"medium",disabled:m,children:"SUBMIT"})})]})]})})}}):(0,g.jsx)("div",{className:"common-header-label-bold",children:"You don't have permission to access this page!"})]})})}},10155:(e,t,n)=>{var a=n(24994);t.A=void 0;var i=a(n(40039)),r=n(70579);t.A=(0,i.default)((0,r.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,t,n)=>{var a=n(24994);t.A=void 0;var i=a(n(40039)),r=n(70579);t.A=(0,i.default)((0,r.jsx)("path",{d:"M3 18h13v-2H3zm0-5h10v-2H3zm0-7v2h13V6zm18 9.59L17.42 12 21 8.41 19.59 7l-5 5 5 5z"}),"MenuOpen")},73402:()=>{}}]);
//# sourceMappingURL=27352.9fb0046d.chunk.js.map