/**
 * @aurora-catalyst-generated
 * @source cliter/o-auth/access-token.aurora.yaml
 */
import { BooleanCell, type DataTableColumnDef } from '@aurora';
import { TranslocoService } from '@jsverse/transloco';
import { type OAuthAccessToken } from '@src/src/app/aurora.types';
import { flexRenderComponent } from '@tanstack/angular-table';

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

  return [
    {
      accessorKey: 'rowId',
      id: 'rowId',
      size: 100,
      label: () => translator?.translate('o-auth.access-token.RowId') ?? 'RowId',
      sortable: true,
      filterable: true,
      exportable: true,
      cell: (info) => `${info.getValue<string>() ?? ''}`,
    },
    {
      accessorKey: 'client.name',
      id: 'client.name',
      size: 220,
      minSize: 140,
      relation: { association: 'client' },
      label: () => translator?.translate('o-auth.access-token.Client') ?? 'Client',
      sortable: true,
      searchable: true,
      filterable: true,
      exportable: true,
      cell: (info) => `${info.getValue<string>() ?? ''}`,
    },
    {
      accessorKey: 'token',
      id: 'token',
      size: 300,
      minSize: 160,
      label: () => translator?.translate('o-auth.access-token.Token') ?? 'Token',
      sortable: true,
      searchable: true,
      filterable: true,
      exportable: true,
      cell: (info) => `${info.getValue<string>() ?? ''}`,
    },
    {
      accessorKey: 'name',
      id: 'name',
      size: 300,
      minSize: 160,
      label: () => translator?.translate('o-auth.access-token.Name') ?? 'Name',
      sortable: true,
      searchable: true,
      filterable: true,
      exportable: true,
      cell: (info) => `${info.getValue<string>() ?? ''}`,
    },
    {
      accessorKey: 'isRevoked',
      id: 'isRevoked',
      size: 100,
      label: () => translator?.translate('o-auth.access-token.IsRevoked') ?? 'IsRevoked',
      sortable: true,
      filterable: true,
      exportable: true,
      cell: () => flexRenderComponent(BooleanCell, { inputs: {} }),
    },
    {
      accessorKey: 'expiresAt',
      id: 'expiresAt',
      size: 140,
      label: () => translator?.translate('o-auth.access-token.ExpiresAt') ?? 'ExpiresAt',
      sortable: true,
      filterable: true,
      exportable: true,
      cell: (info) => `${info.getValue<string>() ?? ''}`,
    },
    {
      accessorFn: (row) => row.refreshToken?.token ?? '',
      id: 'refreshToken.token',
      size: 220,
      minSize: 140,
      relation: { association: 'refreshToken' },
      label: () => translator?.translate('o-auth.access-token.RefreshToken') ?? 'RefreshToken',
      sortable: true,
      searchable: true,
      filterable: true,
      exportable: true,
      cell: (info) => `${info.getValue<string>() ?? ''}`,
    },
  ];
};
