From deba5dfa0123064c8e28671dad2366f566563bb0 Mon Sep 17 00:00:00 2001 From: Kartik Sharma Date: Fri, 12 Dec 2025 18:11:38 +0530 Subject: [PATCH] Adding View functionality in Add challan. --- .../purchase/DeliverChallanList.jsx | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/src/components/purchase/DeliverChallanList.jsx b/src/components/purchase/DeliverChallanList.jsx index ee0e1595..89f6d13e 100644 --- a/src/components/purchase/DeliverChallanList.jsx +++ b/src/components/purchase/DeliverChallanList.jsx @@ -2,10 +2,17 @@ import React from "react"; import { useDeliverChallane } from "../../hooks/usePurchase"; import { SpinnerLoader } from "../common/Loader"; import { formatUTCToLocalTime } from "../../utils/dateUtils"; -import { FileView } from "../Expenses/Filelist"; +import { FileView } from "../Expenses/Filelist"; // Assuming FileView is the component showing the file icon/name +import { usePurchaseContext } from "../../pages/purchase/PurchasePage"; +import { getIconByFileType } from "../../utils/appUtils"; + +// Assuming you have an Error component imported somewhere else +// import Error from "../common/Error"; const DeliverChallanList = ({ purchaseId, viewDocuments }) => { + const { setDocumentView } = usePurchaseContext(); const { data, isLoading, isError, error } = useDeliverChallane(purchaseId); + if (isLoading) { return (
@@ -17,10 +24,12 @@ const DeliverChallanList = ({ purchaseId, viewDocuments }) => { if (isError) { return (
+ {/* Assuming Error component is used here */}
); } + if (!isLoading && data.length === 0) return (
@@ -55,8 +64,29 @@ const DeliverChallanList = ({ purchaseId, viewDocuments }) => { {item.description || "-"}

+ {/* Check if attachment exists and open document view on click */} {item.attachment?.preSignedUrl && ( - +
{ + setDocumentView({ + IsOpen: true, + Images: [item.attachment], + }); + }} + > + {/* Replicating the display style used in ViewExpense for single file attachment */} + + + {item.attachment.fileName} + +
)}
@@ -65,4 +95,4 @@ const DeliverChallanList = ({ purchaseId, viewDocuments }) => { ); }; -export default DeliverChallanList; +export default DeliverChallanList; \ No newline at end of file