import{b as g,a as f,vJ as y,r as E,j as e,I as v,ec as A,B as D,T as F,Q as c,K as n,vK as C,uU as S,vL as w,vM as I}from"./index-43bf7a1c.js";import{c as L,b as M}from"./index.esm-f9e0a906.js";import{o as B}from"./yup-3b80ed10.js";import{u as T}from"./index.esm-0548c843.js";import"./componentStyles-4624000e.js";import{F as U}from"./FormInput-33b720a4.js";/* empty css                   */import"./ScrollableList-e19132c3.js";import{L as $}from"./Loader-aabe9ed3.js";import{D as k,a as q}from"./DialogContent-d5902709.js";import{D as z}from"./DialogTitle-20dc6f66.js";import{D as K}from"./DialogContentText-abf03c9f.js";import{D as P}from"./DialogActions-d63c6496.js";const ee=()=>{const o=g(),{expenses:{selectedData:s,pageParams:l,loading:p,isModelVisible:m}}=f(r=>y(r)),a=()=>{o(C({})),h(),o(S(!1))},t=s==null?void 0:s.id,d=L().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}=T({resolver:B(d),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(I(i))}else{const i={obj:{name:r.name},pageParams:l,clearDataFn:()=>{a()}};o(w(i))}};return e.jsx(e.Fragment,{children:e.jsxs(k,{open:m,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(v,{onClick:a,children:e.jsx(A,{color:"white"})})]}),e.jsx(q,{sx:{px:"24px",pt:"12px !important",pb:0},children:p?e.jsxs(D,{children:[e.jsx($,{}),e.jsx(F,{textAlign:"center",children:"Loading..."})]}):e.jsx(K,{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(U,{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};
