import { Injectable } from '@angular/core';
import { IObjectListUIService } from '@objects-view/interfaces/object-list-ui-service';
import { Router } from '@angular/router';
import { ConfigService } from '@shared/config/config.service';
import { IBaseFleioObjectModel } from '@fleio-api/base-model/base-fleio-object.model';
import { IPermissionsModel } from '@fleio-api/base-model/IPermissionsModel';
import { IObjectUIService } from '@objects-view/interfaces/object-ui-service';
import { FleioObjectsList } from '@fleio-api/fleio-objects-list';
import { IAction } from '@objects-view/interfaces/actions/action';
import { UserProfileUiService } from './user-profile-ui.service';
import { ITableData } from '@objects-view/interfaces/table-data/table-data';
import { IUserProfileModel } from '@fleio-api/profile/model/user-profile.model';

@Injectable({
  providedIn: 'root'
})
export class UserProfileListUiService implements IObjectListUIService {
  constructor(
    private router: Router, private config: ConfigService,
  ) {
  }

  getTableData(objectList: FleioObjectsList<IBaseFleioObjectModel>): ITableData {
    return {
      header: {
        columns: [],
        columnNames: [],
      },
      rows: []
    };
  }

  getObjectUIService(
    object: IBaseFleioObjectModel, permissions: IPermissionsModel, state: string
  ): IObjectUIService {
    return new UserProfileUiService(
      object as IUserProfileModel, permissions, state, this.router, this.config,
    );
  }

  getActions(objectList: FleioObjectsList<IBaseFleioObjectModel>): IAction[] {
    return [];
  }

  getRefreshInterval(): number {
    if (this.config && this.config.current && this.config.current.settings &&
      this.config.current.settings.refreshIntervals) {
      return this.config.current.settings.refreshIntervals.defaultInterval;
    }
    return 10000;
  }
}
