import{d as A,r as n,aV as R,a as V,ot as N,j as t,B as G,eS 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-4dfc510b.js";import{T as Q}from"./index-2560e6e6.js";import{M as U}from"./MasterPageTitle-68cbcd9e.js";import{A as X}from"./add.expenses-60a45e98.js";import{c as w,b as ee,u as te}from"./index.esm-0a454763.js";import{o as se}from"./yup-80def618.js";import{T as re}from"./Tooltip-cc3e7d19.js";import{Z as oe}from"./Zoom-a3338917.js";import{P as ae}from"./Menu-0f556e12.js";import{C as ie}from"./CardContent-afcdca5e.js";import{G as ne}from"./Grid2-713975b3.js";import{T as pe}from"./TextField-c0d4022e.js";import{I as le}from"./InputAdornment-ccd6e8ff.js";import"./TableRow-bee40746.js";import"./useMediaQuery-75ea24f6.js";import"./TableContainer-3d0f0f18.js";import"./TableHead-c19aff48.js";import"./Grow-a7315f12.js";import"./TablePagination-faf46d98.js";import"./KeyboardArrowRight-605c8352.js";import"./Toolbar-1cf142b4.js";import"./Select-c8503f85.js";import"./index-e5978b8b.js";import"./MenuItem-9737e3d9.js";import"./dividerClasses-26c2a6d6.js";import"./listItemTextClasses-e85f7ff0.js";import"./index.esm-337179d9.js";import"./Divider-1794f57d.js";import"./FilterFilled-dc66781c.js";import"./AntdIcon-90a37458.js";import"./objectSpread2-66550f90.js";import"./index-9a385720.js";import"./GenericThumbnailView-6256cad7.js";import"./popper-f3391c26.js";import"./ScrollableList-bef4a518.js";import"./CircularProgress-d36b5e75.js";import"./FormInput-f887e69c.js";import"./FormControlLabel-e49dd1e5.js";import"./componentStyles-df94248d.js";import"./TextArea-a0cc14f3.js";import"./DialogContent-3bf4ff27.js";import"./DialogTitle-248b1818.js";import"./DialogContentText-a6ab23a2.js";import"./DialogActions-49286e71.js";import"./isMuiElement-7be61a21.js";const ot=()=>{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:S,model:ce},system:{userAccessList:o}}=V(e=>N(e)),T=[{title:"S.No",width:100},{title:"Code",width:100},{title:"Name",width:100},{title:"Actions",width:100}];function v(e,r,m,d){return{index:e,code:r,name:m,actions:d}}let y=w({search:ee()});const{control:me,handleSubmit:M,register:z,reset:de}=te({resolver:se(y),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 v(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:M(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:S,columns:T,rows:B,loading:E,page:s.page,pageSize:s.page_size,handleChangePage:_,handleChangeRowsPerPage:O})]})})]})};export{ot as default};
