import{d as A,r as n,b8 as R,a as N,qZ as V,j as t,B as Z,eK as $,v3 as G,I as q,R as K,T as U,U as g,v4 as p,pE as W,a3 as Y,$ as H,v5 as J}from"./index-60657852.js";import{T as L}from"./index-bcfba32e.js";import{M as Q}from"./MasterPageTitle-4d4d4430.js";import{A as X}from"./add.expenses-bf440599.js";import{c as w,b as ee,u as te}from"./index.esm-509a598d.js";import{o as se}from"./yup-75ad371b.js";import{T as re}from"./Tooltip-1a5db018.js";import{Z as oe}from"./Zoom-a3ca5f9d.js";import{P as ae}from"./Select-7d2a5359.js";import{C as ie}from"./CardContent-f8a5d460.js";import{G as ne}from"./Grid2-09163d35.js";import{T as pe}from"./TextField-6b778b78.js";import{I as le}from"./InputAdornment-12fc79ce.js";import"./TableRow-0ab1e69a.js";import"./index-c6051076.js";import"./TableContainer-c3087864.js";import"./TableHead-1ba4d27d.js";import"./Grow-a21bdd26.js";import"./TablePagination-dd506b19.js";import"./KeyboardArrowRight-5039311c.js";import"./LastPage-c4cc7e5b.js";import"./Toolbar-e6f520d9.js";import"./MenuItem-64348b57.js";import"./dividerClasses-590294d7.js";import"./listItemTextClasses-81f8effc.js";import"./listItemIconClasses-39f47a05.js";import"./index.esm-5fae0aa9.js";import"./Divider-6555f8d4.js";import"./FilterFilled-e5a9bf0e.js";import"./AntdIcon-53906b68.js";import"./objectSpread2-b46e5e65.js";import"./index-980acb6c.js";import"./GenericThumbnailView-f8b17afa.js";import"./createClass-2b895736.js";import"./popper-f3391c26.js";import"./ScrollableList-ef4c85dc.js";import"./FormInput-6b018fe9.js";import"./FormControlLabel-95d4d7bb.js";import"./Checkbox-026acf65.js";import"./SwitchBase-3b306fc6.js";import"./componentStyles-19763afb.js";import"./TextArea-d897dbf9.js";import"./DialogContent-d5183bd6.js";import"./DialogTitle-66c21479.js";import"./DialogContentText-e3f3f7dd.js";import"./DialogActions-1dfa5a01.js";import"./isMuiElement-82a67859.js";const it=()=>{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:v,expensesCount:E,model:me},system:{userAccessList:o}}=N(e=>V(e)),T=[{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(J({id:e,clearDataFn:()=>{m()},pageParams:s}))},B=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($,{style:{cursor:"pointer",color:"#fc6f03"},onClick:()=>{a(G({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(q,{onClick:F=>z(F,e==null?void 0:e.id),children:t.jsx(K,{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(U,{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)}),P=({search:e})=>{a(p({...s,search:e||"",page:1,page_size:10}))},_=(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(W(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(Q,{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(Y,{sx:{marginBottom:"20px",mt:1},children:t.jsxs(ie,{sx:{p:2,borderRadius:"10px"},children:[t.jsx("form",{action:"",onSubmit:y(P),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(H,{size:20})})},fullWidth:!0,variant:"outlined",placeholder:"Search",onChange:k})})}),t.jsx(L,{count:E,columns:T,rows:B,loading:v,page:s.page,pageSize:s.page_size,handleChangePage:_,handleChangeRowsPerPage:O})]})})]})};export{it as default};
