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 { User } from "src/app/model/auth/user";

@Injectable()
export class UsersColumns extends PageColumns<User> {
  get(): TableColumn<User>[] {
    return [
      ID_COLUMN,
      {
        name: "username",
        label: "user.username",
        type: "text",
        value: (row: User) => row.username,
      },
      {
        name: "email",
        label: "user.email",
        type: "text",
        value: (row: User) => row.email,
      },
      ...DB_MODEL_COLUMNS,
    ];
  }

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