import{d as f,a as g,b as D,oU as v,r as S,j as e,I as A,aK as F,R as c,oV as C,oW as l,oX as w}from"./index-e6164346.js";import{c as E,b as U,u as $}from"./index.esm-0a041314.js";import{o as k}from"./yup-5fd5d57b.js";import"./GenericThumbnailView-80c6fd98.js";import{F as q}from"./FormInput-859198ec.js";import"./componentStyles-00385170.js";import"./ScrollableList-5a17e8f4.js";import"./TextArea-f5c200de.js";import{D as B}from"./Dialog-2e8a8e2e.js";import{D as L}from"./DialogTitle-8757f50f.js";import{D as P}from"./DialogContent-f10d6731.js";import{D as R}from"./DialogContentText-027be15d.js";import{D as T}from"./DialogActions-31bec80e.js";const _=({modal:i,closeModal:a,mastersName:u,edit_Id:o,mastersValue:V})=>{const n=f(),{document:{selectedData:t,pageParams:p},system:{userAccessList:X}}=g(r=>({system:D(r),document:v(r)})),d=E().shape({name:U().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}=$({resolver:k(d),values:{name:t!=null&&t.name?t==null?void 0:t.name:""}}),b=r=>{if(o==null||o==0){const m={obj:{name:r.name},pageParams:p,clearDataFn:()=>{},navigate:y=>{}};n(C(m)),a(),n(l({})),s()}else{const m={obj:{id:o,name:r.name},pageParams:p,clearDataFn:()=>{},navigate:y=>{}};n(w(m)),n(l({})),a(),s()}};return e.jsx(e.Fragment,{children:e.jsxs(B,{open:i,onClose:a,"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:[o==null||o==0?"Add ":"Update ",u,e.jsx(A,{onClick:a,children:e.jsx(F,{color:"white"})})]}),e.jsx(P,{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:x(b),children:[e.jsx(q,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter Document here...",control:h}),e.jsxs(T,{sx:{p:2},children:[e.jsx(c,{onClick:a,variant:"outlined",color:"secondary",children:"Cancel"}),o==null||o==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};
