import{b as f,a as g,h as v,vp as D,r as S,j as e,I as A,ec as F,K as c,vq as C,vr as l,vs as w}from"./index-60a3c753.js";import{c as E,b as q}from"./index.esm-62d6b2f7.js";import{o as $}from"./yup-92678dde.js";import{u as k}from"./index.esm-c494934a.js";import"./componentStyles-7753bbb9.js";import{F as B}from"./FormInput-74e2c4d2.js";/* empty css                   */import"./ScrollableList-1962b023.js";import{D as L,a as P}from"./DialogContent-89e21f2e.js";import{D as T}from"./DialogTitle-fe69da5c.js";import{D as U}from"./DialogContentText-6688bd59.js";import{D as z}from"./DialogActions-e754942c.js";const M=({modal:i,closeModal:o,mastersName:u,edit_Id:a,mastersValue:K})=>{const n=f(),{document:{selectedData:t,pageParams:p},system:{userAccessList:N}}=g(r=>({system:v(r),document:D(r)})),d=E().shape({name:q().required("Please enter document name").trim().matches(/^[a-zA-Z0-9 ]*$/,"document name should not contain special characters")});S.useEffect(()=>{i?s({name:(t==null?void 0:t.name)||""}):s()},[i,t]);const{control:h,handleSubmit:x,reset:s}=k({resolver:$(d),values:{name:t!=null&&t.name?t==null?void 0:t.name:""}}),b=r=>{if(a==null||a==0){const m={obj:{name:r.name},pageParams:p,clearDataFn:()=>{},navigate:y=>{}};n(C(m)),o(),n(l({})),s()}else{const m={obj:{id:a,name:r.name},pageParams:p,clearDataFn:()=>{},navigate:y=>{}};n(w(m)),n(l({})),o(),s()}};return e.jsx(e.Fragment,{children:e.jsxs(L,{open:i,onClose:o,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsxs(T,{sx:{bgcolor:"primary.main",color:"white",p:1,px:2,display:"flex",alignItems:"center",justifyContent:"space-between"},variant:"h4",id:"alert-dialog-title",children:[a==null||a==0?"Add ":"Update ",u,e.jsx(A,{onClick:o,children:e.jsx(F,{color:"white"})})]}),e.jsx(P,{sx:{px:"24px",pt:"12px !important",pb:0},children:e.jsx(U,{id:"alert-dialog-description",sx:{width:500},children:e.jsxs("form",{style:{width:"100%"},onSubmit:x(b),children:[e.jsx(B,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter Document here...",control:h}),e.jsxs(z,{sx:{p:2},children:[e.jsx(c,{onClick:o,variant:"outlined",color:"secondary",children:"Cancel"}),a==null||a==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{M as A};
