import {Component, Input} from '@angular/core';
import {Router} from "@angular/router";

@Component({
  selector: 'notifications-list-item',
  templateUrl: 'notifications-list-item.component.html',
  styleUrls: ['notifications-list-item.component.scss']
})
export class NotificationsListItemComponent {
  @Input() notification: any;

  get plan() {
    return this.notification.plan?.data;
  }
  get normative() {
    return this.notification.normative?.data;
  }
  get application() {
    return this.notification.application?.data;
  }
  get poll() {
    return this.notification.poll?.data;
  }

  constructor(private router: Router) {
  }

  ngOnInit() {
  }


  openPlan() {
    this.router.navigate(['plans', this.plan?.id]).then(() => {this.close()});
  }
  openNormative() {
    this.router.navigate(['projects', this.normative?.id]).then(() => {this.close()});
  }
  openApplication() {
    this.router.navigate(['applications', this.application?.id]).then(() => {this.close()});
  }
  openPoll() {
    this.router.navigate(['polls', this.poll?.id]).then(() => {this.close()});
  }



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


}
