import {Component} from '@angular/core';
import {Router} from "@angular/router";
import {NotificationService} from "@app/_services/notification.service";

@Component({
  templateUrl: 'notifications-list.component.html',
  styleUrls: ['notifications-list.component.scss']
})
export class NotificationsListComponent {
  public notifications: any[] = [];

  constructor(
    private router: Router,
    private notificationService: NotificationService,
  ) {
  }

  ngOnInit() {
    this.fetch();
  }

  close() {
    this.router.navigate([{outlets: {slider: null}}]).then();
  }

  fetch() {
    this.notificationService.getList({include: 'plan,normative,application,poll'}).subscribe(result => {
      this.notifications = result.data;
    });
  }
}
