import { Pipe, PipeTransform } from '@angular/core';
import { Task } from '../defs';
import { DateAdapter } from '../components/calendar/providers';

@Pipe({
  name: 'calendarItemsFilterPipe',
})
export class CalendarItemsFilterPipe implements PipeTransform {
  constructor(private dateAdapter: DateAdapter) {}

  transform(items: Task[] = [], date: Date): Task[] {
    return items.filter((item) => this.dateAdapter.equals(item.date, date));
  }
}
