import { Pipe, PipeTransform } from '@angular/core';
import { DateAdapter } from '@ui/common';
import { CalendarIndicator } from '../defs';

@Pipe({
  name: 'uiFilterIndicatorsByDate',
})
export class UiFilterIndicatorsByDatePipe implements PipeTransform {
  constructor(private dateAdapter: DateAdapter) {}
  transform(indicators: CalendarIndicator[], date: Date): any {
    return indicators?.filter((indicator) => this.dateAdapter.equals({ first: indicator.date, second: date, precision: 'day' }));
  }
}
