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-d895656a.js";import{T as Q}from"./index-ea344eac.js";import{M as U}from"./MasterPageTitle-a3ec39dd.js";import{A as X}from"./add.expenses-fca6dcd7.js";import{c as w,b as ee,u as te}from"./index.esm-1087b2f3.js";import{o as se}from"./yup-9573aa79.js";import{T as re}from"./Tooltip-b199707c.js";import{Z as oe}from"./Zoom-19a9db59.js";import{P as ae}from"./Menu-1728e1dd.js";import{C as ie}from"./CardContent-26fc99d8.js";import{G as ne}from"./Grid2-5bd460ea.js";import{T as pe}from"./TextField-6f73e19a.js";import{I as le}from"./InputAdornment-36977269.js";import"./TableRow-5557ab84.js";import"./useMediaQuery-dbbc87b0.js";import"./TableContainer-a89da0a1.js";import"./TableHead-1b575958.js";import"./Grow-d4be81a5.js";import"./TablePagination-582dd1d9.js";import"./KeyboardArrowRight-5067dfe9.js";import"./Toolbar-adca1e0f.js";import"./Select-6d425a72.js";import"./index-e5978b8b.js";import"./MenuItem-f1f55b7e.js";import"./dividerClasses-f4dcf412.js";import"./listItemTextClasses-1ed38b44.js";import"./index.esm-44fedea2.js";import"./Divider-cb9ba1b0.js";import"./FilterFilled-9d5acdc3.js";import"./AntdIcon-19e16777.js";import"./objectSpread2-c21546fe.js";import"./index-45bf15b6.js";import"./GenericThumbnailView-532ea2d7.js";import"./popper-f3391c26.js";import"./ScrollableList-e2b22048.js";import"./CircularProgress-1f3ca34c.js";import"./FormInput-9b5da280.js";import"./FormControlLabel-2fb7bcfb.js";import"./componentStyles-866300fe.js";import"./TextArea-fb0d0821.js";import"./DialogContent-4ce43512.js";import"./DialogTitle-738ca272.js";import"./DialogContentText-8b9b0e0c.js";import"./DialogActions-7b82f6f6.js";import"./isMuiElement-424c145f.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};
