import{d as g,a as f,ot as y,r as E,j as e,I as A,ax as D,B as F,T as v,z as i,ou as C,n2 as S,ov as w,ow as I}from"./index-d895656a.js";import{c as B,b as L,u as M}from"./index.esm-1087b2f3.js";import{o as T}from"./yup-9573aa79.js";import"./GenericThumbnailView-532ea2d7.js";import{F as z}from"./FormInput-9b5da280.js";import"./componentStyles-866300fe.js";import{L as $}from"./ScrollableList-e2b22048.js";import"./TextArea-fb0d0821.js";import{D as k,a as q}from"./DialogContent-4ce43512.js";import{D as G}from"./DialogTitle-738ca272.js";import{D as P}from"./DialogContentText-8b9b0e0c.js";import{G as c}from"./Grid2-5bd460ea.js";import{D as U}from"./DialogActions-7b82f6f6.js";const ee=()=>{const a=g(),{expenses:{selectedData:s,pageParams:l,loading:p,isModelVisible:d}}=f(r=>y(r)),o=()=>{a(C({})),h(),a(S(!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(I(n))}else{const n={obj:{name:r.name},pageParams:l,clearDataFn:()=>{o()}};a(w(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(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:o,children:e.jsx(D,{color:"white"})})]}),e.jsx(q,{sx:{px:"24px",pt:"12px !important",pb:0},children:p?e.jsxs(F,{children:[e.jsx($,{}),e.jsx(v,{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(z,{required:!0,name:"name",label:"Name",type:"text",placeholder:"Enter Expenses here...",control:x})})}),e.jsxs(U,{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};
