import {Component, OnInit, ChangeDetectionStrategy, Output, EventEmitter} from '@angular/core';
import {createQueryStringFromObject} from '../../../../../../shared/util/func';
import {formatDate} from '@angular/common';

@Component({
  selector: 'app-register-cancel-search',
  templateUrl: './register-cancel-search.component.html',
  styleUrls: ['./register-cancel-search.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class RegisterCancelSearchComponent implements OnInit {
  query = {
    date: null
  };
  @Output() search = new EventEmitter();
  constructor() { }

  ngOnInit(): void {
  }

  onSearch(){
        if (this.query.date != null){
          this.query.date = formatDate(this.query.date, 'yyyy-MM-dd', 'en-US');
        }
        const query = createQueryStringFromObject(this.query);
        this.search.emit(query);
  }

}
