import{d as g,a as f,oE as y,r as E,j as e,I as F,aI as A,B as D,T as C,R as i,oF as S,nl as v,oG as I,oH as w}from"./index-83d9c1e2.js";import{c as B,b as L,u as M}from"./index.esm-82874186.js";import{o as T}from"./yup-dfe9f223.js";import"./GenericThumbnailView-ceecb14e.js";import{F as G}from"./FormInput-03b7722e.js";import"./componentStyles-7858e543.js";import{L as $}from"./ScrollableList-2bb71a63.js";import"./TextArea-7d949f4d.js";import{D as k,a as q}from"./DialogContent-a75c4d06.js";import{D as z}from"./DialogTitle-3c642f58.js";import{D as P}from"./DialogContentText-ab545101.js";import{G as c}from"./Grid2-78565a55.js";import{D as R}from"./DialogActions-3c3ab24c.js";const ee=()=>{const a=g(),{expenses:{selectedData:s,pageParams:l,loading:p,isModelVisible:d}}=f(r=>y(r)),o=()=>{a(S({})),h(),a(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(()=>{o()},[]);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 n={obj:{id:t,name:r.name},pageParams:l,clearDataFn:()=>{o()}};a(w(n))}else{const n={obj:{name:r.name},pageParams:l,clearDataFn:()=>{o()}};a(I(n))}};return e.jsx(e.Fragment,{children:e.jsxs(k,{open:d,onClose:o,"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(F,{onClick:o,children:e.jsx(A,{color:"white"})})]}),e.jsx(q,{sx:{px:"24px",pt:"12px !important",pb:0},children:p?e.jsxs(D,{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(c,{container:!0,spacing:2,children:e.jsx(c,{size:{xs:24},children:e.jsx(G,{required:!0,name:"name",label:"Name",type:"text",placeholder:"Enter Expenses here...",control:x})})}),e.jsxs(R,{sx:{p:2},children:[e.jsx(i,{onClick:o,variant:"outlined",color:"secondary",children:"Cancel"}),t?e.jsx(i,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Update"}):e.jsx(i,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Submit"})]})]})})})]})})};export{ee as A};
