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