import {
  Component,
  OnInit,
  Output,
  EventEmitter
} from '@angular/core';
import { Anim } from './animation';
import { Service } from '@overflow/commons-typescript/model/discovery';

@Component({
  selector: 'of-discovery-search-filter',
  templateUrl: './search-filter.component.html',
  animations: Anim
})
export class SearchFilterComponent implements OnInit {

  services: Service[] = [];
  filterWord: string;

  @Output() search = new EventEmitter<string>();

  constructor(
  ) {
  }

  ngOnInit() {
  }

  onSearch(e) {
    if (e.key !== 'Enter') {
      return;
    }
    this.search.emit(this.filterWord);
  }

  addService(service: Service) {
    // let exist = false;
    // this.services.forEach(value => {
    //   if (value.key === service.key) {
    //     exist = true;
    //     return;
    //   }
    // });
    // if (!exist) {
    //   this.services.push(service);
    //   this.filterServices[service.key] = true;
    // }
    // this.serviceSelect.emit(this.filterServices);
  }

}
