|
|
|
@ -10,7 +10,6 @@ import { MatInputModule } from '@angular/material/input';
|
|
|
|
|
import { MatMenuModule } from '@angular/material/menu';
|
|
|
|
|
import { User } from '../../models/user.model';
|
|
|
|
|
import { NgIf } from '@angular/common';
|
|
|
|
|
import { UserService } from '../../services/user-service';
|
|
|
|
|
import { Router } from '@angular/router';
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
@ -35,7 +34,6 @@ export class LoginComponent implements OnInit {
|
|
|
|
|
@Output() addConnectEvent = new EventEmitter<User>();
|
|
|
|
|
|
|
|
|
|
public isButtonVisible = false;
|
|
|
|
|
private UserService : UserService;
|
|
|
|
|
|
|
|
|
|
user: User = {id:1, login: '', password: '', streak: null, streaks: [], points: null}
|
|
|
|
|
loginForm: FormGroup = new FormGroup({
|
|
|
|
@ -43,8 +41,7 @@ export class LoginComponent implements OnInit {
|
|
|
|
|
password: new FormControl(this.user.password, Validators.required),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
public constructor(us: UserService,private router: Router) {
|
|
|
|
|
this.UserService = us
|
|
|
|
|
public constructor(private router: Router) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
@ -61,13 +58,10 @@ export class LoginComponent implements OnInit {
|
|
|
|
|
console.log("ERREUR DIFFERENT");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
console.log(this.loginForm.value.login)
|
|
|
|
|
|
|
|
|
|
this.user = this.loginForm.value;
|
|
|
|
|
localStorage.setItem('UserConnecte',String(this.user.login));
|
|
|
|
|
|
|
|
|
|
//this.UserService.addUserToLocal(this.user);
|
|
|
|
|
this.addConnectEvent.emit(this.user)
|
|
|
|
|
|
|
|
|
|
this.addConnectEvent.emit(this.loginForm.value)
|
|
|
|
|
this.loginForm.reset();
|
|
|
|
|
this.isButtonVisible = false;
|
|
|
|
|
this.router.navigate(['/accueil']);
|
|
|
|
|