import { Component, OnInit } from '@angular/core';
import { ModalController, MenuController, NavController } from '@ionic/angular';
import { AuthService } from 'src/app/services/auth.service';
import { LanguageService } from 'src/app/services/language.service';
import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';

@Component({
  selector: 'app-landing',
  templateUrl: './landing.page.html',
  styleUrls: ['./landing.page.scss'],
})
export class LandingPage implements OnInit {
  constructor(
    private modalController: ModalController,
    private menu: MenuController,
    private authService: AuthService,
    private iab: InAppBrowser,
    private navCtrl: NavController,
  ) {
    this.menu.enable(false);
  }
  ionViewWillEnter() {
    this.authService.getToken().then(() => {
      if(this.authService.isLoggedIn) {
        this.navCtrl.navigateRoot('/dashboard');
      }
    });
  }
  ngOnInit() {

  }

  openUrl() {
    this.iab.create("https://www.heroesjobhero.com/registro", '_system')
  }

  register() {
    this.navCtrl.navigateForward('/register');
  }
  login() {
    this.navCtrl.navigateForward('/login');
  }
}
