diff --git a/src/components/collections/AddPayment.jsx b/src/components/collections/AddPayment.jsx index d3e01146..1093728c 100644 --- a/src/components/collections/AddPayment.jsx +++ b/src/components/collections/AddPayment.jsx @@ -11,12 +11,19 @@ import { formatFigure, localToUtc } from "../../utils/appUtils"; import { formatUTCToLocalTime } from "../../utils/dateUtils"; import Avatar from "../common/Avatar"; import { PaymentHistorySkeleton } from "./CollectionSkeleton"; +import { usePaymentType } from "../../hooks/masterHook/useMaster"; const AddPayment = ({ onClose }) => { const { addPayment } = useCollectionContext(); const { data, isLoading, isError, error } = useCollection( addPayment?.invoiceId ); + const { + data: paymentTypes, + isLoading: isPaymentTypeLoading, + isError: isPaymentTypeError, + error: paymentError, + } = usePaymentType(true); const methods = useForm({ resolver: zodResolver(paymentSchema), defaultValues: defaultPayment, @@ -37,7 +44,6 @@ const AddPayment = ({ onClose }) => { paymentReceivedDate: localToUtc(formData.paymentReceivedDate), invoiceId: addPayment.invoiceId, }; - AddPayment(payload); }; const handleClose = (formData) => { @@ -78,6 +84,38 @@ const AddPayment = ({ onClose }) => { )} +
+ + + {errors.paymentAdjustmentHeadId && ( + + {errors.paymentAdjustmentHeadId.message} + + )} +
+
- {data.receivedInvoicePayments.sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt)).map((payment, index) => ( -
-
-
-
-
- - Transaction Date: - {" "} - {formatUTCToLocalTime(payment.paymentReceivedDate)} + {data.receivedInvoicePayments + .sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt)) + .map((payment, index) => ( +
+
+
+
+
+ + Transaction Date: + {" "} + {formatUTCToLocalTime(payment.paymentReceivedDate)} +
+ + {formatFigure(payment.amount, { + type: "currency", + currency: "INR", + })} + +
+ +
+ + Updated By: + {" "} + {" "} + {payment?.createdBy?.firstName}{" "} + {payment.createdBy?.lastName}
- - {formatFigure(payment.amount, { - type: "currency", - currency: "INR", - })} -
-
- Received By:{" "} - {" "} - {payment?.createdBy?.firstName}{" "} - {payment.createdBy?.lastName} -
-
- -
-
-

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

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

{payment?.comment}

+
+
+

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

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

+ {payment?.comment} +

+
-
- ))} + ))}
) diff --git a/src/components/collections/CollectionList.jsx b/src/components/collections/CollectionList.jsx index acfffe23..29f1545e 100644 --- a/src/components/collections/CollectionList.jsx +++ b/src/components/collections/CollectionList.jsx @@ -5,6 +5,7 @@ import { formatFigure, localToUtc, useDebounce } from "../../utils/appUtils"; import { formatUTCToLocalTime } from "../../utils/dateUtils"; import Pagination from "../common/Pagination"; import { useCollectionContext } from "../../pages/collections/CollectionPage"; +import { CollectionTableSkeleton } from "./CollectionSkeleton"; const CollectionList = ({ fromDate, toDate, isPending, searchString }) => { const [currentPage, setCurrentPage] = useState(1); @@ -19,7 +20,8 @@ const CollectionList = ({ fromDate, toDate, isPending, searchString }) => { true, searchDebounce ); - const {setProcessedPayment,setAddPayment,setViewCollection} = useCollectionContext() + const { setProcessedPayment, setAddPayment, setViewCollection } = + useCollectionContext(); const paginate = (page) => { if (page >= 1 && page <= (data?.totalPages ?? 1)) { @@ -127,7 +129,7 @@ const CollectionList = ({ fromDate, toDate, isPending, searchString }) => { }, ]; - if (isLoading) return

Loading...

; + if (isLoading) return ; if (isError) return

{error.message}

; return ( @@ -183,27 +185,50 @@ const CollectionList = ({ fromDate, toDate, isPending, searchString }) => {
diff --git a/src/components/collections/CollectionSkeleton.jsx b/src/components/collections/CollectionSkeleton.jsx index 91ccd18c..82878454 100644 --- a/src/components/collections/CollectionSkeleton.jsx +++ b/src/components/collections/CollectionSkeleton.jsx @@ -30,7 +30,12 @@ export const PaymentHistorySkeleton = ({ count = 2 }) => { {/* Received By (Avatar + Name) */}
- {/* Avatar */} + {" "} + {/* Avatar */} {/* Name */}
@@ -41,3 +46,166 @@ export const PaymentHistorySkeleton = ({ count = 2 }) => { ); }; +export const CollectionDetailsSkeleton = () => { + return ( +
+ {/* Title */} + + + {/* Header Row */} +
+
+ +
+
+ +
+
+ + {/* Project */} +
+
+ +
+
+ + {/* Invoice & E-Invoice */} +
+
+ +
+
+ +
+
+ + {/* Invoice Date & Client Submitted */} +
+
+ +
+
+ +
+
+ + {/* Expected Payment & Mark as Completed */} +
+
+ +
+
+ +
+
+ + {/* Basic & Tax Amount */} +
+
+ +
+
+ +
+
+ + {/* Balance & Created At */} +
+
+ +
+
+ +
+
+ + {/* Created By */} +
+
+ + +
+
+ + {/* Description */} +
+
+ +
+
+ + {/* Attachments */} +
+
+ {[...Array(3)].map((_, idx) => ( + + ))} +
+
+ + {/* Tabs */} +
+
+ + +
+
+ + {/* Tab Content (Comments / Payments) */} + +
+ ); +}; + +export const CollectionTableSkeleton = () => { + const columnCount = 8; + + return ( +
+
+
+ + + + {[...Array(columnCount - 1)].map((_, i) => ( + + ))} + + + + + {[...Array(8)].map((_, rowIdx) => ( + + {[...Array(columnCount - 1)].map((_, colIdx) => ( + + ))} + + + ))} + +
+ + + +
+ + + +
+ + {/* Pagination Skeleton */} +
+ +
+
+
+
+ ); +}; diff --git a/src/components/collections/Comment.jsx b/src/components/collections/Comment.jsx index 11f09829..26c279eb 100644 --- a/src/components/collections/Comment.jsx +++ b/src/components/collections/Comment.jsx @@ -9,7 +9,8 @@ import moment from "moment"; const Comment = ({ invoice }) => { const { - register,reset, + register, + reset, handleSubmit, formState: { errors }, } = useForm({ @@ -17,45 +18,16 @@ const Comment = ({ invoice }) => { defaultValues: { comment: "" }, }); - const { mutate: AddComment, isPending } = useAddComment(() => {reset()}); + const { mutate: AddComment, isPending } = useAddComment(() => { + reset(); + }); const onSubmit = (formData) => { const payload = { ...formData, invoiceId: invoice?.id }; - debugger; AddComment(payload); }; return ( -
- {invoice?.comments?.length > 0 ? ( - invoice.comments.map((comment, index) => ( -
-
-
- - - {comment?.createdBy?.firstName} {comment?.createdBy?.lastName} - -
- - - {moment.utc(comment?.createdAt).local().fromNow()} - -
- -

{comment?.comment}

-
- )) - ) : ( -

No comments yet.

- )} - +