From 7dfabb1e7fe1e57ad953ee2df41287b58d762a80 Mon Sep 17 00:00:00 2001 From: Kristof Csillag Date: Thu, 23 Jan 2025 00:25:53 +0100 Subject: [PATCH] Simplify table --- src/app/components/Table/index.tsx | 98 ++++++++++++++---------------- 1 file changed, 47 insertions(+), 51 deletions(-) diff --git a/src/app/components/Table/index.tsx b/src/app/components/Table/index.tsx index 7299b4b71..1b9512810 100644 --- a/src/app/components/Table/index.tsx +++ b/src/app/components/Table/index.tsx @@ -113,73 +113,69 @@ export const Table: FC = ({ }) => { const { isMobile } = useScreenSize() - const isEmpty = !isLoading && !rows?.length - - if (isEmpty && !emptyMessage) { - return null - } - - return ( + return !isLoading && !rows?.length ? ( // This is known to be empty + emptyMessage ? ( // If we have a message, show it + + ) : null // otherwise just show nothing + ) : ( <> - {!isEmpty && ( - - - - - {columns.map((column, index) => { - if (column.hide) { + + + + + {columns.map((column, index) => { + if (column.hide) { + return null + } + return ( + + {column.content} + + ) + })} + + + + {(alwaysWaitWhileLoading || !rows) && isLoading && ( + + )} + {rows?.map(row => ( + + {row.data.map((cell, index) => { + if (cell.hide) { return null } return ( - {column.content} + {cell.content} ) })} - - - - {(alwaysWaitWhileLoading || !rows) && isLoading && ( - - )} - {rows?.map(row => ( - - {row.data.map((cell, index) => { - if (cell.hide) { - return null - } - return ( - - {cell.content} - - ) - })} - - ))} - - - - )} - {!isEmpty && pagination && ( + + ))} + + + + + {pagination && ( )} - {isEmpty && emptyMessage && } ) }