import{d as A,r as n,b7 as R,a as N,qe as V,j as t,B as G,eI as Z,ud as $,I as q,Q,T as W,R as g,ue as p,oX as X,a2 as Y,_ as H,uf as J}from"./index-952e178b.js";import{T as K}from"./index-baa25e61.js";import{M as L}from"./MasterPageTitle-7665a485.js";import{A as U}from"./add.expenses-493c6109.js";import{c as w,b as ee,u as te}from"./index.esm-6feddb16.js";import{o as se}from"./yup-d92565dd.js";import{T as re}from"./Tooltip-2222bd7e.js";import{Z as oe}from"./Zoom-79996292.js";import{P as ae}from"./Select-41d78585.js";import{C as ie}from"./CardContent-f79f90af.js";import{G as ne}from"./Grid2-7b742c2a.js";import{T as pe}from"./TextField-d1a887ff.js";import{I as le}from"./InputAdornment-020147de.js";import"./TableRow-6a27d7f4.js";import"./useMediaQuery-86e0ce33.js";import"./TableContainer-e3ecf13b.js";import"./TableHead-e31d41f4.js";import"./TablePagination-b93979a3.js";import"./KeyboardArrowRight-c3d685e2.js";import"./LastPage-54692111.js";import"./Toolbar-201b514b.js";import"./MenuItem-f41722f4.js";import"./dividerClasses-8e897c94.js";import"./listItemTextClasses-ca40551b.js";import"./listItemIconClasses-3e4286ad.js";import"./index.esm-70af4911.js";import"./Divider-342f1cfc.js";import"./FilterFilled-1ab4da14.js";import"./AntdIcon-54006664.js";import"./objectSpread2-a71852a2.js";import"./index-22eb3e7f.js";import"./GenericThumbnailView-4e535459.js";import"./createClass-5a32667f.js";import"./popper-f3391c26.js";import"./ScrollableList-cd5816a8.js";import"./CircularProgress-3b605689.js";import"./FormInput-8320115a.js";import"./FormControlLabel-973be654.js";import"./Checkbox-6c7c4dc0.js";import"./SwitchBase-bd5cc4c6.js";import"./componentStyles-00160cc0.js";import"./TextArea-ce7716c9.js";import"./DialogContent-4facb916.js";import"./DialogTitle-3aa960f8.js";import"./DialogContentText-54d95680.js";import"./DialogActions-bd200b72.js";import"./index-e5978b8b.js";import"./isMuiElement-f03a71e4.js";const nt=()=>{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: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:M,reset:de}=te({resolver:se(b),values:{search:s.search}}),z=(e,r)=>{j(r),h(e.currentTarget)},m=()=>{h(null)},I=e=>{a(J({id:e,clearDataFn:()=>{m()},pageParams:s}))},_=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:F=>z(F,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)}),B=({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(X(e))},k=e=>{const r=e.target.value;a(p({...s,search:r||"",page:1,page_size:10}))},D=n.useMemo(()=>t.jsx(U,{}),[open]);return t.jsxs(t.Fragment,{children:[D,t.jsx(L,{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(Y,{sx:{marginBottom:"20px",mt:1},children:t.jsxs(ie,{sx:{p:2,borderRadius:"10px"},children:[t.jsx("form",{action:"",onSubmit:y(B),children:t.jsx(ne,{container:!0,mb:2,children:t.jsx(pe,{type:"text",sx:{width:"500px"},...M("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:k})})}),t.jsx(K,{count:T,columns:v,rows:_,loading:E,page:s.page,pageSize:s.page_size,handleChangePage:P,handleChangeRowsPerPage:O})]})})]})};export{nt as default};
