import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
import { Router } from '@angular/router';
import { UiFilter } from '@ui/filter';
import { MessageBoardItemDTO } from 'apps/hub/notifications/src/lib/defs';

@Component({
  selector: 'modal-notifications-remission-group',
  templateUrl: 'notifications-remission-group.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ModalNotificationsRemissionGroupComponent {
  @Input()
  notifications: MessageBoardItemDTO[];

  @Output()
  navigated = new EventEmitter<void>();

  constructor(private _router: Router) {}

  itemSelected(item: MessageBoardItemDTO) {
    const queryParams = UiFilter.getQueryParamsFromQueryTokenDTO(item.queryToken);
    this._router.navigate(['/filiale/goods/in/results'], { queryParams });
    this.navigated.emit();
  }
}
