import{d as y,a as f,b as g,oq as v,r as C,j as e,I as S,aK as A,R as c,or as D,os as p,ot as F}from"./index-5ae5cc5e.js";import{c as w,b as E,u as q}from"./index.esm-bd37e938.js";import{o as N}from"./yup-86a48159.js";import"./GenericThumbnailView-fac7773c.js";import{F as $}from"./FormInput-77541d96.js";import"./componentStyles-7d84c389.js";import"./ScrollableList-2ee889f8.js";import"./TextArea-20f097f8.js";import{D as k,a as B}from"./DialogContent-e2578cbd.js";import{D as L}from"./DialogTitle-4a5aec12.js";import{D as M}from"./DialogContentText-bc10bf8d.js";import{D as O}from"./DialogActions-ad26e3d6.js";const _=({modal:i,closeModal:o,mastersName:P,editId:t,mastersValue:R})=>{const s=y(),{moc:{selectedData:a,pageParams:l},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}=q({resolver:N(u),values:{name:a!=null&&a.name?a==null?void 0:a.name:""}}),x=r=>{if(t==null||t==0){const m={obj:{name:r.name},pageParams:l,clearDataFn:()=>{},navigate:j=>{}};s(D(m)),o(),s(p({})),n()}else{const m={obj:{id:t,name:r.name},pageParams:l,clearDataFn:()=>{},navigate:j=>{}};s(F(m)),s(p({})),o(),n()}};return e.jsx(e.Fragment,{children:e.jsxs(k,{open:i,onClose:o,"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:[t==null||t==0?"Add ":"Update ","MOC",e.jsx(S,{onClick:o,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($,{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:o,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};
