import{d as k,z as N,a as $,eD as F,r as o,eN as n,eI as V,M as x,j as s,B as l,a2 as Z,T as H,R as P,eO as L}from"./index-aa25c5ff.js";import{C as G}from"./index-06082cde.js";import{P as J}from"./index-ea190582.js";import{v as K}from"./View-afd49d05.js";import{P as Q}from"./Select-b8388c2f.js";import{T as U}from"./Tooltip-c7f6fe40.js";import{Z as W}from"./Zoom-01fed3dd.js";import"./Grow-53c7e965.js";import"./componentStyles-e32842f3.js";import"./TableRow-ee82d902.js";import"./TableContainer-150455ba.js";import"./TableHead-7918647e.js";import"./TablePagination-7f533723.js";import"./KeyboardArrowRight-207c2b3b.js";import"./LastPage-cc741249.js";import"./Toolbar-aae1a453.js";import"./MenuItem-6f39aa2e.js";import"./dividerClasses-ce522944.js";import"./listItemTextClasses-88140258.js";import"./listItemIconClasses-31a870c1.js";import"./Add-dbe1ab7b.js";import"./Tabs-53ac51f5.js";import"./index-e5978b8b.js";import"./Badge-9e87965d.js";import"./yup-72cc4918.js";import"./index.esm-a7f661dc.js";import"./Breadcrumbs-ac850034.js";import"./Link-6a2f86f0.js";import"./Divider-52e89c7e.js";import"./TextField-55b66d20.js";import"./isMuiElement-1b254892.js";import"./InputAdornment-1e7eea92.js";import"./popper-f3391c26.js";function zt(){const i=k(),y=N(),{payments:{paymentsEntriesList:r,paymentsEntriesPageParams:a,paymentsEntriesCount:d,loading:C}}=$(t=>F(t)),[_,v]=o.useState(null),[j,b]=o.useState(!1),[A,B]=o.useState(null),m=()=>{b(!1),v(null),B(null)},D=t=>{t&&i(L({id:t,params:a})),m()};o.useEffect(()=>{i(n({...a,search:"",page:1,page_size:10})),i(V({}))},[]);const S=({search:t})=>{i(n({...a,search:t??"",page:1}))},z=(t,p)=>{i(n({...a,page:p+1}))},E=t=>{i(n({...a,page:1,page_size:parseInt(t.target.value)}))},Y=t=>{i(n({...a,ordering:a.ordering===`-${t}`?t:`-${t}`,page:1}))},O=[{title:"S.No",width:60},{title:"Code",width:100},{title:"Date",width:130},{title:"Vendor",width:150},{title:"PO Code",width:100},{title:"Payment Term",width:130},{title:"Amount",width:100},{title:"Paid Amount",width:110},{title:"Balance",width:100},{title:"Status",width:100},{title:"Created By",width:150},{title:"Created On",width:140,sortable:!0,field:"created_on"},{title:"Actions",width:100}],T=o.useMemo(()=>r==null?void 0:r.map((t,p)=>{var c,u,h,g,f;const I=(a.page-1)*a.page_size+(p+1),M=s.jsx(l,{sx:{display:"flex",gap:1,alignItems:"center"},children:s.jsx(U,{TransitionComponent:W,title:"View",children:s.jsx(l,{sx:{cursor:"pointer",display:"flex",alignItems:"center"},onClick:()=>y(`/pages/sidemenu/payments/view/${t.id}`),children:s.jsx("img",{src:K,alt:"view",style:{width:18,height:18}})})})}),e=t==null?void 0:t.payment_request;return{index:I,code:(t==null?void 0:t.code)??"--",date:t!=null&&t.date?x(t.date).format("DD-MM-YYYY"):"--",vendor:((c=e==null?void 0:e.vendor)==null?void 0:c.name)??"--",poCode:((u=e==null?void 0:e.purchaseorder)==null?void 0:u.code)??"--",paymentTerm:((h=e==null?void 0:e.po_payment_term)==null?void 0:h.payment_term)??"--",amount:(e==null?void 0:e.amount)??"--",paidAmount:(e==null?void 0:e.paid_amount)??"--",balance:(e==null?void 0:e.balance_amount)??"--",status:(e==null?void 0:e.status_name)??"--",createdBy:((g=t==null?void 0:t.created_by)==null?void 0:g.fullname)??((f=t==null?void 0:t.created_by)==null?void 0:f.username)??"--",createdOn:t!=null&&t.created_on?x(t.created_on).format("DD-MM-YYYY"):"--",actions:M}}),[r,a]);return s.jsxs(l,{sx:{display:"grid",gap:.5,mt:-1.7},children:[s.jsx(J,{title:"Payments",addButtonLabel:"",breadcrumbs:[],showAddButton:!1,applabel:"Payments",model:"payment",count:d,handleSearch:S,fetchapi:n,showFilterButton:!1,openFilter:()=>{},pageParams:a,buttons:{list:!0,thumbnail:!1,grid:!1}}),s.jsx(Z,{children:s.jsx(G,{showPagination:!0,columns:O,rows:T??[],count:d,page:a.page,pageSize:a.page_size,loading:C,handleSort:Y,handleChangePage:z,handleChangeRowsPerPage:E})}),s.jsx(Q,{open:j,anchorEl:_,onClose:m,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:s.jsxs(l,{sx:{p:2},children:[s.jsx(H,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure you want to delete this payment?"}),s.jsx(P,{variant:"contained",color:"primary",onClick:()=>D(A),children:"Yes"}),s.jsx(P,{variant:"outlined",size:"small",onClick:m,sx:{ml:2},children:"No"})]})})]})}export{zt as default};
