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';

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

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