import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { faSearch } from '@fortawesome/free-solid-svg-icons';
import { Router } from '@angular/router';

@Component({
  selector: 'app-search',
  templateUrl: './search.component.html',
  styleUrls: ['./search.component.scss']
})
export class SearchComponent implements OnInit {

  @Output() search_change = new EventEmitter();
  @Input() search_placeholder: string = 'Search';


  @Input() is_in_home: boolean = true;
  icon_search = faSearch;
  search: string = ''

  constructor(private router: Router) { }

  ngOnInit(): void {
  }

  onSearchChange(){
    console.log(this.search)
    this.search_change.emit(this.search);
  }


  onSubmit(){
    if(this.is_in_home){
      this.router.navigate(['/discover'], { queryParams: { search: this.search } });
    }
  }

}
