diff --git a/src/pages/audit/AuditPage.tsx b/src/pages/audit/AuditPage.tsx index e1b7c2a..de3b842 100644 --- a/src/pages/audit/AuditPage.tsx +++ b/src/pages/audit/AuditPage.tsx @@ -51,6 +51,25 @@ const entityTypeBadgeVariant = (type: string) => { const isBadValue = (val: unknown) => val === '-' || val === 'undefined' || val === '' || val === null || val === undefined; +const asAuditText = (val: unknown): string => { + if (isBadValue(val)) return '-'; + if (typeof val === 'string') return val; + if (typeof val === 'object' && val !== null && 'reason' in val) { + const nested = (val as { reason?: unknown }).reason; + return typeof nested === 'string' ? nested : '-'; + } + return String(val); +}; + +const asEntityId = (val: unknown): string => { + if (typeof val === 'string') return val; + if (typeof val === 'object' && val !== null && 'id' in val) { + const id = (val as { id?: unknown }).id; + return typeof id === 'string' ? id : String(id ?? ''); + } + return String(val ?? ''); +}; + const toDateInput = (iso: string | undefined): string => { if (!iso) return ''; return iso.slice(0, 10); @@ -167,7 +186,10 @@ const AuditPage: React.FC = () => { header: t('audit.name'), enableSorting: false, cell: ({ row }) => ( - + ), }, { accessorKey: 'timestamp', header: t('common.date'), enableSorting: true }, @@ -177,7 +199,7 @@ const AuditPage: React.FC = () => { header: t('common.reason'), enableSorting: false, cell: ({ getValue }) => { - const reason = getValue(); + const reason = asAuditText(getValue()); return {reason}; }, },