From 4295e7d8d6ef7f4e3dad3bbe27cf82e1f17ccc24 Mon Sep 17 00:00:00 2001 From: Kartik Sharma Date: Mon, 8 Sep 2025 16:04:13 +0530 Subject: [PATCH] UI Changes in Document Details popup. --- .../Documents/DocumentVersionList.jsx | 228 ++++++++---------- src/components/Documents/ViewDocument.jsx | 4 +- 2 files changed, 105 insertions(+), 127 deletions(-) diff --git a/src/components/Documents/DocumentVersionList.jsx b/src/components/Documents/DocumentVersionList.jsx index 87b4004e..aea49267 100644 --- a/src/components/Documents/DocumentVersionList.jsx +++ b/src/components/Documents/DocumentVersionList.jsx @@ -16,36 +16,12 @@ const DocumentVersionList = ({ }) => { const canVerifyDocument = useHasUserPermission(VERIFY_DOCUMENT); const canDownloadDocument = useHasUserPermission(DOWNLOAD_DOCUMENT); + const handleOpenDocument = () => { if (canDownloadDocument) { setOpenDocument(true); } }; - const contentTypeIcons = { - "application/pdf": "fa-solid fa-file-pdf text-primary", - "application/msword": "fa-solid fa-file-word text-primary", - "application/vnd.openxmlformats-officedocument.wordprocessingml.document": - "fa-solid fa-file-word text-primary", - "application/vnd.ms-excel": "fa-solid fa-file-excel text-success", - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": - "fa-solid fa-file-excel text-primary", - "application/vnd.ms-powerpoint": "fa-solid fa-file-powerpoint text-primary", - "application/vnd.openxmlformats-officedocument.presentationml.presentation": - "fa-solid fa-file-powerpoint text-primary", - "image/jpg": "fa-solid fa-file-image text-primary", - "image/jpeg": "fa-solid fa-file-image text-primary", - "image/png": "fa-solid fa-file-image text-primary", - "image/gif": "fa-solid fa-file-image text-primary", - "text/plain": "fa-solid fa-file-lines text-primary", - "text/csv": "fa-solid fa-file-csv text-primary", - "application/json": "fa-solid fa-file-code text-primary", - default: "fa-solid fa-file text-primary", - }; - - const getIcon = (fileName = "") => { - const ext = fileName.split(".").pop().toLowerCase(); - return contentTypeIcons[ext] || contentTypeIcons.default; - }; const sortedVersions = versionList?.data ? [...versionList.data].sort((a, b) => b.version - a.version) @@ -59,123 +35,125 @@ const DocumentVersionList = ({ return

No documents available.

; } - const latestDoc = sortedVersions[0]; - return ( -
-
-

- -

-
+ <> +
+
Documents
+
+ + +
+
+
+
{sortedVersions.map((document, index) => (
0 ? "ms-4" : "" // indent only older versions - }`} + className="list-group-item list-group-item-action" style={{ marginLeft: "-30px" }} > - - -
-
- {document.name} - - Version-{document.version} - {" "} - - File Size: {document.fileSize} Kb - -
-
-
+
+ {/* Left Side: Document Details */} +
+ +
+
+ + {document.name} + +
+
+ {getDocuementsStatus(document.isVerified)} + + File Size: {document.fileSize} Kb + +
- {formatUTCToLocalTime(document?.uploadedAt)} | - Uploaded by{" "} -
+ + Uploaded by + + + + + {`${document.uploadedBy?.firstName ?? ""} ${document.uploadedBy?.lastName ?? ""}`.trim() || "N/A"} + + + + {formatUTCToLocalTime(document?.uploadedAt)} + +
+ {document?.verifiedAt && ( +
+ + {document.isVerified ? "Approved by" : "Rejected by"} + - - {`${document.uploadedBy?.firstName ?? ""} ${document.uploadedBy?.lastName ?? "" - }`.trim() || "N/A"} + + + {`${document.verifiedBy?.firstName ?? ""} ${document.verifiedBy?.lastName ?? ""}`.trim() || "N/A"} + -
-
- -
- {document?.verifiedAt && ( - <> - {formatUTCToLocalTime(document?.verifiedAt)} |{" "} - {document.isVerified - ? "Verified by " - : "Rejected by "} -
- - - {`${document.verifiedBy?.firstName ?? ""} ${document.verifiedBy?.lastName ?? "" - }`.trim() || "N/A"} - -
- - )} -
- - - {document?.updatedAt && ( -
- {formatUTCToLocalTime(document?.updatedAt)} | - Updated by{" "} -
- - - {`${document.updatedBy?.firstName ?? ""} ${document.updatedBy?.lastName ?? "" - }`.trim() || "N/A"} - -
+ + {formatUTCToLocalTime(document?.verifiedAt)} +
)}
+
-
- {getDocuementsStatus(document.isVerified)} + {/* Right Side: Status and Actions */} +
+ {document.isLatest && ( + + latest + + )} + +
+ {document?.updatedBy && ( + <> + Updated by + + + + {`${document.updatedBy?.firstName ?? ""} ${document.updatedBy?.lastName ?? ""}`.trim() || "N/A"} + + + + {formatUTCToLocalTime(document?.updatedAt)} + + + )}
+ + version {document.version} +
@@ -184,7 +162,7 @@ const DocumentVersionList = ({
-
+ ); }; diff --git a/src/components/Documents/ViewDocument.jsx b/src/components/Documents/ViewDocument.jsx index b4e401ce..5eb46f37 100644 --- a/src/components/Documents/ViewDocument.jsx +++ b/src/components/Documents/ViewDocument.jsx @@ -57,7 +57,7 @@ const ViewDocument = () => {

{error?.response?.status}

); - + console.log("kartik", data) return (

Document Details

@@ -150,7 +150,7 @@ const ViewDocument = () => { {isPending ? ( Please Wait... ) : ( - <> + <>