import{d as f,a as g,b as D,oK as v,r as S,j as e,I as A,aK as F,R as c,oL as C,oM as p,oN as w}from"./index-458d5762.js";import{c as E,b as L,u as $}from"./index.esm-b1b14098.js";import{o as k}from"./yup-536c503d.js";import"./GenericThumbnailView-3cd8dbb5.js";import{F as q}from"./FormInput-3d74947b.js";import"./componentStyles-56425874.js";import"./ScrollableList-ba92364a.js";import"./TextArea-233680fc.js";import{D as B,a as K}from"./DialogContent-2b2d5db0.js";import{D as N}from"./DialogTitle-bda4183d.js";import{D as P}from"./DialogContentText-f6501c39.js";import{D as R}from"./DialogActions-38a5ba62.js";const M=({modal:i,closeModal:o,mastersName:u,edit_Id:a,mastersValue:T})=>{const n=f(),{document:{selectedData:t,pageParams:l},system:{userAccessList:U}}=g(r=>({system:D(r),document:v(r)})),d=E().shape({name:L().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(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(B,{open:i,onClose:o,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsxs(N,{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(K,{sx:{px:"24px",pt:"12px !important",pb:0},children:e.jsx(P,{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(R,{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};
