import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { AuthService } from '../services/auth.service'; @Component({ selector: 'app-login', templateUrl: './login.component.html', styleUrls: ['./login.component.scss'] }) export class LoginComponent implements OnInit { credentials = { username: 'suresh', password: '123456789', login_type: "OUTLET" }; // ramsesrh login_types = ['VENDOR', 'OUTLET']; errorMessage: string = ''; constructor( public router: Router, private authService: AuthService ) { } ngOnInit() { } requestAuthentication() { this.authService.authenticateUser(this.credentials).then((data: any) => { localStorage.current_login_type = this.credentials.login_type; localStorage.token = data.access_Token; localStorage.user_info = JSON.stringify(data['User Info']); if (this.credentials.login_type === 'VENDOR') { localStorage.vendor_info = JSON.stringify(data['Info Info']); } else { localStorage.outlet_info = JSON.stringify(data['Outlet Info']); } this.router.navigate(['shop-details']); }, (err: any) => { this.errorMessage = 'Please check your credentials'; setTimeout(() => { this.errorMessage = ''; }, 3000); }); } }