import{az as v,d as b,z as D,a as w,eA as C,r as Y,eI as M,eG as _,M as c,j as t,B as N,R as S,eL as k,a2 as x,T as o,S as y}from"./index-5ae5cc5e.js";import{G as z}from"./GoBack-d59c920a.js";import{C as W}from"./index-b50996fd.js";import{P as A}from"./payments.types-0f415f4f.js";import{C as u}from"./CardContent-12b28b82.js";import{G as e}from"./Grid2-48c222cb.js";import{D as B}from"./Divider-e1d32c28.js";import"./LoadingButton-d465030d.js";import"./Select-6f375e89.js";import"./index-e5978b8b.js";import"./Grow-d70e9b6d.js";import"./composeClasses-b42b2e69.js";import"./CircularProgress-672898c5.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"./isMuiElement-c29cfc23.js";function T(r){var n;return r==null?"--":((n=A.find(m=>m.value===r))==null?void 0:n.label)??String(r)}function mt(){var p,l;const{id:r}=v(),n=b(),m=D(),{payments:{selectedPaymentEntry:a,loading:f}}=w(i=>C(i));Y.useEffect(()=>(r&&n(M({id:r})),()=>{n(_({}))}),[r]);const j=[{title:"S.No",width:60},{title:"Amount",width:140},{title:"Payment Date",width:140},{title:"Payment Mode",width:160},{title:"Transaction Number",width:180},{title:"Remarks",width:200}],d=((p=a==null?void 0:a.payment_items)==null?void 0:p.map((i,s)=>({sNo:s+1,amount:i.amount!==void 0?Number(i.amount).toFixed(2):"--",paymentDate:i.payment_date?c(i.payment_date).format("DD-MM-YYYY"):"--",paymentMode:T(i.payment_mode),transactionNumber:i.transaction_number??"--",remarks:i.remarks??"--"})))??[],g=((a==null?void 0:a.payment_items)??[]).reduce((i,s)=>{const h=parseFloat(String((s==null?void 0:s.amount)??0));return i+(isNaN(h)?0:h)},0);return t.jsxs(N,{children:[t.jsx(z,{title:"Payment Details",is_goback:!0,showSaveButton:!1,otherButtons:t.jsx(S,{variant:"contained",size:"small",startIcon:t.jsx(k,{}),onClick:()=>m(`/pages/sidemenu/payments/add/${a==null?void 0:a.id}`),children:"Edit"})}),t.jsx(x,{sx:{mt:2},children:t.jsxs(u,{children:[t.jsx(o,{variant:"h6",fontWeight:600,mb:2,children:"Payment Information"}),t.jsxs(e,{container:!0,spacing:3,children:[t.jsxs(e,{size:{xs:12,sm:6,md:3},children:[t.jsx(o,{variant:"caption",color:"text.secondary",children:"Date"}),t.jsx(o,{variant:"body1",fontWeight:500,children:a!=null&&a.date?c(a.date).format("DD-MM-YYYY"):"--"})]}),t.jsxs(e,{size:{xs:12,sm:6,md:3},children:[t.jsx(o,{variant:"caption",color:"text.secondary",children:"Created By"}),t.jsx(o,{variant:"body1",fontWeight:500,children:((l=a==null?void 0:a.created_by)==null?void 0:l.fullname)??"--"})]}),t.jsxs(e,{size:{xs:12,sm:6,md:3},children:[t.jsx(o,{variant:"caption",color:"text.secondary",children:"Created On"}),t.jsx(o,{variant:"body1",fontWeight:500,children:a!=null&&a.created_on?c(a.created_on).format("DD-MM-YYYY"):"--"})]}),t.jsxs(e,{size:{xs:12},children:[t.jsx(o,{variant:"caption",color:"text.secondary",children:"Remarks"}),t.jsx(o,{variant:"body1",fontWeight:500,children:(a==null?void 0:a.remarks)??"--"})]})]})]})}),t.jsx(x,{sx:{mt:2},children:t.jsxs(u,{children:[t.jsx(o,{variant:"h6",fontWeight:600,mb:2,children:"Payment Items"}),t.jsx(W,{showPagination:!1,columns:j,rows:d,count:d.length,page:1,pageSize:d.length||10,loading:f,handleChangePage:()=>{},handleChangeRowsPerPage:()=>{}}),t.jsx(B,{sx:{mt:2,mb:1}}),t.jsx(y,{direction:"row",justifyContent:"flex-end",pr:2,children:t.jsxs(o,{variant:"subtitle1",fontWeight:600,children:["Total Amount: ",t.jsx(o,{component:"span",variant:"subtitle1",fontWeight:700,color:"primary",children:g.toFixed(2)})]})})]})})]})}export{mt as default};
