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-ba11e6ab.js";import{T as L}from"./index-cbb0ce26.js";import{M as U}from"./MasterPageTitle-6247bce5.js";import{A as X}from"./add.expenses-6a01f273.js";import{c as w,b as ee,u as te}from"./index.esm-39ef576a.js";import{o as se}from"./yup-902af9ab.js";import{T as re}from"./Tooltip-0b246907.js";import{Z as oe}from"./Zoom-60edb791.js";import{P as ae}from"./Select-f9434f8a.js";import{C as ie}from"./CardContent-9c57d232.js";import{G as ne}from"./Grid2-12794a3c.js";import{T as pe}from"./TextField-16337ecc.js";import{I as le}from"./InputAdornment-0f07311f.js";import"./TableRow-e1616615.js";import"./useMediaQuery-c8eb26e5.js";import"./TableContainer-9178cc85.js";import"./TableHead-5a0d8cfc.js";import"./Grow-1038181b.js";import"./TablePagination-3b5112dd.js";import"./KeyboardArrowRight-36117cc9.js";import"./Toolbar-c7a1b81e.js";import"./MenuItem-e4578955.js";import"./dividerClasses-ab944802.js";import"./listItemTextClasses-a4497781.js";import"./index.esm-c4573c1c.js";import"./Divider-7b675f59.js";import"./FilterFilled-94a9d775.js";import"./AntdIcon-d49f53d6.js";import"./objectSpread2-d72b34ab.js";import"./index-33824b7d.js";import"./GenericThumbnailView-511a7e33.js";import"./popper-f3391c26.js";import"./ScrollableList-b4fc4d99.js";import"./CircularProgress-509803a6.js";import"./FormInput-3e62ad24.js";import"./FormControlLabel-8048035a.js";import"./Checkbox-3e187368.js";import"./SwitchBase-7d4e0bc8.js";import"./componentStyles-cc6f218d.js";import"./TextArea-1c46e0e4.js";import"./DialogContent-af77e042.js";import"./DialogTitle-dc43931f.js";import"./DialogContentText-990aa19e.js";import"./DialogActions-3fe54b4c.js";import"./index-e5978b8b.js";import"./isMuiElement-f8265807.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};
