import{d as f,a as g,b as D,qh as v,r as S,j as e,I as A,aM as F,U as c,qi as C,qj as p,qk as q}from"./index-c3f592b2.js";import{c as w,b as E,u as k}from"./index.esm-70dd1c06.js";import{o as U}from"./yup-abb4a026.js";import"./GenericThumbnailView-9f1d2f81.js";import{F as $}from"./FormInput-adbf55b1.js";import"./componentStyles-b8fcedb5.js";import"./ScrollableList-ecbfc0f3.js";import"./TextArea-674a9ec6.js";import{D as B,a as L}from"./DialogContent-b7fc1c43.js";import{D as P}from"./DialogTitle-5d3e2030.js";import{D as T}from"./DialogContentText-c3e782dc.js";import{D as z}from"./DialogActions-6e00f4f1.js";const M=({modal:i,closeModal:o,mastersName:u,edit_Id:a,mastersValue:N})=>{const n=f(),{document:{selectedData:t,pageParams:l},system:{userAccessList:R}}=g(r=>({system:D(r),document:v(r)})),d=w().shape({name:E().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:U(d),values:{name:t!=null&&t.name?t==null?void 0:t.name:""}}),j=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(q(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(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:[a==null||a==0?"Add ":"Update ",u,e.jsx(A,{onClick:o,children:e.jsx(F,{color:"white"})})]}),e.jsx(L,{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(j),children:[e.jsx($,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter Document here...",control:h}),e.jsxs(z,{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};
