import { Component, OnInit } from '@angular/core';
import { IPluginComponent } from '@shared/plugins/interfaces/plugin-component';
import { ConfigService } from '@shared/config/config.service';
import { DomainApiService } from '@fleio-api/plugins/domains/domain-api.service';
import { NotificationService } from '@shared/ui-api/notification.service';

@Component({
  selector: 'app-domains-dashboard-services-rows',
  templateUrl: './domains-dashboard-services-rows.component.html',
  styleUrls: ['./domains-dashboard-services-rows.component.scss']
})
export class DomainsDashboardServicesRowsComponent implements OnInit, IPluginComponent {
  public data: Record<string, unknown>;
  domainsCount: number;

  constructor(
    public config: ConfigService,
    private domainApiService: DomainApiService,
    private notificationService: NotificationService,
  ) { }

  ngOnInit(): void {
    this.domainApiService.getSummary().subscribe(response => {
      this.domainsCount = response.domains_count;
    }, error => {
      this.notificationService.showMessage($localize`Could not load domains summary`);
    });
  }

}
