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-5ae5cc5e.js";import{C as L}from"./index-b50996fd.js";import{P as V}from"./index-b42f1909.js";import{d as q}from"./Delete-5ebded29.js";import{v as J}from"./View-afd49d05.js";import{P as K}from"./Select-6f375e89.js";import{T as f}from"./Tooltip-650e2bc8.js";import{Z as C}from"./Zoom-9aa3be87.js";import"./Grow-d70e9b6d.js";import"./componentStyles-7d84c389.js";import"./TableRow-fbdd6d52.js";import"./TableContainer-ed67fdcd.js";import"./TableHead-15aac70d.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"./Add-6763b6d4.js";import"./Tabs-0bcc8392.js";import"./index-e5978b8b.js";import"./Badge-936004f7.js";import"./yup-86a48159.js";import"./index.esm-bd37e938.js";import"./Breadcrumbs-271593f6.js";import"./Link-b8158cb8.js";import"./Divider-e1d32c28.js";import"./TextField-013fef4f.js";import"./isMuiElement-c29cfc23.js";import"./InputAdornment-c8af61f0.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};
