import { Pipe, PipeTransform } from '@angular/core';
import { Task, TaskType } from '../defs';

@Pipe({
  name: 'taskTypeCount',
})
export class TaskTypeCountPipe implements PipeTransform {
  transform(tasks: Task[], filterType: TaskType): number {
    if (filterType === 'Info') {
      return tasks.filter((task) => task.type === 'PreInfo' || filterType).length;
    }

    return tasks.filter((task) => task.type === filterType).length;
  }
}
