import{d as f,a as g,b as D,pA as v,r as A,j as e,I as S,aL as C,R as c,pB as F,pC as l,pD as w}from"./index-952e178b.js";import{c as E,b as B,u as L}from"./index.esm-6feddb16.js";import{o as $}from"./yup-d92565dd.js";import"./GenericThumbnailView-4e535459.js";import{F as k}from"./FormInput-8320115a.js";import"./componentStyles-00160cc0.js";import"./ScrollableList-cd5816a8.js";import"./TextArea-ce7716c9.js";import{D as q,a as P}from"./DialogContent-4facb916.js";import{D as R}from"./DialogTitle-3aa960f8.js";import{D as T}from"./DialogContentText-54d95680.js";import{D as U}from"./DialogActions-bd200b72.js";const M=({modal:i,closeModal:o,mastersName:u,edit_Id:a,mastersValue:z})=>{const n=f(),{document:{selectedData:t,pageParams:p},system:{userAccessList:N}}=g(r=>({system:D(r),document:v(r)})),d=E().shape({name:B().required("Please enter document name").trim().matches(/^[a-zA-Z0-9 ]*$/,"document name should not contain special characters")});A.useEffect(()=>{i?s({name:(t==null?void 0:t.name)||""}):s()},[i,t]);const{control:h,handleSubmit:x,reset:s}=L({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(F(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(q,{open:i,onClose:o,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsxs(R,{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(S,{onClick:o,children:e.jsx(C,{color:"white"})})]}),e.jsx(P,{sx:{px:"24px",pt:"12px !important",pb:0},children:e.jsx(T,{id:"alert-dialog-description",sx:{width:500},children:e.jsxs("form",{style:{width:"100%"},onSubmit:x(b),children:[e.jsx(k,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter Document here...",control:h}),e.jsxs(U,{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};
