import{az as v,d as b,z as w,a as C,eC as D,r as Y,eG as M,eH 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-e6164346.js";import{G as z}from"./GoBack-c758ef34.js";import{C as W}from"./index-cde536dd.js";import{P as B}from"./payments.types-0f415f4f.js";import{C as u}from"./CardContent-f8fb4397.js";import{G as e}from"./Grid2-c9c87842.js";import{D as T}from"./Divider-6099014b.js";import"./LoadingButton-bce4d1bf.js";import"./Select-9c2d8cd2.js";import"./index-e5978b8b.js";import"./Grow-306e2fd0.js";import"./composeClasses-b42b2e69.js";import"./CircularProgress-7d99d864.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"./isMuiElement-5779af4f.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=w(),{payments:{selectedPaymentEntry:a,loading:f}}=C(i=>D(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};
