import{d as f,a as g,b as D,oV as v,r as S,j as e,I as A,aK as F,R as c,oW as C,oX as l,oY as w}from"./index-6f149d0c.js";import{c as E,b as $,u as k}from"./index.esm-88773116.js";import{o as q}from"./yup-7ebcc99d.js";import"./GenericThumbnailView-01fef5a2.js";import{F as B}from"./FormInput-d3efc191.js";import"./componentStyles-d6393a0a.js";import"./ScrollableList-e382be10.js";import"./TextArea-eb0beb3a.js";import{D as L}from"./Dialog-4a8f5dd6.js";import{D as P}from"./DialogTitle-0edc620d.js";import{D as R}from"./DialogContent-398aea0b.js";import{D as T}from"./DialogContentText-12f15d60.js";import{D as U}from"./DialogActions-d3c730f9.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:$().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:q(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(L,{open:i,onClose:a,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsxs(P,{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(R,{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(B,{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: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};
