import{d as F,r as n,b6 as R,a as N,pw as V,j as t,B as G,fr as Z,tz as $,I as Q,Q as W,T as Y,R as g,tA as p,od as q,a2 as H,_ as J,tB as K}from"./index-e972fa8e.js";import{T as L}from"./index-0e298e38.js";import{M as U}from"./MasterPageTitle-fc1ef7a8.js";import{A as X}from"./add.expenses-4b85346c.js";import{c as w,b as ee,u as te}from"./index.esm-b3c20f6d.js";import{o as se}from"./yup-b3178c01.js";import{T as re}from"./Tooltip-9b8e644f.js";import{Z as oe}from"./Zoom-caee0cdd.js";import{P as ae}from"./Select-a2938be0.js";import{C as ie}from"./CardContent-4b9f1338.js";import{G as ne}from"./Grid2-936c64bd.js";import{T as pe}from"./TextField-77f9d647.js";import{I as le}from"./InputAdornment-acd34c72.js";import"./TableRow-c60adf0a.js";import"./useMediaQuery-f8b4772b.js";import"./TableContainer-ad9de4b5.js";import"./TableHead-11d85aea.js";import"./Grow-0b3a9797.js";import"./TablePagination-63dde5fc.js";import"./KeyboardArrowRight-4b11e6b9.js";import"./LastPage-69d51b6f.js";import"./Toolbar-fca75f8a.js";import"./MenuItem-fab52ff5.js";import"./dividerClasses-b771f620.js";import"./listItemTextClasses-f7cdafa8.js";import"./listItemIconClasses-bcb38dc7.js";import"./index.esm-44b3cc2a.js";import"./Divider-1d368ab1.js";import"./FilterFilled-61dd8e74.js";import"./AntdIcon-c86cb7c3.js";import"./objectSpread2-5ffd54f7.js";import"./index-44db81fe.js";import"./GenericThumbnailView-38007944.js";import"./createClass-8ffbea6f.js";import"./popper-f3391c26.js";import"./ScrollableList-4768c2b7.js";import"./CircularProgress-58819244.js";import"./FormInput-dbaa88c2.js";import"./FormControlLabel-77a47114.js";import"./Checkbox-05d562e2.js";import"./SwitchBase-a3d90b7d.js";import"./componentStyles-7142291f.js";import"./TextArea-6c7f39e1.js";import"./DialogContent-51a7b314.js";import"./DialogTitle-6bcbc606.js";import"./DialogContentText-1562904b.js";import"./DialogActions-122de1b4.js";import"./index-e5978b8b.js";import"./isMuiElement-fab695f8.js";const pt=()=>{const a=F();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}}=N(e=>V(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:z,reset:de}=te({resolver:se(b),values:{search:s.search}}),M=(e,r)=>{j(r),h(e.currentTarget)},m=()=>{h(null)},I=e=>{a(K({id:e,clearDataFn:()=>{m()},pageParams:s}))},B=C.map((e,r)=>{const c=(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(Q,{onClick:D=>M(D,e==null?void 0:e.id),children:t.jsx(W,{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(Y,{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)}),_=({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}))},A=n.useMemo(()=>t.jsx(X,{}),[open]);return t.jsxs(t.Fragment,{children:[A,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(_),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(J,{size:20})})},fullWidth:!0,variant:"outlined",placeholder:"Search",onChange:k})})}),t.jsx(L,{count:T,columns:v,rows:B,loading:E,page:s.page,pageSize:s.page_size,handleChangePage:P,handleChangeRowsPerPage:O})]})})]})};export{pt as default};
