From a26e4d1dc22bbe06c49b2803ec537174e1d9e08f Mon Sep 17 00:00:00 2001 From: "pramod.mahajan" Date: Tue, 14 Oct 2025 14:23:48 +0530 Subject: [PATCH] added skeleton for payment history at add payment form --- src/components/collections/AddPayment.jsx | 60 ++++++++++++++++++- .../collections/CollectionSkeleton.jsx | 43 +++++++++++++ 2 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 src/components/collections/CollectionSkeleton.jsx diff --git a/src/components/collections/AddPayment.jsx b/src/components/collections/AddPayment.jsx index acea7593..2bc97494 100644 --- a/src/components/collections/AddPayment.jsx +++ b/src/components/collections/AddPayment.jsx @@ -7,7 +7,10 @@ import DatePicker from "../common/DatePicker"; import { formatDate } from "date-fns"; import { useCollectionContext } from "../../pages/collections/CollectionPage"; import { useAddPayment, useCollection } from "../../hooks/useCollections"; -import { localToUtc } from "../../utils/appUtils"; +import { formatFigure, localToUtc } from "../../utils/appUtils"; +import { formatUTCToLocalTime } from "../../utils/dateUtils"; +import Avatar from "../common/Avatar"; +import { PaymentHistorySkeleton } from "./CollectionSkeleton"; const AddPayment = ({ onClose }) => { const { addPayment } = useCollectionContext(); @@ -34,7 +37,7 @@ const AddPayment = ({ onClose }) => { paymentReceivedDate: localToUtc(formData.paymentReceivedDate), invoiceId: addPayment.invoiceId, }; - debugger; + AddPayment(payload); }; const handleClose = (formData) => { @@ -116,6 +119,59 @@ const AddPayment = ({ onClose }) => { + {isLoading ? ( + + ) : ( + data?.receivedInvoicePayments?.length > 0 && ( +
+
+ History +
+ +
+ {data.receivedInvoicePayments.map((payment, index) => ( +
+
+
+

+ Date:{" "} + {formatUTCToLocalTime(payment.paymentReceivedDate)} +

{" "} + + {formatFigure(payment.amount, { + type: "currency", + currency: "INR", + })} + +
+ +
+
+

+ Transaction ID:{" "} + {payment.transactionId} +

+
+
+
+ Received By:{" "} + {" "} + {payment?.createdBy?.firstName}{" "} + {payment.createdBy?.lastName} +
+
+
+
+
+ ))} +
+
+ ) + )} ); }; diff --git a/src/components/collections/CollectionSkeleton.jsx b/src/components/collections/CollectionSkeleton.jsx new file mode 100644 index 00000000..91ccd18c --- /dev/null +++ b/src/components/collections/CollectionSkeleton.jsx @@ -0,0 +1,43 @@ +import React from "react"; + +const SkeletonLine = ({ height = 20, width = "100%", className = "" }) => ( +
+); + +export const PaymentHistorySkeleton = ({ count = 2 }) => { + return ( +
+ {[...Array(count)].map((_, idx) => ( +
+
+ {/* Top Row: Date + Amount */} +
+ {/* Date */} + {/* Amount */} +
+ +
+ {/* Transaction ID */} +
+ +
+ + {/* Received By (Avatar + Name) */} +
+ {/* Avatar */} + {/* Name */} +
+
+
+
+ ))} +
+ ); +}; +