import{d as f,a as g,b as D,nP as v,r as S,j as e,I as A,ax as F,z as c,nQ as C,nR as p,nS as w}from"./index-d895656a.js";import{c as E,b as P,u as $}from"./index.esm-1087b2f3.js";import{o as k}from"./yup-9573aa79.js";import"./GenericThumbnailView-532ea2d7.js";import{F as q}from"./FormInput-9b5da280.js";import"./componentStyles-866300fe.js";import"./ScrollableList-e2b22048.js";import"./TextArea-fb0d0821.js";import{D as z,a as B}from"./DialogContent-4ce43512.js";import{D as L}from"./DialogTitle-738ca272.js";import{D as R}from"./DialogContentText-8b9b0e0c.js";import{D as T}from"./DialogActions-7b82f6f6.js";const M=({modal:i,closeModal:o,mastersName:u,edit_Id:a,mastersValue:U})=>{const n=f(),{document:{selectedData:t,pageParams:l},system:{userAccessList:N}}=g(r=>({system:D(r),document:v(r)})),d=E().shape({name:P().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:x,handleSubmit:h,reset:s}=$({resolver:k(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:l,clearDataFn:()=>{},navigate:y=>{}};n(C(m)),o(),n(p({})),s()}else{const m={obj:{id:a,name:r.name},pageParams:l,clearDataFn:()=>{},navigate:y=>{}};n(w(m)),n(p({})),o(),s()}};return e.jsx(e.Fragment,{children:e.jsxs(z,{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:[a==null||a==0?"Add ":"Update ",u,e.jsx(A,{onClick:o,children:e.jsx(F,{color:"white"})})]}),e.jsx(B,{sx:{px:"24px",pt:"12px !important",pb:0},children:e.jsx(R,{id:"alert-dialog-description",sx:{width:500},children:e.jsxs("form",{style:{width:"100%"},onSubmit:h(b),children:[e.jsx(q,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter Document here...",control:x}),e.jsxs(T,{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};
