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

@Component({
    selector: 'teacher-finance-search',
    templateUrl: './teacher-finance-search.component.html',
    styleUrls: ['./teacher-finance-search.component.scss'],
    changeDetection: ChangeDetectionStrategy.OnPush
})
export class TeacherFinanceSearchComponent implements OnInit {
    @Output() add = new EventEmitter()
    @Output() search = new EventEmitter()
    @Input() facultyList: any = [];
    query = {
        instructor_name: null,
        faculty_name: null
    }
    constructor() { }

    ngOnInit(): void {
    }

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

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

    clear(){
        this.query = {
            instructor_name: null,
            faculty_name: null
        }
        let query = createQueryStringFromObject(this.query)
        this.search.emit(query)
    }

}
