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

@Component({
    selector: 'calendar-search',
    templateUrl: './calendar-search.component.html',
    styleUrls: ['./calendar-search.component.scss'],
    changeDetection: ChangeDetectionStrategy.OnPush
})
export class CalendarSearchComponent implements OnInit {
    @Output() add = new EventEmitter()
    @Output() search = new EventEmitter()
    query = {
        calendar_type_name_th: null
    }
    constructor() { }

    ngOnInit(): void {
    }

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

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

    clear(){
        this.query = {
            calendar_type_name_th: null
        }
    }

}
