import { formatDate } from '@angular/common';
import { Component, OnInit, ChangeDetectionStrategy, Output, EventEmitter, Input, ChangeDetectorRef } from '@angular/core';
import { tap } from 'rxjs/operators';
import { UserCountersService } from 'src/app/core/service/permission/user-counters.service';
import { createQueryStringFromObject } from 'src/app/shared/util/func';

@Component({
  selector: 'period-summary-search',
  templateUrl: './period-summary-search.component.html',
  styleUrls: ['./period-summary-search.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class PeriodSummarySearchComponent implements OnInit {
  @Input() testingInfo: any = [];
  period;
  query = {
    payment_date: null,
    period: null,
    counter_no: null
  }

  @Output() search = new EventEmitter()
  constructor(
    private userCounterSV: UserCountersService,
    private cdr: ChangeDetectorRef
    ) { }

  ngOnInit(): void {
  }

  onSearch(){
        if (this.query.payment_date) {this.query.payment_date = formatDate(this.query.payment_date, 'yyyy-MM-dd', 'en-US'); }
        this.search.emit(this.query);
  }


}
