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-c121b02d.js";import{G as z}from"./GoBack-48b594ac.js";import{C as W}from"./index-ae3694f0.js";import{P as A}from"./payments.types-0f415f4f.js";import{C as u}from"./CardContent-ed3e9467.js";import{G as e}from"./Grid2-1ceedf41.js";import{D as B}from"./Divider-6da4bf5c.js";import"./LoadingButton-66be9360.js";import"./Select-dd7adaf8.js";import"./index-e5978b8b.js";import"./Grow-9a484472.js";import"./composeClasses-b42b2e69.js";import"./CircularProgress-fa872e62.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"./isMuiElement-d52f64c2.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};
