From 7e81649841e54c59dd332289904c22a9ed6e863f Mon Sep 17 00:00:00 2001 From: Kartik Sharma Date: Fri, 5 Sep 2025 12:45:28 +0530 Subject: [PATCH 1/4] Toggle Button Functionality for Deleted Notes Not Working Correctly --- src/components/Directory/NotesDirectory.jsx | 78 ++++++++++----------- 1 file changed, 38 insertions(+), 40 deletions(-) diff --git a/src/components/Directory/NotesDirectory.jsx b/src/components/Directory/NotesDirectory.jsx index fab739ee..67c1e239 100644 --- a/src/components/Directory/NotesDirectory.jsx +++ b/src/components/Directory/NotesDirectory.jsx @@ -128,42 +128,40 @@ const NotesDirectory = ({
{" "}
- - + > + Include Deleted Notes + + {!showEditor && (
@@ -225,23 +223,23 @@ const NotesDirectory = ({ )} {!isLoading && notesToDisplay.length > 0 ? notesToDisplay - .slice() - .reverse() - .map((noteItem) => ( - - )) + .slice() + .reverse() + .map((noteItem) => ( + + )) : !isLoading && !showEditor && ( -
{noNotesMessage}
- )} +
{noNotesMessage}
+ )}
); From ef0eff98f83ef1086754c80db90140518727d4c4 Mon Sep 17 00:00:00 2001 From: Kartik Sharma Date: Mon, 8 Sep 2025 14:55:33 +0530 Subject: [PATCH 2/4] Remove unwanted icon --- src/components/Directory/NotesDirectory.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Directory/NotesDirectory.jsx b/src/components/Directory/NotesDirectory.jsx index 67c1e239..b20f9a5e 100644 --- a/src/components/Directory/NotesDirectory.jsx +++ b/src/components/Directory/NotesDirectory.jsx @@ -139,7 +139,7 @@ const NotesDirectory = ({ type="checkbox" className="switch-input" onChange={handleSwitch} - checked={!IsActive} // ✅ invert binding + checked={!IsActive} // invert binding style={{ transform: "scale(0.8)" }} /> Date: Mon, 8 Sep 2025 16:04:13 +0530 Subject: [PATCH 3/4] 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... ) : ( - <> + <> + + + )} +
+ )} + + ); + } + + // If showVersions is true, display all versions if (!sortedVersions.length) { return

No documents available.

; } return ( - <> -
-
Documents
-
- - -
-
-
-
-
-
- {sortedVersions.map((document, index) => ( -
-
- {/* Left Side: Document Details */} -
- -
-
- - {document.name} - -
-
- {getDocuementsStatus(document.isVerified)} - - File Size: {document.fileSize} Kb - -
-
- - Uploaded by +
+
+
+
+ {sortedVersions.map((document, index) => ( +
+
+ {/* Left Side: Document Details */} +
+ +
+
+ + {document.name} + +
+
+ {getDocuementsStatus(document.isVerified)} + + File Size: {document.fileSize} Kb + +
+
+ + 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"} - - {formatUTCToLocalTime(document?.uploadedAt)} -
- {document?.verifiedAt && ( -
- - {document.isVerified ? "Approved by" : "Rejected by"} - - - - - {`${document.verifiedBy?.firstName ?? ""} ${document.verifiedBy?.lastName ?? ""}`.trim() || "N/A"} - - - - {formatUTCToLocalTime(document?.verifiedAt)} - -
- )} -
-
- - {/* 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} - + {/* Conditionally render verified date */} + {document?.verifiedAt && ( + + {formatUTCToLocalTime(document?.verifiedAt)} + + )}
+
+ + version {document.version} + + {document.isLatest && ( + + latest + + )} +
+ {/* Right Side: Status and Actions */} +
+ {/* + version {document.version} + */} + {document.isLatest && ( + + latest + + )} +
+ {document?.updatedBy && ( + <> + Updated by + + + + {`${document.updatedBy?.firstName ?? ""} ${document.updatedBy?.lastName ?? ""}`.trim() || "N/A"} + + + + )} +
+ {/* Conditionally render updated date */} + {document?.updatedAt && ( + + {formatUTCToLocalTime(document?.updatedAt)} + + )} + +
- ))} -
+
+ ))}
- +
); }; diff --git a/src/components/Documents/ViewDocument.jsx b/src/components/Documents/ViewDocument.jsx index 5eb46f37..8270bb08 100644 --- a/src/components/Documents/ViewDocument.jsx +++ b/src/components/Documents/ViewDocument.jsx @@ -1,3 +1,4 @@ +// ViewDocument.jsx import React, { useState } from "react"; import { useDocumentDetails, @@ -12,9 +13,6 @@ import { ITEMS_PER_PAGE, VERIFY_DOCUMENT, } from "../../utils/constants"; -import Pagination from "../common/Pagination"; -import VersionListSkeleton from "./VersionListSkeleton"; -// import DocumentDetailsSkeleton from "./DocumentDetailsSkeleton"; import DocumentDetailsSkeleton from "./DocumentDetailsSkeleton "; import { useHasUserPermission } from "../../hooks/useHasUserPermission"; import DocumentVersionList from "./DocumentVersionList"; @@ -22,15 +20,20 @@ import DocumentVersionList from "./DocumentVersionList"; const ViewDocument = () => { const { viewDoc, setOpenDocument } = useDocumentContext(); const [currentPage, setCurrentPage] = useState(1); + const [showVersions, setShowVersions] = useState(false); const canVerifyDocument = useHasUserPermission(VERIFY_DOCUMENT); + + // Document Details const { data, isLoading, isError, error } = useDocumentDetails( viewDoc?.document ); + + // Document Versions (fetch only if toggle is ON) const { data: versionList, - isLoading: versionLoding, + isLoading: versionLoading, } = useDocumentVersionList( - data?.parentAttachmentId, + showVersions ? data?.parentAttachmentId : null, ITEMS_PER_PAGE - 10, currentPage ); @@ -41,6 +44,7 @@ const ViewDocument = () => { } }; + // Verify / Reject const { mutate: VerifyDoc, isPending } = useVerifyDocument(); const VerifyDocument = () => { VerifyDoc({ documentId: viewDoc?.document, isVerify: true }); @@ -57,11 +61,12 @@ const ViewDocument = () => {

{error?.response?.status}

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

Document Details

+ {/* Document Info Rows */}
@@ -103,14 +108,7 @@ const ViewDocument = () => { {formatUTCToLocalTime(data.uploadedAt)}
-
- - Updated At: - - - {formatUTCToLocalTime(data.updatedAt) || "-"} - -
+
@@ -144,39 +142,32 @@ const ViewDocument = () => {
- {/* Verify / Reject */} - {data.isVerified === null && canVerifyDocument && ( -
- {isPending ? ( - Please Wait... - ) : ( - <> - - - - )} + {/* Toggle for Versions */} +
+

Documents:

+
+ + setShowVersions(e.target.checked)} + />
- )} - +
);