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

@Pipe({
  name: 'calendarItemsFilterUniqueStatusTypePipe',
})
export class CalendarItemsFilterUniqueStatusTypePipe implements PipeTransform {
  transform(items: CalendarItem[] = []): CalendarItem[] {
    const uniqueColors = Array.from(new Set(items.map((item) => item.color)));
    const uniqueItemsByColor = uniqueColors.map((color) => items.find((item) => item.color === color));

    return uniqueItemsByColor;
  }
}
