import{b as g,a as f,vE as y,r as E,j as e,I as v,ec as F,B as A,T as D,Q as c,K as n,vF as C,uP as S,vG as w,vH as I}from"./index-76d4793e.js";import{c as B,b as L}from"./index.esm-ad8a7c9f.js";import{o as M}from"./yup-688ec4f6.js";import{u as T}from"./index.esm-3adfd9f7.js";import"./componentStyles-0803b39e.js";import{F as P}from"./FormInput-8f40ded1.js";/* empty css                   */import"./ScrollableList-4dae3697.js";import{L as $}from"./Loader-9f443a4c.js";import{D as k,a as q}from"./DialogContent-7bd8dd8f.js";import{D as z}from"./DialogTitle-71dd5b3a.js";import{D as G}from"./DialogContentText-7642f81f.js";import{D as U}from"./DialogActions-5a5e1db9.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=B().shape({name:L().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:M(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(F,{color:"white"})})]}),e.jsx(q,{sx:{px:"24px",pt:"12px !important",pb:0},children:p?e.jsxs(A,{children:[e.jsx($,{}),e.jsx(D,{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(P,{required:!0,name:"name",label:"Name",type:"text",placeholder:"Enter Expenses here...",control:x})})}),e.jsxs(U,{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};
