import { Component, OnInit } from '@angular/core';
import { ModalController } from '@ionic/angular';
import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service';

@Component({
  selector: 'app-worklist-advanced-search',
  templateUrl: './worklist-advanced-search.component.html',
  styleUrls: ['./worklist-advanced-search.component.scss'],
})
export class WorklistAdvancedSearchComponent implements OnInit {

  public hideDateInput = false;
  public hideTextInput = false;
  public inputDate = '';
  public inputSearch = '';
  public selectedValue = '';
  public notificationType = '';
  public itemType = '';

  constructor(
    public modalController: ModalController,
    public ts: TranslatorService
  ) { }

  ngOnInit() {}

  public dismissModal() {
    this.modalController.dismiss();
  }

  public search() {
    console.log(this.itemType);
    this.modalController.dismiss({
      notificationType: this.notificationType,
      selectedValue: this.selectedValue,
      inputDate: this.inputDate,
      inputSearch: this.inputSearch,
      itemType: this.itemType
    });
  }

  onChangeView(selectedValue: any) {
    this.notificationType = selectedValue.detail.value;
  }

  getValueSelected(value) {
      this.selectedValue = value.detail.value;
      if (this.selectedValue === '1') {
        this.hideDateInput = false;
        this.hideTextInput = true;
      } else if (this.selectedValue === '2') {
        this.hideDateInput = false;
        this.hideTextInput = true;
      } else if (this.selectedValue === '3') {
        this.hideDateInput = true;
        this.hideTextInput = false;
      } else if (this.selectedValue === '4') {
        this.hideDateInput = false;
        this.hideTextInput = true;
      } else if (this.selectedValue === '5') {
        this.hideDateInput = false;
        this.hideTextInput = false;
      }
  }
}
