From b7e9af9b071feda1a94382720077388cb396f825 Mon Sep 17 00:00:00 2001 From: Firman Ramdhani <33869609+firmanramdhani@users.noreply.github.com> Date: Fri, 24 Jul 2026 13:52:36 +0700 Subject: [PATCH] feat: add custom postfix column support and date formatting in EnterpriseDataTable --- .../components/data-table/index.tsx | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/packages/ui/src/foundations/enterprise-module/components/data-table/index.tsx b/packages/ui/src/foundations/enterprise-module/components/data-table/index.tsx index fb609c0..fc94cf5 100644 --- a/packages/ui/src/foundations/enterprise-module/components/data-table/index.tsx +++ b/packages/ui/src/foundations/enterprise-module/components/data-table/index.tsx @@ -46,6 +46,7 @@ import { BulkActionConfirmationModal } from '../bulk-action-confirmation'; import { TableFilterDrawer, TableFilterConfig } from './components/table-filter-drawer'; // import { TableSettingDrawer } from './components/table-setting-drawer'; import { EntityId } from '../../../../../../core-api/src/data-services/types'; +import { DateUtils } from '@repo/utils'; export * from 'ag-grid-community'; export * from 'ag-grid-react'; @@ -88,6 +89,7 @@ export interface EnterpriseDataTableProps extends Omit[]) => ColDef[]; + customPostfixColumn?: (col: ColDef[]) => ColDef[]; // Action related props statusKey?: string; @@ -154,6 +156,7 @@ export function EnterpriseDataTable(props: EnterpriseDataT noRowsMessage = 'No records found', showStatusbar, customPrefixColumn, + customPostfixColumn, // new action props statusKey = 'status', @@ -665,7 +668,43 @@ export function EnterpriseDataTable(props: EnterpriseDataT statusColumn, ].filter(Boolean); - return [...(customPrefixColumn ? customPrefixColumn(prefixColumn) : prefixColumn), ...columnDefs]; + const postfixColumn: ColDef[] = [ + { + colId: 'creator_name', + field: 'creator_name' as any, + headerName: t('common:fields.createdBy'), + cellRenderer: ({ value }: any) => value ?? '-', + }, + + { + colId: 'created_at', + field: 'created_at', + headerName: t('common:fields.createdAt'), + cellRenderer: ({ value }: any) => { + return value ? new DateUtils(Number(value)).format('DD-MM-YYYY, HH:mm') : '-'; + }, + }, + { + colId: 'editor_name', + field: 'editor_name' as any, + headerName: t('common:fields.updatedBy'), + cellRenderer: ({ value }: any) => value ?? '-', + }, + + { + colId: 'updated_at', + field: 'updated_at', + headerName: t('common:fields.updatedAt'), + cellRenderer: ({ value }: any) => { + return value ? new DateUtils(Number(value)).format('DD-MM-YYYY, HH:mm') : '-'; + }, + }, + ]; + + const finalPrefixColumn = customPrefixColumn ? customPrefixColumn(prefixColumn) : prefixColumn; + const finalPostfixColumn = customPostfixColumn ? customPostfixColumn(postfixColumn) : postfixColumn; + + return [...finalPrefixColumn, ...columnDefs, ...finalPostfixColumn]; }, [ columnDefs, props.masterDetail,