import{b as y,a as f,h as g,uR as v,r as S,j as e,I as C,ec as A,K as c,uS as D,uT as p,uU as F}from"./index-76d4793e.js";import{c as w,b as E}from"./index.esm-ad8a7c9f.js";import{o as N}from"./yup-688ec4f6.js";import{u as T}from"./index.esm-3adfd9f7.js";import"./componentStyles-0803b39e.js";import{F as U}from"./FormInput-8f40ded1.js";/* empty css                   */import"./ScrollableList-4dae3697.js";import{D as $,a as k}from"./DialogContent-7bd8dd8f.js";import{D as q}from"./DialogTitle-71dd5b3a.js";import{D as B}from"./DialogContentText-7642f81f.js";import{D as L}from"./DialogActions-5a5e1db9.js";const _=({modal:i,closeModal:r,mastersName:M,editId:t,mastersValue:O})=>{const s=y(),{moc:{selectedData:a,pageParams:l},system:{userAccessList:P}}=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")});S.useEffect(()=>{i?n({name:(a==null?void 0:a.name)||""}):n()},[i,a]);const{control:h,handleSubmit:x,reset:n}=T({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($,{open:i,onClose:r,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsxs(q,{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(C,{onClick:r,children:e.jsx(A,{color:"white"})})]}),e.jsx(k,{sx:{px:"24px",pt:"12px !important",pb:0},children:e.jsx(B,{id:"alert-dialog-description",sx:{width:500},children:e.jsxs("form",{style:{width:"100%"},onSubmit:x(d),children:[e.jsx(U,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter MOC Name here...",control:h}),e.jsxs(L,{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};
