import{d as k,z as N,a as $,eC as F,r as o,eM as n,eH as H,M as x,j as s,B as l,a2 as V,T as Z,R as P,eN as L}from"./index-e6164346.js";import{C as G}from"./index-cde536dd.js";import{P as J}from"./index-d7588099.js";import{v as K}from"./View-afd49d05.js";import{P as Q}from"./Select-9c2d8cd2.js";import{T as U}from"./Tooltip-c38fd0c1.js";import{Z as W}from"./Zoom-393881cf.js";import"./Grow-306e2fd0.js";import"./componentStyles-00385170.js";import"./TableRow-bf4e60a0.js";import"./TableContainer-7ecd96ea.js";import"./TableHead-0c525f54.js";import"./TablePagination-b02830fa.js";import"./KeyboardArrowRight-73af71dd.js";import"./LastPage-b9dcf78c.js";import"./Toolbar-82d22fac.js";import"./MenuItem-8dd174fb.js";import"./dividerClasses-932c3e8b.js";import"./listItemTextClasses-6b253cb4.js";import"./listItemIconClasses-a58b491d.js";import"./Add-bc2f8db4.js";import"./Tabs-e9b670f1.js";import"./index-e5978b8b.js";import"./Badge-4f6d4e12.js";import"./yup-5fd5d57b.js";import"./index.esm-0a041314.js";import"./Breadcrumbs-1036f3e6.js";import"./Link-03330239.js";import"./Divider-6099014b.js";import"./TextField-db9cff08.js";import"./isMuiElement-5779af4f.js";import"./InputAdornment-59975edf.js";import"./popper-f3391c26.js";function Dt(){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)},S=t=>{t&&i(L({id:t,params:a})),m()};o.useEffect(()=>{i(n({...a,search:"",page:1,page_size:10})),i(H({}))},[]);const z=({search:t})=>{i(n({...a,search:t??"",page:1}))},D=(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}))},T=[{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}],M=o.useMemo(()=>r==null?void 0:r.map((t,p)=>{var c,u,h,g,f;const O=(a.page-1)*a.page_size+(p+1),I=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:O,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:I}}),[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:z,fetchapi:n,showFilterButton:!1,openFilter:()=>{},pageParams:a,buttons:{list:!0,thumbnail:!1,grid:!1}}),s.jsx(V,{children:s.jsx(G,{showPagination:!0,columns:T,rows:M??[],count:d,page:a.page,pageSize:a.page_size,loading:C,handleSort:Y,handleChangePage:D,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(Z,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure you want to delete this payment?"}),s.jsx(P,{variant:"contained",color:"primary",onClick:()=>S(A),children:"Yes"}),s.jsx(P,{variant:"outlined",size:"small",onClick:m,sx:{ml:2},children:"No"})]})})]})}export{Dt as default};
