import{d as y,a as f,b as g,om as v,r as C,j as e,I as S,aK as A,R as c,on as D,oo as l,op as F}from"./index-e972fa8e.js";import{c as w,b as E,u as N}from"./index.esm-b3c20f6d.js";import{o as $}from"./yup-b3178c01.js";import"./GenericThumbnailView-38007944.js";import{F as k}from"./FormInput-dbaa88c2.js";import"./componentStyles-7142291f.js";import"./ScrollableList-4768c2b7.js";import"./TextArea-6c7f39e1.js";import{D as q,a as B}from"./DialogContent-51a7b314.js";import{D as L}from"./DialogTitle-6bcbc606.js";import{D as M}from"./DialogContentText-1562904b.js";import{D as O}from"./DialogActions-122de1b4.js";const _=({modal:i,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(()=>{i?n({name:(a==null?void 0:a.name)||""}):n()},[i,a]);const{control:d,handleSubmit:h,reset:n}=N({resolver:$(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(D(m)),t(),s(l({})),n()}else{const m={obj:{id:o,name:r.name},pageParams:p,clearDataFn:()=>{},navigate:j=>{}};s(F(m)),s(l({})),t(),n()}};return e.jsx(e.Fragment,{children:e.jsxs(q,{open:i,onClose:t,"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:[o==null||o==0?"Add ":"Update ","MOC",e.jsx(S,{onClick:t,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:h(x),children:[e.jsx(k,{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{_ as A};
