import{b as f,a as g,vJ as y,r as E,j as e,I as v,ef as A,B as D,T as F,P as c,J as n,vK as C,uU as S,vL as w,vM as I}from"./index-d2b25495.js";import{c as L,b as M}from"./index.esm-3043d6d4.js";import{o as B}from"./yup-267e586f.js";import{u as T}from"./index.esm-ce3c2c20.js";import"./componentStyles-0e851d91.js";import{F as P}from"./FormInput-d202e905.js";/* empty css                   */import"./ScrollableList-fc1de312.js";import{L as U}from"./Loader-1b927baf.js";import{D as $,a as k}from"./DialogContent-cded694d.js";import{D as q}from"./DialogTitle-a145b392.js";import{D as z}from"./DialogContentText-43575e44.js";import{D as J}from"./DialogActions-7c802cc8.js";const ee=()=>{const o=f(),{expenses:{selectedData:s,pageParams:l,loading:p,isModelVisible:m}}=g(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($,{open:m,onClose:a,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsxs(q,{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(k,{sx:{px:"24px",pt:"12px !important",pb:0},children:p?e.jsxs(D,{children:[e.jsx(U,{}),e.jsx(F,{textAlign:"center",children:"Loading..."})]}):e.jsx(z,{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(J,{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};
