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-0698dbe6.js";import{T as L}from"./index-60056aa1.js";import{M as U}from"./MasterPageTitle-f4c9de66.js";import{A as X}from"./add.expenses-3dd8205e.js";import{c as w,b as ee,u as te}from"./index.esm-85d015f3.js";import{o as se}from"./yup-7a53beb8.js";import{T as re}from"./Tooltip-d8ba7224.js";import{Z as oe}from"./Zoom-5ab18c69.js";import{P as ae}from"./Select-371fc2c6.js";import{C as ie}from"./CardContent-da6ab0f2.js";import{G as ne}from"./Grid2-a3850bef.js";import{T as pe}from"./TextField-4222c766.js";import{I as le}from"./InputAdornment-0c2174b6.js";import"./TableRow-2848b050.js";import"./useMediaQuery-98e2832a.js";import"./TableContainer-99852104.js";import"./TableHead-0cf6a9bf.js";import"./Grow-ea87e600.js";import"./TablePagination-a4795561.js";import"./KeyboardArrowRight-4fe4c481.js";import"./LastPage-1dfd52ba.js";import"./Toolbar-14560ae2.js";import"./MenuItem-aa4e2c66.js";import"./dividerClasses-2d12c750.js";import"./listItemTextClasses-d0728874.js";import"./listItemIconClasses-6eed47b3.js";import"./index.esm-bda38eda.js";import"./Divider-eb09fdb8.js";import"./FilterFilled-b68f936d.js";import"./AntdIcon-ef833303.js";import"./objectSpread2-86ebda25.js";import"./index-c9a9ee7a.js";import"./GenericThumbnailView-dca658f3.js";import"./createClass-61c32f27.js";import"./popper-f3391c26.js";import"./ScrollableList-fc87149c.js";import"./CircularProgress-4f55e66c.js";import"./FormInput-98c39817.js";import"./FormControlLabel-5da20c5e.js";import"./Checkbox-987be799.js";import"./SwitchBase-6519d4d3.js";import"./componentStyles-91278318.js";import"./TextArea-91c96faf.js";import"./DialogContent-6dbfd908.js";import"./DialogTitle-a8d1726a.js";import"./DialogContentText-ceb40f80.js";import"./DialogActions-318201e3.js";import"./index-e5978b8b.js";import"./isMuiElement-d179539f.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};
