From b5d09d2aeaba3dbe12f85de1ba36fe6658cec796 Mon Sep 17 00:00:00 2001 From: estifanos Date: Mon, 27 Jul 2026 08:52:13 +0000 Subject: [PATCH] advanced table fixes --- .../configuration/pages/ConfigurationPage.tsx | 1 + libs/ui/src/lib/data/AdvancedTable.tsx | 124 +++++++++++------- 2 files changed, 75 insertions(+), 50 deletions(-) diff --git a/apps/backoffice/src/app/features/configuration/pages/ConfigurationPage.tsx b/apps/backoffice/src/app/features/configuration/pages/ConfigurationPage.tsx index ac238a204..085e74cf3 100644 --- a/apps/backoffice/src/app/features/configuration/pages/ConfigurationPage.tsx +++ b/apps/backoffice/src/app/features/configuration/pages/ConfigurationPage.tsx @@ -279,6 +279,7 @@ function ProfessionTab() { { header: t("configuration.name"), cell: ({ row }) => row.original.name[locale], + enabled:true }, { header: t("configuration.description"), diff --git a/libs/ui/src/lib/data/AdvancedTable.tsx b/libs/ui/src/lib/data/AdvancedTable.tsx index 4c2fc12cb..4b9a855c8 100644 --- a/libs/ui/src/lib/data/AdvancedTable.tsx +++ b/libs/ui/src/lib/data/AdvancedTable.tsx @@ -9,8 +9,10 @@ import { Pagination, Loader, Center, + Paper, + Badge, } from '@mantine/core'; -import { IconRefresh, IconEye } from '@tabler/icons-react'; +import { IconRefresh, IconEye, IconInbox } from '@tabler/icons-react'; import { useTranslation } from 'react-i18next'; export interface AdvancedColumn { @@ -64,84 +66,106 @@ export function AdvancedTable({ const { t } = useTranslation(); const [visible, setVisible] = useState(columns.map((c) => c.enabled ?? true)); const toggleColumn = (i: number) => - setVisible((prev) => prev.map((v, idx) => (idx === i ? !v : v))); + setVisible((prev) => { + if (prev[i] && prev.filter(Boolean).length === 1) return prev; // keep at least one column visible + return prev.map((v, idx) => (idx === i ? !v : v)); + }); const shownColumns = columns.filter((_, i) => visible[i] ?? true); return ( -
- - {tableName} + + - + {tableName} + + {itemCount} + + + + - + {t('common.toggleColumns', 'Toggle columns')} {columns.map((col, i) => ( toggleColumn(i)}> toggleColumn(i)} + disabled={visible.filter(Boolean).length === 1 && (visible[i] ?? true)} readOnly + tabIndex={-1} + styles={{ input: { cursor: 'pointer' }, label: { cursor: 'pointer' } }} /> ))} {refresh && ( - )} - - - - {shownColumns.map((col, i) => ( - - {col.header} - - ))} - - - - {isLoading ? ( + +
+ - -
- -
-
+ {shownColumns.map((col, i) => ( + + {col.header} + + ))}
- ) : data.length === 0 ? ( - - - - {emptyText ?? t('common.noResult', 'No results')} - - - - ) : ( - data.map((row, rowIndex) => ( - - {shownColumns.map((col, i) => { - const value = getByPath(row, col.accessorKey); - return ( - - {col.cell ? col.cell({ row: { original: row }, value }) : (value as ReactNode) ?? '-'} - - ); - })} +
+ + {isLoading ? ( + + +
+ +
+
- )) - )} -
-
+ ) : data.length === 0 ? ( + + +
+ + + {emptyText ?? t('common.noResult', 'No results')} + +
+
+
+ ) : ( + data.map((row, rowIndex) => ( + + {shownColumns.map((col, i) => { + const value = getByPath(row, col.accessorKey); + return ( + + {col.cell ? col.cell({ row: { original: row }, value }) : (value as ReactNode) ?? '-'} + + ); + })} + + )) + )} + + + {itemCount > pageSize && ( @@ -153,6 +177,6 @@ export function AdvancedTable({ /> )} -
+ ); }