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

@Component({
  selector: 'app-approve-examination-search',
  templateUrl: './approve-examination-search.component.html',
  styleUrls: ['./approve-examination-search.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class ApproveExaminationSearchComponent implements OnInit {
  @Output() search = new EventEmitter();
  academicYearList = [];
  constructor(
    private AcademicYearSV: AcademicYearService,
  ) { }
  query = {
    academic_year_code: null,
    testing_information_name: null,
    academic_semester_code: null
  };
  ngOnInit(): void {
    this.AcademicYearSV.getAll().subscribe(
      result => {
        this.academicYearList = result;
      }
    );
  }

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

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

}
