import{d as y,a as f,b as g,nL as v,r as C,j as e,I as S,aI as A,R as c,nM as D,nN as p,nO as F}from"./index-0698dbe6.js";import{c as w,b as E,u as N}from"./index.esm-85d015f3.js";import{o as L}from"./yup-7a53beb8.js";import"./GenericThumbnailView-dca658f3.js";import{F as M}from"./FormInput-98c39817.js";import"./componentStyles-91278318.js";import"./ScrollableList-fc87149c.js";import"./TextArea-91c96faf.js";import{D as O,a as $}from"./DialogContent-6dbfd908.js";import{D as k}from"./DialogTitle-a8d1726a.js";import{D as q}from"./DialogContentText-ceb40f80.js";import{D as B}from"./DialogActions-318201e3.js";const _=({modal:i,closeModal:r,mastersName:P,editId:t,mastersValue:R})=>{const s=y(),{moc:{selectedData:a,pageParams:l},system:{userAccessList:T}}=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:d,handleSubmit:h,reset:n}=N({resolver:L(u),values:{name:a!=null&&a.name?a==null?void 0:a.name:""}}),x=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(O,{open:i,onClose:r,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsxs(k,{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($,{sx:{px:"24px",pt:"12px !important",pb:0},children:e.jsx(q,{id:"alert-dialog-description",sx:{width:500},children:e.jsxs("form",{style:{width:"100%"},onSubmit:h(x),children:[e.jsx(M,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter MOC Name here...",control:d}),e.jsxs(B,{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};
