import { Router } from '@angular/router';
import { Component, OnInit, ViewChild } from '@angular/core';
import { AlertController } from '@ionic/angular';

AlertController

@Component({
  selector: 'app-login',
  templateUrl: './login.page.html',
  styleUrls: ['./login.page.scss'],
})
export class LoginPage implements OnInit {

  @ViewChild('username', { static: false }) username;
  @ViewChild('password', { static: false }) password;


  constructor(
    private alertCtrl: AlertController,
    private router: Router
    ) { }

  ngOnInit() {
  }

  async  onStartLogin() {
    if (this.username == null || this.username === '' /* || this.floatValidatorsProvider.validateEmail(this.username) === false */
      || this.password == null || this.password === '') {
      this.showAlert('Invalid Login', 'Enter username(email) and password to login');
    } else {

      this.router.navigateByUrl('tabs');
    }


  }

  async showAlert(mtitle: string, amessage: string) {
    const alert = await this.alertCtrl.create({
      header: mtitle,
      message: amessage,
      buttons: ['OK']
    });
    alert.present();
  }

}
