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