import{d as g,a as f,qZ as y,r as E,j as e,I as A,aM as D,B as F,T as C,U as n,q_ as S,pE as v,q$ as q,r0 as w}from"./index-c3f592b2.js";import{c as I,b as M,u as B}from"./index.esm-70dd1c06.js";import{o as L}from"./yup-abb4a026.js";import"./GenericThumbnailView-9f1d2f81.js";import{F as T}from"./FormInput-adbf55b1.js";import"./componentStyles-b8fcedb5.js";import{L as $}from"./ScrollableList-ecbfc0f3.js";import"./TextArea-674a9ec6.js";import{D as U,a as k}from"./DialogContent-b7fc1c43.js";import{D as z}from"./DialogTitle-5d3e2030.js";import{D as G}from"./DialogContentText-c3e782dc.js";import{G as c}from"./Grid2-9e718eb0.js";import{D as P}from"./DialogActions-6e00f4f1.js";const ee=()=>{const o=g(),{expenses:{selectedData:s,pageParams:l,loading:p,isModelVisible:d}}=f(r=>y(r)),a=()=>{o(S({})),h(),o(v(!1))},t=s==null?void 0:s.id,m=I().shape({name:M().required("Please enter your expenses name").trim().matches(/^[a-zA-Z0-9 ]*$/,"Expenses name should not contain special characters")});E.useEffect(()=>{a()},[]);const{control:x,handleSubmit:u,reset:h}=B({resolver:L(m),values:{name:s!=null&&s.name?s==null?void 0:s.name:""}}),j=r=>{if(t){const i={obj:{id:t,name:r.name},pageParams:l,clearDataFn:()=>{a()}};o(w(i))}else{const i={obj:{name:r.name},pageParams:l,clearDataFn:()=>{a()}};o(q(i))}};return e.jsx(e.Fragment,{children:e.jsxs(U,{open:d,onClose:a,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsxs(z,{sx:{bgcolor:"primary.main",color:"white",p:1,px:2,display:"flex",alignItems:"center",justifyContent:"space-between"},variant:"h4",id:"alert-dialog-title",children:[t?"Update ":"Add ","Expenses",e.jsx(A,{onClick:a,children:e.jsx(D,{color:"white"})})]}),e.jsx(k,{sx:{px:"24px",pt:"12px !important",pb:0},children:p?e.jsxs(F,{children:[e.jsx($,{}),e.jsx(C,{textAlign:"center",children:"Loading..."})]}):e.jsx(G,{id:"alert-dialog-description",sx:{width:500},children:e.jsxs("form",{style:{width:"100%"},onSubmit:u(j),children:[e.jsx(c,{container:!0,spacing:2,children:e.jsx(c,{size:{xs:24},children:e.jsx(T,{required:!0,name:"name",label:"Name",type:"text",placeholder:"Enter Expenses here...",control:x})})}),e.jsxs(P,{sx:{p:2},children:[e.jsx(n,{onClick:a,variant:"outlined",color:"secondary",children:"Cancel"}),t?e.jsx(n,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Update"}):e.jsx(n,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Submit"})]})]})})})]})})};export{ee as A};
