import { Injectable } from '@nestjs/common';
import { WidgetsCollectionService } from '@app/event-emitter/dashboards/widgets-collection.service';
import { IssuesByTagsWidgetDataLoaderService } from './widget-data-loader/issues-by-tags.widget-data-loader.service';
import { createInteractiveWidget } from '@app/event-emitter/dashboards/interactive-widget-factory';
import { DailyEccmReportsV2DataLoaderService } from 'src/eccm-statistic/dashboards/widget-data-loader/daily-eccm-v2.widget-data-loader.service';
import { WIDGET_TYPE as DAILY_ECCM_V2_WIDGET_TYPE } from 'src/reports/daily-eccm-v2-report-task-runner.service';

@Injectable()
export class DashboardInitService {
  constructor(
    private issuesByTagsWidgetDataLoaderService: IssuesByTagsWidgetDataLoaderService,
    private dailyEccmReportsV2DataLoaderService: DailyEccmReportsV2DataLoaderService,
    private widgetsCollectionService: WidgetsCollectionService,
  ) {}

  init(): void {
    const collection = [
      createInteractiveWidget(
        this.issuesByTagsWidgetDataLoaderService,
        'kanban_by_tags',
      ),
      createInteractiveWidget(
        this.issuesByTagsWidgetDataLoaderService,
        'issues_list_by_tags',
      ),
      createInteractiveWidget(
        this.dailyEccmReportsV2DataLoaderService,
        DAILY_ECCM_V2_WIDGET_TYPE,
      ),
    ];
    collection.forEach((w) => this.widgetsCollectionService.appendWidget(w));
  }
}
