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-c3f592b2.js";import{T as L}from"./index-6f96a8b8.js";import{M as Q}from"./MasterPageTitle-eaa6f939.js";import{A as X}from"./add.expenses-3ee8d0d3.js";import{c as w,b as ee,u as te}from"./index.esm-70dd1c06.js";import{o as se}from"./yup-abb4a026.js";import{T as re}from"./Tooltip-0fd4d2f4.js";import{Z as oe}from"./Zoom-209264bc.js";import{P as ae}from"./Select-9d10c4ab.js";import{C as ie}from"./CardContent-fa813e56.js";import{G as ne}from"./Grid2-9e718eb0.js";import{T as pe}from"./TextField-7d0d5009.js";import{I as le}from"./InputAdornment-fd596377.js";import"./TableRow-974e102e.js";import"./index-88943ce1.js";import"./TableContainer-a7e6bb64.js";import"./TableHead-98885dba.js";import"./Grow-f61cc5ca.js";import"./TablePagination-fd957a04.js";import"./KeyboardArrowRight-8b3fa289.js";import"./LastPage-a52503ff.js";import"./Toolbar-ac8f3726.js";import"./MenuItem-e7a45c4b.js";import"./dividerClasses-03c42ea7.js";import"./listItemTextClasses-3ff99335.js";import"./listItemIconClasses-b60c7a41.js";import"./index.esm-1314deac.js";import"./Divider-057a9865.js";import"./FilterFilled-90800ccd.js";import"./AntdIcon-b07622f5.js";import"./objectSpread2-890c3efa.js";import"./index-78da10f4.js";import"./GenericThumbnailView-9f1d2f81.js";import"./createClass-c7973e27.js";import"./popper-f3391c26.js";import"./ScrollableList-ecbfc0f3.js";import"./FormInput-adbf55b1.js";import"./FormControlLabel-3f9f7a84.js";import"./Checkbox-38171bff.js";import"./SwitchBase-38103115.js";import"./componentStyles-b8fcedb5.js";import"./TextArea-674a9ec6.js";import"./DialogContent-b7fc1c43.js";import"./DialogTitle-5d3e2030.js";import"./DialogContentText-c3e782dc.js";import"./DialogActions-6e00f4f1.js";import"./isMuiElement-43203123.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};
