From 254bc9f40e952bf571867e7b0dea3a0eb8a26c6b Mon Sep 17 00:00:00 2001 From: Yashwin Date: Fri, 27 Mar 2026 16:39:48 +0530 Subject: [PATCH] refactor: Replace document action dropdown with status-specific buttons and simplify supplier table layout. --- src/pages/tenant/Suppliers.tsx | 10 ++-- src/pages/tenant/ViewDocument.tsx | 87 +++++++++++++++++-------------- 2 files changed, 54 insertions(+), 43 deletions(-) diff --git a/src/pages/tenant/Suppliers.tsx b/src/pages/tenant/Suppliers.tsx index 073aa5a..d39eca0 100644 --- a/src/pages/tenant/Suppliers.tsx +++ b/src/pages/tenant/Suppliers.tsx @@ -13,14 +13,14 @@ const Suppliers = (): ReactElement => { >
-
-
+ {/*
*/} + {/*

Suppliers

-
- -
+
*/} + + {/*
*/}
diff --git a/src/pages/tenant/ViewDocument.tsx b/src/pages/tenant/ViewDocument.tsx index bb32c25..e04e54b 100644 --- a/src/pages/tenant/ViewDocument.tsx +++ b/src/pages/tenant/ViewDocument.tsx @@ -1,4 +1,4 @@ -import { useEffect, useMemo, useState, type ReactElement } from "react"; +import { useEffect, useState, type ReactElement } from "react"; import { useNavigate, useParams } from "react-router-dom"; import { Layout } from "@/components/layout/Layout"; import { @@ -14,7 +14,7 @@ import { documentService, type FileAttachmentItem } from "@/services/document-se import { workflowService } from "@/services/workflow-service"; import type { DocumentDetail, DocumentVersion } from "@/types/document"; import { showToast } from "@/utils/toast"; -import { ChevronDown, Paperclip, Plus } from "lucide-react"; +import { Paperclip, Plus } from "lucide-react"; const formatDateTime = (value?: string | null): string => { if (!value) return "-"; @@ -56,7 +56,7 @@ const ViewDocument = (): ReactElement => { const [activeTab, setActiveTab] = useState<"overview" | "version-history">( "overview", ); - const [actionMenuOpen, setActionMenuOpen] = useState(false); + const [activeAction, setActiveAction] = useState(null); const [isActionLoading, setIsActionLoading] = useState(false); const [workflowDefinitionId, setWorkflowDefinitionId] = useState(""); @@ -182,7 +182,6 @@ const ViewDocument = (): ReactElement => { }; const openActionModal = async (action: DocumentAction): Promise => { - setActionMenuOpen(false); if (action === "checkin") { await handleAction(action); return; @@ -332,18 +331,7 @@ const ViewDocument = (): ReactElement => { }, ]; - const actionOptions: DocumentAction[] = useMemo( - () => [ - "submit", - "approve", - "reject", - "effective", - "obsolete", - "checkout", - "checkin", - ], - [], - ); + return ( { {document?.document_number || "-"}

-
- - {actionMenuOpen && ( -
- {actionOptions.map((action) => ( - - ))} -
+
+ {document?.status === "draft" && ( + + )} + {document?.status === "in_review" && ( + <> + + + + )} + {document?.status === "approved" && ( + + )} + {document?.status === "effective" && ( + )}