feat: add fields translations to common.json and enhance EnterpriseDataTable with status column and StatusBadge component
This commit is contained in:
@@ -13,7 +13,7 @@ import {
|
||||
} from 'ag-grid-community';
|
||||
import { Box } from '@mantine/core';
|
||||
|
||||
import { DataGrid } from '../../../../components';
|
||||
import { DataGrid, StatusBadge } from '../../../../components';
|
||||
|
||||
import {
|
||||
useEnterpriseModuleDataServiceContext,
|
||||
@@ -108,8 +108,20 @@ export function EnterpriseDataTable<E extends BaseEntity>(props: EnterpriseDataT
|
||||
|
||||
// Ensure column definitions are referentially stable
|
||||
const finalColumnDefs = useMemo<ColDef<E>[]>(() => {
|
||||
return columnDefs;
|
||||
}, [columnDefs]);
|
||||
const masterDetailColumn: ColDef<E> = { maxWidth: 50, sortable: false, cellRenderer: 'agGroupCellRenderer' };
|
||||
const statusColumn: ColDef<E> = {
|
||||
maxWidth: 130,
|
||||
field: 'status' as any,
|
||||
headerName: t('common:fields.status'),
|
||||
cellRenderer: ({ value }: any) => <StatusBadge status={value} />,
|
||||
};
|
||||
|
||||
const prefixColumn: ColDef<E>[] = [props.masterDetail ? masterDetailColumn : (null as any), statusColumn].filter(
|
||||
Boolean,
|
||||
);
|
||||
|
||||
return [...prefixColumn, ...columnDefs];
|
||||
}, [columnDefs, props.masterDetail]);
|
||||
|
||||
// Default configuration applied to all columns in the grid
|
||||
const defaultColDef = useMemo<ColDef>(() => ({ flex: 1, minWidth: 100, sortable: true, resizable: true }), []);
|
||||
|
||||
Reference in New Issue
Block a user