import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute, Params } from '@angular/router';
import { NgForm } from '@angular/forms';

import { DataService } from '../../services/data.service';
import { AlertService } from '../../services/alert.service';

@Component({
    selector:"login",
    template: require('./login.component.html'),
    styles: [require('./login.component.css')]
})
export class LoginComponent implements OnInit {

    private returnUrl: string;

    constructor(private alertService: AlertService,private router: Router, private route: ActivatedRoute, private dataService: DataService) { }

    onLoadDashboard() {
        this.router.navigate(['/home']);
    }
    model: any = {};
    loading = false;
    // onSubmit(loginForm: NgForm) {
    //  this.onLoadDashboard();
    //     // let data = this.dataService.login(user)
    //     //     .subscribe((res) => {
    //     //         if(Object.keys(res)[0] !== 'message'){
    //     //             this.onLoadDashboard();
    //     //         }else{
    //     //             alert(res.message);
    //     //             return;
    //     //         }
    //     //     },
    //     //     (err) => {
    //     //         console.log(err);
    //     //     });
    // }
 login() {
     
        this.loading = true;
         this.alertService.error("Error: Username or password is incorrect");
        this.loading = false;
       
    }
    ngOnInit() {
        // reset login status
        this.dataService.logout();

        // get return url from route parameters or default to '/'
      //  this.returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/';
    }

}
