import{d as y,a as f,b as g,pC as v,r as C,j as e,I as D,aL as F,R as c,pD as S,pE as l,pF as A}from"./index-e79f7aad.js";import{c as w,b as E,u as L}from"./index.esm-1ca67d65.js";import{o as N}from"./yup-96f14780.js";import"./GenericThumbnailView-8a83a30c.js";import{F as $}from"./FormInput-07daa19d.js";import"./componentStyles-7718fc5e.js";import"./ScrollableList-5929779e.js";import"./TextArea-ec29d1d5.js";import{D as k,a as q}from"./DialogContent-6a297cef.js";import{D as B}from"./DialogTitle-62595023.js";import{D as M}from"./DialogContentText-0c5306f9.js";import{D as O}from"./DialogActions-edd1d02f.js";const _=({modal:i,closeModal:r,mastersName:P,editId:t,mastersValue:R})=>{const s=y(),{moc:{selectedData:a,pageParams:p},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}=L({resolver:N(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:p,clearDataFn:()=>{},navigate:j=>{}};s(S(m)),r(),s(l({})),n()}else{const m={obj:{id:t,name:o.name},pageParams:p,clearDataFn:()=>{},navigate:j=>{}};s(A(m)),s(l({})),r(),n()}};return e.jsx(e.Fragment,{children:e.jsxs(k,{open:i,onClose:r,"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:[t==null||t==0?"Add ":"Update ","MOC",e.jsx(D,{onClick:r,children:e.jsx(F,{color:"white"})})]}),e.jsx(q,{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: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};
