From ae1cc331fb1d4263eb990a04bf6e5b130e4b9a98 Mon Sep 17 00:00:00 2001 From: its-kios09 Date: Thu, 19 Sep 2024 01:41:44 +0300 Subject: [PATCH] (feat) Action column only appears if there are any orders with a fulfillerStatus of COMPLETED --- .../common/groupedOrdersTable.component.tsx | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/radiology-tabs/common/groupedOrdersTable.component.tsx b/src/radiology-tabs/common/groupedOrdersTable.component.tsx index 8ad911e..8806b08 100644 --- a/src/radiology-tabs/common/groupedOrdersTable.component.tsx +++ b/src/radiology-tabs/common/groupedOrdersTable.component.tsx @@ -77,15 +77,26 @@ const GroupedOrdersTable: React.FC = (props) => { })); }, [paginatedResults]); - const tableColumns = [ - { id: 0, header: t("patient", "Patient"), key: "patientname" }, - { id: 1, header: t("totalorders", "Total Orders"), key: "totalorders" }, - { - id: 2, - header: t("actionButton", "Action"), - key: "action", - }, - ]; + const tableColumns = useMemo(() => { + const showActionColumn = workListEntries.some( + (order) => order.fulfillerStatus === "COMPLETED" + ); + + const columns = [ + { id: 0, header: t("patient", "Patient"), key: "patientname" }, + { id: 1, header: t("totalorders", "Total Orders"), key: "totalorders" }, + ]; + + if (showActionColumn) { + columns.push({ + id: 2, + header: t("actionButton", "Action"), + key: "action", + }); + } + + return columns; + }, [workListEntries, t]); return (