import { Injectable, Provider } from '@angular/core';
import {
  DB_MODEL_COLUMNS,
  ID_COLUMN,
  PageColumns,
} from 'src/app/core/base/page.columns';
import { TableColumn } from 'src/app/modules/shared/components/table/table.model';
import { ApiKey } from 'src/app/model/entities/api-key';

@Injectable()
export class ApiKeysColumns extends PageColumns<ApiKey> {
  get(): TableColumn<ApiKey>[] {
    return [
      ID_COLUMN,
      {
        name: 'identifier',
        translationKey: 'common.identifier',
        type: 'text',
        filterable: true,
        value: (row: ApiKey) => row.identifier,
      },
      {
        name: 'key',
        translationKey: 'common.key',
        type: 'password',
        value: (row: ApiKey) => row.key,
      },
      ...DB_MODEL_COLUMNS,
    ];
  }

  static provide(): Provider[] {
    return [
      {
        provide: PageColumns,
        useClass: ApiKeysColumns,
      },
      ApiKeysColumns,
    ];
  }
}
