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

@Component({
  selector: 'app-setting-exam-search',
  templateUrl: './setting-exam-search.component.html',
  styleUrls: ['./setting-exam-search.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class SettingExamSearchComponent implements OnInit {
  @Output() add = new EventEmitter()
  @Output() search = new EventEmitter()
  statusMock = [{id:1, name:'ใช้งาน'},{id:2, name:'ยกเลิก'}]
  query = {
    status_id: null,
    subject_code: null,
    responsible_faculty_name_th: null
  }
  constructor() { }

  ngOnInit(): void {
  }

  onAdd(){
    this.add.emit()
  }

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

  clear(){
    this.query = {
      status_id: null,
      subject_code: null,
      responsible_faculty_name_th: null
    }
  }

}
