import{d as R,r as n,aV as A,a as V,ot as N,j as t,B as G,eR as Z,sd as $,I as W,y as Y,T as q,z as g,se as p,n2 as H,R as J,M as K,sf as L}from"./index-c5c88b67.js";import{T as Q}from"./index-f0b37835.js";import{M as U}from"./MasterPageTitle-405781d7.js";import{A as X}from"./add.expenses-a2cb458d.js";import{c as w,b as ee,u as te}from"./index.esm-81620445.js";import{o as se}from"./yup-41605283.js";import{T as re}from"./Tooltip-7a33c6d6.js";import{Z as oe}from"./Zoom-7991491b.js";import{P as ae}from"./Menu-e7d2b2ee.js";import{C as ie}from"./CardContent-5f043396.js";import{G as ne}from"./Grid2-0ff60c92.js";import{T as pe}from"./TextField-78388962.js";import{I as le}from"./InputAdornment-d66117f3.js";import"./TableRow-2b359fa8.js";import"./useMediaQuery-fe3ce37c.js";import"./TableContainer-c31f204a.js";import"./TableHead-c2c21491.js";import"./Grow-7345f8ea.js";import"./TablePagination-0147f84a.js";import"./KeyboardArrowRight-261f4f43.js";import"./Toolbar-f8d4b0c4.js";import"./Select-4ed8db5d.js";import"./index-e5978b8b.js";import"./MenuItem-81e44793.js";import"./dividerClasses-6bc0ca72.js";import"./listItemTextClasses-88792089.js";import"./index.esm-0ad88c35.js";import"./Divider-0dc41916.js";import"./FilterFilled-9066fadd.js";import"./AntdIcon-1a0d7a6b.js";import"./objectSpread2-65a0d991.js";import"./index-c98d1d89.js";import"./GenericThumbnailView-43782201.js";import"./createClass-fb49042e.js";import"./popper-f3391c26.js";import"./ScrollableList-21ab2b9c.js";import"./CircularProgress-13afa056.js";import"./FormInput-86f14880.js";import"./FormControlLabel-d6955dc8.js";import"./componentStyles-a5e5a830.js";import"./TextArea-aad9dffe.js";import"./DialogContent-1350b249.js";import"./DialogTitle-da236dcc.js";import"./DialogContentText-659ecbc3.js";import"./DialogActions-1232a7fa.js";import"./isMuiElement-b3c21f38.js";const at=()=>{const a=R();n.useState("");const i=A(),[x,h]=n.useState(null),f=!!x,[l,j]=n.useState(null),{expenses:{expensesList:C,pageParams:s,loading:E,expensesCount:T,model:ce},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 y(e,r,m,d){return{index:e,code:r,name:m,actions:d}}let M=w({search:ee()});const{control:me,handleSubmit:S,register:z,reset:de}=te({resolver:se(M),values:{search:s.search}}),b=(e,r)=>{j(r),h(e.currentTarget)},c=()=>{h(null)},I=e=>{a(L({id:e,clearDataFn:()=>{c()},pageParams:s}))},B=C.map((e,r)=>{const m=(s.page-1)*s.page_size+(r+1),d=t.jsxs(G,{justifyContent:"start",alignItems:"center",sx:{display:"flex",gap:2},children:[(o==null?void 0:o.indexOf("Masters.change_expances"))!==-1&&t.jsx(Z,{style:{cursor:"pointer",color:"#fc6f03"},onClick:()=>{a($({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(W,{onClick:F=>b(F,e==null?void 0:e.id),children:t.jsx(Y,{style:{cursor:"pointer",color:"#fc6f03",fontSize:16}})})}),t.jsx(ae,{id:l?String(l):void 0,open:f,anchorEl:x,onClose:c,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:t.jsxs("div",{style:{padding:"15px"},children:[t.jsx(q,{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:c,style:{marginLeft:"20px"},children:"No"})]})})]})]});return y(m,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(H(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(J,{sx:{marginBottom:"20px",mt:1},children:t.jsxs(ie,{sx:{p:2,borderRadius:"10px"},children:[t.jsx("form",{action:"",onSubmit:S(P),children:t.jsx(ne,{container:!0,mb:2,children:t.jsx(pe,{type:"text",sx:{width:"500px"},...z("search"),id:"input-with-icon-textfield",size:"small",InputProps:{startAdornment:t.jsx(le,{position:"start",children:t.jsx(K,{size:20})})},fullWidth:!0,variant:"outlined",placeholder:"Search",onChange:k})})}),t.jsx(Q,{count:T,columns:v,rows:B,loading:E,page:s.page,pageSize:s.page_size,handleChangePage:_,handleChangeRowsPerPage:O})]})})]})};export{at as default};
