Adding View functionality in Add challan.
This commit is contained in:
parent
bb743d2bb0
commit
deba5dfa01
@ -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 (
|
||||
<div className="d-flex justify-content-center align-items-center text-center vh-50">
|
||||
@ -17,10 +24,12 @@ const DeliverChallanList = ({ purchaseId, viewDocuments }) => {
|
||||
if (isError) {
|
||||
return (
|
||||
<div className="py-3">
|
||||
{/* Assuming Error component is used here */}
|
||||
<Error error={error} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!isLoading && data.length === 0)
|
||||
return (
|
||||
<div className="d-flex justify-content-center align-items-center text-center vh-50">
|
||||
@ -55,8 +64,29 @@ const DeliverChallanList = ({ purchaseId, viewDocuments }) => {
|
||||
{item.description || "-"}
|
||||
</p>
|
||||
|
||||
{/* Check if attachment exists and open document view on click */}
|
||||
{item.attachment?.preSignedUrl && (
|
||||
<FileView file={item.attachment} viewFile={viewDocuments} />
|
||||
<div
|
||||
className="d-flex align-items-center cusor-pointer mt-2"
|
||||
onClick={() => {
|
||||
setDocumentView({
|
||||
IsOpen: true,
|
||||
Images: [item.attachment],
|
||||
});
|
||||
}}
|
||||
>
|
||||
{/* Replicating the display style used in ViewExpense for single file attachment */}
|
||||
<i
|
||||
className={`bx ${getIconByFileType(item.attachment.contentType)}`}
|
||||
style={{ fontSize: "30px" }}
|
||||
></i>
|
||||
<small
|
||||
className="text-start text-tiny text-truncate w-100 ms-1"
|
||||
title={item.attachment.fileName}
|
||||
>
|
||||
{item.attachment.fileName}
|
||||
</small>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
@ -65,4 +95,4 @@ const DeliverChallanList = ({ purchaseId, viewDocuments }) => {
|
||||
);
|
||||
};
|
||||
|
||||
export default DeliverChallanList;
|
||||
export default DeliverChallanList;
|
||||
Loading…
x
Reference in New Issue
Block a user