import{d as g,a as y,pw as f,r as E,j as e,I as A,aK as D,B as F,T as C,R as n,px as S,od as v,py as w,pz as I}from"./index-e0c07a84.js";import{c as B,b as L,u as M}from"./index.esm-79617ba5.js";import{o as T}from"./yup-74a95d85.js";import"./GenericThumbnailView-d192caf7.js";import{F as z}from"./FormInput-7bb37f2a.js";import"./componentStyles-5432a72d.js";import{L as $}from"./ScrollableList-874c742d.js";import"./TextArea-e9886f56.js";import{D as k,a as q}from"./DialogContent-bfc00e3a.js";import{D as G}from"./DialogTitle-d1ec1f1a.js";import{D as P}from"./DialogContentText-c88b94b0.js";import{G as p}from"./Grid2-05f25635.js";import{D as R}from"./DialogActions-7f92619e.js";const ee=()=>{const o=g(),{expenses:{selectedData:s,pageParams:l,loading:c,isModelVisible:d}}=y(r=>f(r)),a=()=>{o(S({})),h(),o(v(!1))},t=s==null?void 0:s.id,m=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}=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(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: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(q,{sx:{px:"24px",pt:"12px !important",pb:0},children:c?e.jsxs(F,{children:[e.jsx($,{}),e.jsx(C,{textAlign:"center",children:"Loading..."})]}):e.jsx(P,{id:"alert-dialog-description",sx:{width:500},children:e.jsxs("form",{style:{width:"100%"},onSubmit:u(j),children:[e.jsx(p,{container:!0,spacing:2,children:e.jsx(p,{size:{xs:24},children:e.jsx(z,{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};
