import { Component, OnInit, ChangeDetectionStrategy, EventEmitter, Output } from '@angular/core';
import { Router } from '@angular/router';
import { createQueryStringFromObject } from 'src/app/shared/util/func';

@Component({
  selector: 'app-search',
  templateUrl: './search.component.html',
  styleUrls: ['./search.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class SearchComponent implements OnInit {
  @Output() search = new EventEmitter()
  @Output() add = new EventEmitter()
  query = {
    recipient_signature_name_th: null
  }
  constructor(
    private router: Router
  ) { }

  ngOnInit(): void {
  }

  onSearch(){
    const queryString = createQueryStringFromObject(this.query)
    this.search.emit(queryString)
  }

  clear(){
    this.query.recipient_signature_name_th = null
    const queryString = createQueryStringFromObject(this.query)
    this.search.emit(queryString)
  }

}
