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

@Pipe({
  name: 'filterType',
  standalone: false,
})
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);
    });
  }
}
