import { Pipe, PipeTransform } from '@angular/core';
import { DomainTaskCalendarService, InfoType } from '@domain/task-calendar';
import { DisplayInfoDTO } from '@swagger/eis';
import { isArray } from '@utils/common';

@Pipe({
  name: 'filterType',
})
export class FilterTypePipe implements PipeTransform {
  constructor(private domainTaskCalendarService: DomainTaskCalendarService) {}

  transform(items: DisplayInfoDTO[], types: InfoType[]): any {
    return items?.filter((item) => {
      const type = this.domainTaskCalendarService.getInfoType(item);
      return types.includes(type);
    });
  }
}
