import { Component, OnInit } from '@angular/core';

import { ActivatedRoute, Router } from '@angular/router';

import { TokenService, UserCredentials } from '../core/shared';

@Component({
    selector: 'knk-login',
    styleUrls: ['./login.component.scss'],
    templateUrl: 'login.component.html'
})
export class LoginComponent implements OnInit {
    user: UserCredentials;
    constructor(private router: Router,
        private route: ActivatedRoute,
        private tokenService: TokenService) {
        this.user = new UserCredentials();
    }
    ngOnInit(): void {
        console.log('init');
    }
    login(): void {
        this.tokenService.apiUserToken(this.user).subscribe(() => {
            this.router.navigate(['..', 'dashboard'], { relativeTo: this.route.parent });
        });
    }
}
