import{d as F,r as n,b6 as R,a as N,pA as V,j as t,B as G,eL as Z,tz as $,I as L,Q,T as W,R as g,tA as p,oh as Y,a2 as q,_ as H,tB as J}from"./index-5ae5cc5e.js";import{T as K}from"./index-7d0c783f.js";import{M as U}from"./MasterPageTitle-426707bb.js";import{A as X}from"./add.expenses-683c1b19.js";import{c as w,b as ee,u as te}from"./index.esm-bd37e938.js";import{o as se}from"./yup-86a48159.js";import{T as re}from"./Tooltip-650e2bc8.js";import{Z as oe}from"./Zoom-9aa3be87.js";import{P as ae}from"./Select-6f375e89.js";import{C as ie}from"./CardContent-12b28b82.js";import{G as ne}from"./Grid2-48c222cb.js";import{T as pe}from"./TextField-013fef4f.js";import{I as le}from"./InputAdornment-c8af61f0.js";import"./TableRow-fbdd6d52.js";import"./useMediaQuery-8780c1c1.js";import"./TableContainer-ed67fdcd.js";import"./TableHead-15aac70d.js";import"./Grow-d70e9b6d.js";import"./TablePagination-63129eb6.js";import"./KeyboardArrowRight-8e772e39.js";import"./LastPage-aa82a010.js";import"./Toolbar-0ec32807.js";import"./MenuItem-dc2bf765.js";import"./dividerClasses-ea2ed133.js";import"./listItemTextClasses-2547faff.js";import"./listItemIconClasses-20c36342.js";import"./index.esm-91b69e04.js";import"./Divider-e1d32c28.js";import"./FilterFilled-40058e95.js";import"./AntdIcon-b932f733.js";import"./objectSpread2-13a56fdb.js";import"./index-125b1c7e.js";import"./GenericThumbnailView-fac7773c.js";import"./createClass-227e27b6.js";import"./popper-f3391c26.js";import"./ScrollableList-2ee889f8.js";import"./CircularProgress-672898c5.js";import"./FormInput-77541d96.js";import"./FormControlLabel-b2fabe81.js";import"./Checkbox-84b6779a.js";import"./SwitchBase-4fa73d90.js";import"./componentStyles-7d84c389.js";import"./TextArea-20f097f8.js";import"./DialogContent-e2578cbd.js";import"./DialogTitle-4a5aec12.js";import"./DialogContentText-bc10bf8d.js";import"./DialogActions-ad26e3d6.js";import"./index-e5978b8b.js";import"./isMuiElement-c29cfc23.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(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(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(L,{onClick:D=>M(D,e==null?void 0:e.id),children:t.jsx(Q,{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(W,{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}))},A=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(Y(e))},O=e=>{const r=e.target.value;a(p({...s,search:r||"",page:1,page_size:10}))},k=n.useMemo(()=>t.jsx(X,{}),[open]);return t.jsxs(t.Fragment,{children:[k,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(q,{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(H,{size:20})})},fullWidth:!0,variant:"outlined",placeholder:"Search",onChange:O})})}),t.jsx(K,{count:T,columns:v,rows:B,loading:E,page:s.page,pageSize:s.page_size,handleChangePage:P,handleChangeRowsPerPage:A})]})})]})};export{pt as default};
