import{d as g,a as f,pz as y,r as E,j as e,I as A,aK as D,B as C,T as F,R as n,pA as S,og as v,pB as w,pC as B}from"./index-6f149d0c.js";import{c as I,b as L,u as M}from"./index.esm-88773116.js";import{o as T}from"./yup-7ebcc99d.js";import"./GenericThumbnailView-01fef5a2.js";import{F as z}from"./FormInput-d3efc191.js";import"./componentStyles-d6393a0a.js";import{L as $}from"./ScrollableList-e382be10.js";import"./TextArea-eb0beb3a.js";import{D as k}from"./Dialog-4a8f5dd6.js";import{D as q}from"./DialogTitle-0edc620d.js";import{D as G}from"./DialogContent-398aea0b.js";import{D as P}from"./DialogContentText-12f15d60.js";import{G as p}from"./Grid2-3d1a13f9.js";import{D as R}from"./DialogActions-d3c730f9.js";const se=()=>{const a=g(),{expenses:{selectedData:s,pageParams:l,loading:c,isModelVisible:m}}=f(r=>y(r)),o=()=>{a(S({})),h(),a(v(!1))},t=s==null?void 0:s.id,d=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(()=>{o()},[]);const{control:x,handleSubmit:u,reset:h}=M({resolver:T(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:()=>{o()}};a(B(i))}else{const i={obj:{name:r.name},pageParams:l,clearDataFn:()=>{o()}};a(w(i))}};return e.jsx(e.Fragment,{children:e.jsxs(k,{open:m,onClose:o,"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(A,{onClick:o,children:e.jsx(D,{color:"white"})})]}),e.jsx(G,{sx:{px:"24px",pt:"12px !important",pb:0},children:c?e.jsxs(C,{children:[e.jsx($,{}),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: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:o,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{se as A};
