import{d as A,r as n,b4 as R,a as N,oE as V,j as t,B as G,e_ as Z,sH as $,I as H,Q as J,T as Q,R as g,sI as p,nl as W,a2 as Y,_ as q,sJ as K}from"./index-3141de2d.js";import{T as L}from"./index-a22dce01.js";import{M as U}from"./MasterPageTitle-e75bb457.js";import{A as X}from"./add.expenses-804d3298.js";import{c as w,b as ee,u as te}from"./index.esm-8b0c9a99.js";import{o as se}from"./yup-c2fea6fa.js";import{T as re}from"./Tooltip-ca912c56.js";import{Z as oe}from"./Zoom-ef11d3b2.js";import{P as ae}from"./Select-369b8a03.js";import{C as ie}from"./CardContent-97006932.js";import{G as ne}from"./Grid2-488bb30d.js";import{T as pe}from"./TextField-ec161c03.js";import{I as le}from"./InputAdornment-1680248d.js";import"./TableRow-e26106d8.js";import"./useMediaQuery-aa4be5c2.js";import"./TableContainer-e4a79220.js";import"./TableHead-6dad4842.js";import"./Grow-e0aea29d.js";import"./TablePagination-377a84d4.js";import"./KeyboardArrowRight-d5826f7e.js";import"./Toolbar-c1e97401.js";import"./MenuItem-d41bf2e5.js";import"./dividerClasses-752b2dd5.js";import"./listItemTextClasses-5f5f8755.js";import"./index.esm-8b587a7a.js";import"./Divider-e779ddd3.js";import"./FilterFilled-94ea2c05.js";import"./AntdIcon-eb0da2c9.js";import"./objectSpread2-41b8b8d3.js";import"./index-a3f870f6.js";import"./GenericThumbnailView-c2621934.js";import"./popper-f3391c26.js";import"./ScrollableList-fa62971d.js";import"./CircularProgress-a64e9e1b.js";import"./FormInput-abff9e70.js";import"./FormControlLabel-c4983ca8.js";import"./Checkbox-8808455f.js";import"./SwitchBase-416973c8.js";import"./componentStyles-24f97919.js";import"./TextArea-ceaff311.js";import"./DialogContent-17781b67.js";import"./DialogTitle-16416764.js";import"./DialogContentText-c64ca110.js";import"./DialogActions-37bf04e2.js";import"./index-e5978b8b.js";import"./isMuiElement-2bebf9f1.js";const at=()=>{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:ce},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,m,d){return{index:e,code:r,name:m,actions:d}}let b=w({search:ee()});const{control:me,handleSubmit:y,register:M,reset:de}=te({resolver:se(b),values:{search:s.search}}),z=(e,r)=>{j(r),h(e.currentTarget)},c=()=>{h(null)},I=e=>{a(K({id:e,clearDataFn:()=>{c()},pageParams:s}))},_=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(H,{onClick:F=>z(F,e==null?void 0:e.id),children:t.jsx(J,{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 S(m,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(W(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(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(q,{size:20})})},fullWidth:!0,variant:"outlined",placeholder:"Search",onChange:k})})}),t.jsx(L,{count:T,columns:v,rows:_,loading:E,page:s.page,pageSize:s.page_size,handleChangePage:P,handleChangeRowsPerPage:O})]})})]})};export{at as default};
