import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { UserService } from '../user.service';
@Component({
  selector: 'app-page-login',
  templateUrl: './page-login.component.html',
  styleUrls: ['./page-login.component.scss']
})
export class PageLoginComponent {

  constructor(private userServ:UserService,private router:Router){}
  userData:any = {
    username:"",
    password:""
  }

  login(){
    console.log(this.userData)
    try{
      let isLogin = this.userServ.checkUserPassword(this.userData)
      if(isLogin){
        let path = localStorage.getItem("REDIRECT_URL") || "/lesson/home"
        this.router.navigate([path])
      }
    }catch(err){
      alert(err)
    }
  }
}