import{d as y,a as f,b as g,oo as v,r as C,j as e,I as D,aK as S,R as c,op as A,oq as l,or as F}from"./index-e6164346.js";import{c as w,b as E,u as q}from"./index.esm-0a041314.js";import{o as N}from"./yup-5fd5d57b.js";import"./GenericThumbnailView-80c6fd98.js";import{F as $}from"./FormInput-859198ec.js";import"./componentStyles-00385170.js";import"./ScrollableList-5a17e8f4.js";import"./TextArea-f5c200de.js";import{D as k}from"./Dialog-2e8a8e2e.js";import{D as B}from"./DialogTitle-8757f50f.js";import{D as L}from"./DialogContent-f10d6731.js";import{D as M}from"./DialogContentText-027be15d.js";import{D as O}from"./DialogActions-31bec80e.js";const I=({modal:n,closeModal:t,mastersName:P,editId:o,mastersValue:R})=>{const s=y(),{moc:{selectedData:a,pageParams:p},system:{userAccessList:T}}=f(r=>({system:g(r),moc:v(r)})),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(()=>{n?i({name:(a==null?void 0:a.name)||""}):i()},[n,a]);const{control:d,handleSubmit:h,reset:i}=q({resolver:N(u),values:{name:a!=null&&a.name?a==null?void 0:a.name:""}}),x=r=>{if(o==null||o==0){const m={obj:{name:r.name},pageParams:p,clearDataFn:()=>{},navigate:j=>{}};s(A(m)),t(),s(l({})),i()}else{const m={obj:{id:o,name:r.name},pageParams:p,clearDataFn:()=>{},navigate:j=>{}};s(F(m)),s(l({})),t(),i()}};return e.jsx(e.Fragment,{children:e.jsxs(k,{open:n,onClose:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsxs(B,{sx:{bgcolor:"primary.main",color:"white",p:1,px:2,display:"flex",alignItems:"center",justifyContent:"space-between"},variant:"h4",id:"alert-dialog-title",children:[o==null||o==0?"Add ":"Update ","MOC",e.jsx(D,{onClick:t,children:e.jsx(S,{color:"white"})})]}),e.jsx(L,{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:h(x),children:[e.jsx($,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter MOC Name here...",control:d}),e.jsxs(O,{sx:{p:2},children:[e.jsx(c,{onClick:t,variant:"outlined",color:"secondary",children:"Cancel"}),o==null||o==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{I as A};
