import{d as O,z as R,a as F,eA as N,r,eF as i,eG as $,M as x,j as t,B as o,a2 as H,T as Z,R as y,eH as G}from"./index-c121b02d.js";import{C as L}from"./index-ae3694f0.js";import{P as V}from"./index-3854e5c3.js";import{d as q}from"./Delete-5ebded29.js";import{v as J}from"./View-afd49d05.js";import{P as K}from"./Select-dd7adaf8.js";import{T as f}from"./Tooltip-4b00e924.js";import{Z as C}from"./Zoom-7d897850.js";import"./Grow-9a484472.js";import"./componentStyles-2d610038.js";import"./TableRow-0b65a5b3.js";import"./TableContainer-be48ac32.js";import"./TableHead-9a25be14.js";import"./TablePagination-6fddb4ff.js";import"./KeyboardArrowRight-87bf88d8.js";import"./LastPage-df7292bf.js";import"./Toolbar-600c82f3.js";import"./MenuItem-0f1fc7f8.js";import"./dividerClasses-81752629.js";import"./listItemTextClasses-27b4ea1b.js";import"./listItemIconClasses-b2c374f0.js";import"./Add-ecd3d0c0.js";import"./Tabs-e031f9f3.js";import"./index-e5978b8b.js";import"./Badge-fa1b30d0.js";import"./yup-1361ecb6.js";import"./index.esm-0c6778ff.js";import"./Breadcrumbs-77d32fc3.js";import"./Link-58b976d6.js";import"./Divider-6da4bf5c.js";import"./TextField-f9d2a024.js";import"./isMuiElement-d52f64c2.js";import"./InputAdornment-ae4c2625.js";import"./popper-f3391c26.js";function Ee(){const s=O(),j=R(),{payments:{paymentsEntriesList:l,paymentsEntriesPageParams:a,paymentsEntriesCount:p,loading:P}}=F(e=>N(e)),[v,c]=r.useState(null),[b,d]=r.useState(!1),[D,h]=r.useState(null),_=(e,n)=>{c(e.currentTarget),d(!0),h(n)},m=()=>{d(!1),c(null),h(null)},k=e=>{e&&s(G({id:e,params:a})),m()};r.useEffect(()=>{s(i({...a,search:"",page:1,page_size:10})),s($({}))},[]);const z=({search:e})=>{s(i({...a,search:e??"",page:1}))},B=(e,n)=>{s(i({...a,page:n+1}))},E=e=>{s(i({...a,page:1,page_size:parseInt(e.target.value)}))},I=e=>{s(i({...a,ordering:a.ordering===`-${e}`?e:`-${e}`,page:1}))},S=[{title:"S.No",width:60},{title:"Date",width:130},{title:"Remarks",width:200},{title:"Items Count",width:120},{title:"Created By",width:150},{title:"Created On",width:140,sortable:!0,field:"created_on"},{title:"Actions",width:100}],Y=r.useMemo(()=>l==null?void 0:l.map((e,n)=>{var u,g;const A=(a.page-1)*a.page_size+(n+1),T=t.jsxs(o,{sx:{display:"flex",gap:1,alignItems:"center"},children:[t.jsx(f,{TransitionComponent:C,title:"View",children:t.jsx(o,{sx:{cursor:"pointer",display:"flex",alignItems:"center"},onClick:()=>j(`/pages/sidemenu/payments/view/${e.id}`),children:t.jsx("img",{src:J,alt:"view",style:{width:18,height:18}})})}),t.jsx(f,{TransitionComponent:C,title:"Delete",children:t.jsx(o,{sx:{cursor:"pointer",display:"flex",alignItems:"center"},onClick:M=>_(M,e.id??""),children:t.jsx("img",{src:q,alt:"delete",style:{width:18,height:18}})})})]});return{index:A,date:e!=null&&e.date?x(e.date).format("DD-MM-YYYY"):"--",remarks:(e==null?void 0:e.remarks)??"--",itemsCount:((u=e==null?void 0:e.payment_items)==null?void 0:u.length)??0,createdBy:((g=e==null?void 0:e.created_by)==null?void 0:g.fullname)??"--",createdOn:e!=null&&e.created_on?x(e.created_on).format("DD-MM-YYYY"):"--",actions:T}}),[l,a]);return t.jsxs(o,{sx:{display:"grid",gap:.5,mt:-1.7},children:[t.jsx(V,{title:"Payments",addButtonLabel:"",breadcrumbs:[],showAddButton:!1,applabel:"Payments",model:"payment",count:p,handleSearch:z,fetchapi:i,showFilterButton:!1,openFilter:()=>{},pageParams:a,buttons:{list:!0,thumbnail:!1,grid:!1}}),t.jsx(H,{children:t.jsx(L,{showPagination:!0,columns:S,rows:Y??[],count:p,page:a.page,pageSize:a.page_size,loading:P,handleSort:I,handleChangePage:B,handleChangeRowsPerPage:E})}),t.jsx(K,{open:b,anchorEl:v,onClose:m,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:t.jsxs(o,{sx:{p:2},children:[t.jsx(Z,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure you want to delete this payment?"}),t.jsx(y,{variant:"contained",color:"primary",onClick:()=>k(D),children:"Yes"}),t.jsx(y,{variant:"outlined",size:"small",onClick:m,sx:{ml:2},children:"No"})]})})]})}export{Ee as default};
