import { Component, OnInit } from '@angular/core';
import { LoginApiService } from '../../services/login-api';
import { Router } from '@angular/router';

@Component({
  selector: 'mylogin',
  templateUrl: './login.component.html',
})
export class MyLoginComponent implements OnInit{

  redirectDelay: number = 0;
  showMessages: any = {};
  strategy: string = '';

  errors: string[] = [];
  messages: string[] = [];
  user: any = {};
  submitted: boolean = false;
  socialLinks: any[] = [];
  rememberMe = false;

  constructor(
    private router : Router,  
    private loginApi : LoginApiService
  ){}

  ngOnInit(){
    this.loginApi.checkLogin().then(loggedin => {
      if(loggedin){
        this.router.navigateByUrl("/")
      }
    });
  }

  login(){
    this.loginApi.login(this.user.name, this.user.password)
  }
}