import { Component, OnInit } from '@angular/core';

import { SearchService } from 'app/search/service/search-service';

@Component({
  selector: 'jhi-teaser-content',
  templateUrl: './teaserContent.component.html',
  styleUrls: ['./teaserContent.component.scss'],
})
export class TeaserContentComponent implements OnInit {
  public keywords: Array<String> = new Array<String>();
  public contributors: Array<String> = new Array<String>();
  public programmingLanguages: Array<String> = new Array<String>();

  constructor(private searchService: SearchService) {}

  ngOnInit(): void {
    this.searchService.getKeywordsAutoComplete('').subscribe(
      (data: Array<string>) => {
        this.keywords = data;
      },
      () => {
        alert('Initialization of keywords failed');
      }
    );

    this.searchService.getProgrammingLanguageAutoComplete('').subscribe(
      (data: Array<string>) => {
        this.programmingLanguages = data;
      },
      () => {
        alert('Initialization of programming languages failed');
      }
    );
    this.searchService.getContributorAutoComplete('').subscribe(
      (data: Array<string>) => {
        this.contributors = data;
      },
      () => {
        alert('Initialization of contributors failed');
      }
    );
  }
}