import{d as g,a as f,pA as y,r as E,j as e,I as A,aK as D,B as C,T as F,R as n,pB as S,oh as v,pC as w,pD as B}from"./index-5ae5cc5e.js";import{c as I,b as L,u as M}from"./index.esm-bd37e938.js";import{o as T}from"./yup-86a48159.js";import"./GenericThumbnailView-fac7773c.js";import{F as $}from"./FormInput-77541d96.js";import"./componentStyles-7d84c389.js";import{L as k}from"./ScrollableList-2ee889f8.js";import"./TextArea-20f097f8.js";import{D as q,a as z}from"./DialogContent-e2578cbd.js";import{D as G}from"./DialogTitle-4a5aec12.js";import{D as P}from"./DialogContentText-bc10bf8d.js";import{G as p}from"./Grid2-48c222cb.js";import{D as R}from"./DialogActions-ad26e3d6.js";const ee=()=>{const o=g(),{expenses:{selectedData:s,pageParams:l,loading:c,isModelVisible:d}}=f(r=>y(r)),a=()=>{o(S({})),u(),o(v(!1))},t=s==null?void 0:s.id,m=I().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:h,reset:u}=M({resolver:T(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(B(i))}else{const i={obj:{name:r.name},pageParams:l,clearDataFn:()=>{a()}};o(w(i))}};return e.jsx(e.Fragment,{children:e.jsxs(q,{open:d,onClose:a,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsxs(G,{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(z,{sx:{px:"24px",pt:"12px !important",pb:0},children:c?e.jsxs(C,{children:[e.jsx(k,{}),e.jsx(F,{textAlign:"center",children:"Loading..."})]}):e.jsx(P,{id:"alert-dialog-description",sx:{width:500},children:e.jsxs("form",{style:{width:"100%"},onSubmit:h(j),children:[e.jsx(p,{container:!0,spacing:2,children:e.jsx(p,{size:{xs:24},children:e.jsx($,{required:!0,name:"name",label:"Name",type:"text",placeholder:"Enter Expenses here...",control:x})})}),e.jsxs(R,{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};
