import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { EventData } from '@nativescript/core';
import { Observable } from 'rxjs';
import { PickerProvider } from '~/core/entities/picker-provider';
import { EvaluationSearch } from '../../entities/evaluation-search';

@Component({
    moduleId: module.id,
    selector: 'EvaluationSearchForm',
    templateUrl: './evaluation-search-form.component.html',
    styleUrls: ['./evaluation-search-form.component.scss']
})
export class EvaluationSearchFormComponent implements OnInit {
    evaluationSearch: EvaluationSearch;
    @Input() years$: Observable<PickerProvider[]>;
    @Input() states$: Observable<PickerProvider[]>;
    @Input() unit$: Observable<PickerProvider[]>;
    @Input() isLoading: boolean;

    @Output() searchEvaluation = new EventEmitter<EvaluationSearch>();

    ngOnInit() {
        this.evaluationSearch = new EvaluationSearch(0, '', 'MyUnit');
    }

    // Search button action
    onSearch(args: EventData) {
        this.searchEvaluation.emit(this.evaluationSearch);
    }
}
