import{az as v,d as b,z as D,a as w,eD as C,r as Y,eH as M,eI as _,M as c,j as t,B as N,R as S,ew as k,a2 as x,T as o,S as y}from"./index-aa25c5ff.js";import{G as z}from"./GoBack-3be9a532.js";import{C as W}from"./index-06082cde.js";import{P as B}from"./payments.types-0f415f4f.js";import{C as u}from"./CardContent-879d5aba.js";import{G as e}from"./Grid2-d00e0f6a.js";import{D as T}from"./Divider-52e89c7e.js";import"./LoadingButton-bec71809.js";import"./Select-b8388c2f.js";import"./index-e5978b8b.js";import"./Grow-53c7e965.js";import"./composeClasses-b42b2e69.js";import"./CircularProgress-d6cfca6d.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"./isMuiElement-1b254892.js";function A(r){var n;return r==null?"--":((n=B.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:A(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(T,{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};
