import {Component} from '@angular/core';
import {ActivatedRoute, Router} from "@angular/router";
import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service";

@Component({
  selector: 'monitor-dataprovider',
  template: `
    <div id="page_content">
      <dataprovider *ngIf="initialized"></dataprovider>
    </div>`,
})
export class MonitorDataProviderComponent {
  initialized: boolean = false;
  
  constructor(private route: ActivatedRoute,
              private router: Router,
              private stakeholderService: StakeholderService) {
  }
  
  ngOnInit() {
    this.route.params.subscribe(params => {
      if (params['stakeholder']) {
        this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
          if (stakeholder) {
            this.initialized = true;
          }
        });
      }
    });
  }
}
