import React from "react"; import { useDeliverChallane } from "../../hooks/usePurchase"; import { SpinnerLoader } from "../common/Loader"; import { formatUTCToLocalTime } from "../../utils/dateUtils"; 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 (
); } if (isError) { return (
{/* Assuming Error component is used here */}
); } if (!isLoading && data.length === 0) return (

Not Yet

); return (
{data.map((item) => (
{/* LEFT SIDE */}

{item.deliveryChallanNumber}

{formatUTCToLocalTime(item.deliveryChallanDate)}
Invoice: {item.purchaseInvoice?.title} ( {item.purchaseInvoice?.purchaseInvoiceUId})

Description:{" "} {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}
)}
))}
); }; export default DeliverChallanList;