/**
 * @aurora-catalyst-generated
 * @source cliter/iam/permission.aurora.yaml
 */
import { type DataTableColumnDef } from '@aurora';
import { TranslocoService } from '@jsverse/transloco';
import { type IamPermission } from '@src/src/app/aurora.types';

export const getPermissionStandaloneColumns = (properties?: {
  translator?: TranslocoService;
}): DataTableColumnDef<IamPermission>[] => {
  const { translator = null } = properties ?? {};

  return [
    {
      accessorKey: 'rowId',
      id: 'rowId',
      size: 100,
      label: () => translator?.translate('iam.permission.RowId') ?? 'RowId',
      sortable: true,
      filterable: true,
      exportable: true,
      cell: (info) => `${info.getValue<string>() ?? ''}`,
    },
    {
      accessorKey: 'name',
      id: 'name',
      size: 300,
      minSize: 160,
      label: () => translator?.translate('iam.permission.Name') ?? 'Name',
      sortable: true,
      searchable: true,
      filterable: true,
      exportable: true,
      cell: (info) => `${info.getValue<string>() ?? ''}`,
    },
    {
      accessorKey: 'boundedContext.name',
      id: 'boundedContext.name',
      size: 220,
      minSize: 140,
      relation: { association: 'boundedContext' },
      label: () => translator?.translate('iam.permission.BoundedContext') ?? 'BoundedContext',
      sortable: true,
      searchable: true,
      filterable: true,
      exportable: true,
      cell: (info) => `${info.getValue<string>() ?? ''}`,
    },
  ];
};

export const getPermissionEmbedColumns = (properties?: {
  translator?: TranslocoService;
}): DataTableColumnDef<IamPermission>[] =>
  getPermissionStandaloneColumns(properties).filter((c) => c.id !== 'boundedContext.name');
