import { Component, OnInit, ChangeDetectionStrategy, EventEmitter, Output, Input } from '@angular/core';
import { AcademicYearService } from 'src/app/core/service/settings/academic-year.service';
import { createQueryStringFromObject } from 'src/app/shared/util/func';

@Component({
  selector: 'app-testing-info-search',
  templateUrl: './testing-info-search.component.html',
  styleUrls: ['./testing-info-search.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class TestingInfoSearchComponent implements OnInit {
  @Output() search = new EventEmitter();
  @Input() academicYearList: any = [];
  query = {
    academic_year_code: null,
    testing_information_code: null,
    testing_information_name: null,
    academic_semester_code: null,
    is_open: true
  };
  constructor() { }

  ngOnInit(): void {

  }

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

  clear(){
    this.query = {
      academic_year_code: null,
      testing_information_code: null,
      testing_information_name: null,
      academic_semester_code: null,
      is_open: true
    };
  }

}
