import{b as y,a as f,g,uW as v,r as C,j as e,I as S,ef as A,J as c,uX as D,uY as p,uZ as F}from"./index-d2b25495.js";import{c as w,b as E}from"./index.esm-3043d6d4.js";import{o as N}from"./yup-267e586f.js";import{u as $}from"./index.esm-ce3c2c20.js";import"./componentStyles-0e851d91.js";import{F as k}from"./FormInput-d202e905.js";/* empty css                   */import"./ScrollableList-fc1de312.js";import{D as q,a as B}from"./DialogContent-cded694d.js";import{D as L}from"./DialogTitle-a145b392.js";import{D as M}from"./DialogContentText-43575e44.js";import{D as O}from"./DialogActions-7c802cc8.js";const _=({modal:i,closeModal:r,mastersName:P,editId:t,mastersValue:T})=>{const s=y(),{moc:{selectedData:a,pageParams:l},system:{userAccessList:U}}=f(o=>({system:g(o),moc:v(o)})),u=w().shape({name:E().required("Please enter your moc name").trim().matches(/^[a-zA-Z0-9 ]*$/,"moc name should not contain special characters")});C.useEffect(()=>{i?n({name:(a==null?void 0:a.name)||""}):n()},[i,a]);const{control:h,handleSubmit:x,reset:n}=$({resolver:N(u),values:{name:a!=null&&a.name?a==null?void 0:a.name:""}}),d=o=>{if(t==null||t==0){const m={obj:{name:o.name},pageParams:l,clearDataFn:()=>{},navigate:j=>{}};s(D(m)),r(),s(p({})),n()}else{const m={obj:{id:t,name:o.name},pageParams:l,clearDataFn:()=>{},navigate:j=>{}};s(F(m)),s(p({})),r(),n()}};return e.jsx(e.Fragment,{children:e.jsxs(q,{open:i,onClose:r,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsxs(L,{sx:{bgcolor:"primary.main",color:"white",p:1,px:2,display:"flex",alignItems:"center",justifyContent:"space-between"},variant:"h4",id:"alert-dialog-title",children:[t==null||t==0?"Add ":"Update ","MOC",e.jsx(S,{onClick:r,children:e.jsx(A,{color:"white"})})]}),e.jsx(B,{sx:{px:"24px",pt:"12px !important",pb:0},children:e.jsx(M,{id:"alert-dialog-description",sx:{width:500},children:e.jsxs("form",{style:{width:"100%"},onSubmit:x(d),children:[e.jsx(k,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter MOC Name here...",control:h}),e.jsxs(O,{sx:{p:2},children:[e.jsx(c,{onClick:r,variant:"outlined",color:"secondary",children:"Cancel"}),t==null||t==0?e.jsx(c,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Submit"}):e.jsx(c,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Update"})]})]})})})]})})};export{_ as A};
