import{d as y,a as f,b as g,pN as v,r as C,j as e,I as S,aM as A,U as c,pO as D,pP as l,pQ as F}from"./index-c3f592b2.js";import{c as w,b as E,u as N}from"./index.esm-70dd1c06.js";import{o as M}from"./yup-abb4a026.js";import"./GenericThumbnailView-9f1d2f81.js";import{F as O}from"./FormInput-adbf55b1.js";import"./componentStyles-b8fcedb5.js";import"./ScrollableList-ecbfc0f3.js";import"./TextArea-674a9ec6.js";import{D as P,a as U}from"./DialogContent-b7fc1c43.js";import{D as $}from"./DialogTitle-5d3e2030.js";import{D as k}from"./DialogContentText-c3e782dc.js";import{D as q}from"./DialogActions-6e00f4f1.js";const _=({modal:i,closeModal:r,mastersName:B,editId:t,mastersValue:L})=>{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}=N({resolver:M(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(D(m)),r(),s(l({})),n()}else{const m={obj:{id:t,name:o.name},pageParams:p,clearDataFn:()=>{},navigate:j=>{}};s(F(m)),s(l({})),r(),n()}};return e.jsx(e.Fragment,{children:e.jsxs(P,{open:i,onClose:r,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsxs($,{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(U,{sx:{px:"24px",pt:"12px !important",pb:0},children:e.jsx(k,{id:"alert-dialog-description",sx:{width:500},children:e.jsxs("form",{style:{width:"100%"},onSubmit:h(x),children:[e.jsx(O,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter MOC Name here...",control:d}),e.jsxs(q,{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};
