import{d as A,r as n,b4 as R,a as V,oV as N,j as t,B as Z,f5 as G,sY as Y,I as $,Q,T as W,R as g,sZ as p,nC as q,a2 as H,_ as J,s_ as K}from"./index-858224db.js";import{T as L}from"./index-e980fe31.js";import{M as U}from"./MasterPageTitle-cb9528e3.js";import{A as X}from"./add.expenses-d3976903.js";import{c as w,b as ee,u as te}from"./index.esm-241dec99.js";import{o as se}from"./yup-9213c3af.js";import{T as re}from"./Tooltip-7699ff20.js";import{Z as oe}from"./Zoom-20db8662.js";import{P as ae}from"./Select-8b602eed.js";import{C as ie}from"./CardContent-0d2efdc7.js";import{G as ne}from"./Grid2-274bb638.js";import{T as pe}from"./TextField-bbb2480f.js";import{I as le}from"./InputAdornment-583927e5.js";import"./TableRow-ef998644.js";import"./useMediaQuery-f2f5fd7b.js";import"./TableContainer-0664e137.js";import"./TableHead-cf76ecee.js";import"./Grow-b7b43b3f.js";import"./TablePagination-4cf72ac4.js";import"./KeyboardArrowRight-b25c72ab.js";import"./LastPage-c7260b25.js";import"./Toolbar-9be5abc1.js";import"./MenuItem-bf5218a0.js";import"./dividerClasses-3bf2d765.js";import"./listItemTextClasses-ac0d77df.js";import"./listItemIconClasses-5ed9cb9d.js";import"./index.esm-20949d74.js";import"./Divider-262150be.js";import"./FilterFilled-4ddeca5a.js";import"./AntdIcon-8f3bee6f.js";import"./objectSpread2-cfd43bb2.js";import"./index-9223140c.js";import"./GenericThumbnailView-2d7b7363.js";import"./createClass-042c577b.js";import"./popper-f3391c26.js";import"./ScrollableList-bf78e54b.js";import"./CircularProgress-5bd54bd6.js";import"./FormInput-8eacbbd9.js";import"./FormControlLabel-c742681c.js";import"./Checkbox-57cdf644.js";import"./SwitchBase-959e94f2.js";import"./componentStyles-107bd37e.js";import"./TextArea-78cda1eb.js";import"./DialogContent-e06a39bc.js";import"./DialogTitle-6e616d34.js";import"./DialogContentText-a2775ca2.js";import"./DialogActions-825c19e9.js";import"./index-e5978b8b.js";import"./isMuiElement-ec705bc2.js";const pt=()=>{const a=A();n.useState("");const i=R(),[x,h]=n.useState(null),f=!!x,[l,j]=n.useState(null),{expenses:{expensesList:C,pageParams:s,loading:E,expensesCount:T,model:me},system:{userAccessList:o}}=V(e=>N(e)),v=[{title:"S.No",width:100},{title:"Code",width:100},{title:"Name",width:100},{title:"Actions",width:100}];function S(e,r,c,d){return{index:e,code:r,name:c,actions:d}}let b=w({search:ee()});const{control:ce,handleSubmit:y,register:M,reset:de}=te({resolver:se(b),values:{search:s.search}}),z=(e,r)=>{j(r),h(e.currentTarget)},m=()=>{h(null)},I=e=>{a(K({id:e,clearDataFn:()=>{m()},pageParams:s}))},_=C.map((e,r)=>{const c=(s.page-1)*s.page_size+(r+1),d=t.jsxs(Z,{justifyContent:"start",alignItems:"center",sx:{display:"flex",gap:2},children:[(o==null?void 0:o.indexOf("Masters.change_expances"))!==-1&&t.jsx(G,{style:{cursor:"pointer",color:"#fc6f03"},onClick:()=>{a(Y({id:e==null?void 0:e.id})),u(!0)}}),(o==null?void 0:o.indexOf("Masters.delete_expances"))!==-1&&t.jsxs(t.Fragment,{children:[t.jsx(re,{TransitionComponent:oe,title:"Delete Expances",children:t.jsx($,{onClick:F=>z(F,e==null?void 0:e.id),children:t.jsx(Q,{style:{cursor:"pointer",color:"#fc6f03",fontSize:16}})})}),t.jsx(ae,{id:l?String(l):void 0,open:f,anchorEl:x,onClose:m,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:t.jsxs("div",{style:{padding:"15px"},children:[t.jsx(W,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),t.jsx(g,{variant:"contained",type:"submit",color:"primary",onClick:()=>{I(l)},autoFocus:!0,children:"Yes"}),t.jsx(g,{variant:"outlined",size:"small",onClick:m,style:{marginLeft:"20px"},children:"No"})]})})]})]});return S(c,e.code,e.name,d)}),B=({search:e})=>{a(p({...s,search:e||"",page:1,page_size:10}))},P=(e,r)=>{a(p({...s,search:"",page:r+1}))},O=e=>{a(p({...s,search:"",page:1,page_size:parseInt(e.target.value)}))};n.useEffect(()=>{a(p({...s,search:"",page:1,page_size:10})),i==null||i.setTitle("Expenses"),i==null||i.setSubtitle("Masters")},[]);const u=e=>{a(q(e))},k=e=>{const r=e.target.value;a(p({...s,search:r||"",page:1,page_size:10}))},D=n.useMemo(()=>t.jsx(X,{}),[open]);return t.jsxs(t.Fragment,{children:[D,t.jsx(U,{prefix:"Masters",postfix:"Expenses",pageTitle:"Expenses",goBack:!0,addModelTile:(o==null?void 0:o.indexOf("Masters.add_expances"))!==-1?"Add Expenses":void 0,modalVisible:!0,setIsModalVisible:u,pageText:""}),t.jsx(H,{sx:{marginBottom:"20px",mt:1},children:t.jsxs(ie,{sx:{p:2,borderRadius:"10px"},children:[t.jsx("form",{action:"",onSubmit:y(B),children:t.jsx(ne,{container:!0,mb:2,children:t.jsx(pe,{type:"text",sx:{width:"500px"},...M("search"),id:"input-with-icon-textfield",size:"small",InputProps:{startAdornment:t.jsx(le,{position:"start",children:t.jsx(J,{size:20})})},fullWidth:!0,variant:"outlined",placeholder:"Search",onChange:k})})}),t.jsx(L,{count:T,columns:v,rows:_,loading:E,page:s.page,pageSize:s.page_size,handleChangePage:P,handleChangeRowsPerPage:O})]})})]})};export{pt as default};
