import{d as y,a as f,b as g,nb as v,r as C,j as e,I as S,ax as A,z as c,nc as D,nd as p,ne as F}from"./index-d895656a.js";import{c as w,b as E,u as N}from"./index.esm-1087b2f3.js";import{o as $}from"./yup-9573aa79.js";import"./GenericThumbnailView-532ea2d7.js";import{F as k}from"./FormInput-9b5da280.js";import"./componentStyles-866300fe.js";import"./ScrollableList-e2b22048.js";import"./TextArea-fb0d0821.js";import{D as q,a as z}from"./DialogContent-4ce43512.js";import{D as B}from"./DialogTitle-738ca272.js";import{D as L}from"./DialogContentText-8b9b0e0c.js";import{D as M}from"./DialogActions-7b82f6f6.js";const _=({modal:i,closeModal:r,mastersName:O,editId:t,mastersValue:P})=>{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:x,reset:n}=N({resolver:$(u),values:{name:a!=null&&a.name?a==null?void 0:a.name:""}}),h=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(q,{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(S,{onClick:r,children:e.jsx(A,{color:"white"})})]}),e.jsx(z,{sx:{px:"24px",pt:"12px !important",pb:0},children:e.jsx(L,{id:"alert-dialog-description",sx:{width:500},children:e.jsxs("form",{style:{width:"100%"},onSubmit:x(h),children:[e.jsx(k,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter MOC Name here...",control:d}),e.jsxs(M,{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};
