"use strict";(self.webpackChunkkns_reports=self.webpackChunkkns_reports||[]).push([[53705],{24659:(e,n,r)=>{r.d(n,{A:()=>c});r(65043);var i=r(67784),l=r(4701),a=r(17392),t=r(10155),s=r(70579);const d=(0,l.A)({}),o=e=>{let{onClick:n}=e;return(0,s.jsx)(a.A,{onClick:n,children:(0,s.jsx)(t.A,{})})},c=e=>{const n=d();return(0,s.jsx)(i.A,{InputProps:{...n,endAdornment:(0,s.jsxs)(s.Fragment,{children:[" ",e.iscross&&(0,s.jsx)(o,{onClick:null!==e&&void 0!==e&&e.textclear?e.textclear:""})]})},...e})}},53705:(e,n,r)=>{r.r(n),r.d(n,{default:()=>N});var i=r(65043),l=r(68903),a=r(11906),t=r(96446),s=r(63516),d=r(24659),o=r(73216),c=r(66675),u=r(14556),m=r(96801),y=r(11852),h=r(6994),v=r(73033),p=r(70579);const x={categoryName:"",displayOrder:""},j=v.Ik().shape({categoryName:v.Yj().required("Category Name is required")}),g=(0,m.Gq)("enuseloc"),A=g&&Object.keys(g).length>0?g.user_id:null,f=[];const N=function(e){const n=(0,u.wA)(),r=(0,o.Zp)(),m=i.useRef(null),[v,g]=(0,i.useState)(x),[N,b]=(0,i.useState)([]),O=(0,u.d4)((e=>{var n;return null===(n=e.bd.getFunctionalityPermissionDetail)||void 0===n?void 0:n.data})),C=(0,i.useRef)("NO"),k=(0,i.useRef)("NO");return(0,i.useEffect)((()=>{const e={userID:A,functionalityID:286,functionalityItemIDs:f};return n((0,y.P8M)(e)),()=>{n((0,y.qo7)())}}),[]),(0,i.useEffect)((()=>(O&&286===(null===O||void 0===O?void 0:O.functionalityID)&&(b(O),C.current=null===O||void 0===O?void 0:O.permission_report,k.current=null===O||void 0===O?void 0:O.permission_admin),()=>{b([]),C.current="NO",k.current="NO"})),[O]),(0,p.jsxs)("div",{className:"component-list",children:[(0,p.jsx)(l.Ay,{container:!0,className:"d-flex justify-content-between align-items-center",py:1,children:(0,p.jsxs)(l.Ay,{item:!0,className:"common-header-label",children:[(0,p.jsx)(a.A,{onClick:()=>{r(-1)},children:(0,p.jsx)(c.A,{})}),"Add Enquiry Category"]})}),N&&Object.keys(N).length>0&&286===(null===N||void 0===N?void 0:N.functionalityID)&&"YES"===(null===N||void 0===N?void 0:N.permission_admin)?(0,p.jsx)(s.l1,{enableReinitialize:!0,innerRef:m,initialValues:v,validationSchema:j,onSubmit:async(e,i)=>{const l={categoryName:null!==e&&void 0!==e&&e.categoryName?null===e||void 0===e?void 0:e.categoryName:"",displayOrder:null!==e&&void 0!==e&&e.displayOrder?null===e||void 0===e?void 0:e.displayOrder:""};console.log("finalPayload",l),i.setSubmitting(!0),await n((0,h.$e)(l)),i.resetForm({}),r("/crm/crm-enquiry-category")},children:e=>{let{errors:n,handleSubmit:r,handleChange:i,setFieldValue:o,handleBlur:c,isSubmitting:u,isValid:m,touched:y,values:h}=e;return(0,p.jsx)(s.lV,{onSubmit:r,children:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(l.Ay,{container:!0,className:"component-form",children:(0,p.jsxs)(l.Ay,{container:!0,children:[(0,p.jsx)(l.Ay,{item:!0,xs:12,sm:12,md:12,lg:12,p:1,children:(0,p.jsx)(d.A,{fullWidth:!0,name:"categoryName",onBlur:c,onChange:i,value:h.categoryName,error:y.categoryName&&Boolean(n.categoryName),helperText:y.categoryName&&n.categoryName,id:"categoryName",size:"small",label:"Category Name *",variant:"outlined"})}),(0,p.jsx)(l.Ay,{item:!0,xs:12,sm:12,md:12,lg:12,p:1,children:(0,p.jsx)(d.A,{fullWidth:!0,name:"displayOrder",onBlur:c,onChange:i,value:h.displayOrder,error:y.displayOrder&&Boolean(n.displayOrder),helperText:y.displayOrder&&n.displayOrder,id:"displayOrder",type:"number",size:"small",label:"Display Order *",variant:"outlined"})})]})}),(0,p.jsxs)(l.Ay,{className:"d-flex justify-content-end",p:2,children:[(0,p.jsxs)(t.A,{mx:2,children:[" ",(0,p.jsx)(a.A,{text:"CANCEL",variant:"contained",size:"medium",type:"reset",color:"secondary",onClick:()=>{g({...x})},children:"RESET"})]}),(0,p.jsx)(t.A,{children:(0,p.jsx)(a.A,{type:"submit",text:"SAVE",variant:"contained",size:"medium",disabled:u,children:"SAVE"})})]})]})})}}):(0,p.jsx)("div",{className:"common-header-label-bold",children:"You don't have permission to access this page!"})]})}},10155:(e,n,r)=>{var i=r(24994);n.A=void 0;var l=i(r(40039)),a=r(70579);n.A=(0,l.default)((0,a.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,n,r)=>{var i=r(24994);n.A=void 0;var l=i(r(40039)),a=r(70579);n.A=(0,l.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")}}]);
//# sourceMappingURL=53705.fe9df0a7.chunk.js.map