Skip to content
Snippets Groups Projects
Unverified Commit fc74ad4a authored by AurianeStrasser2's avatar AurianeStrasser2 Committed by GitHub
Browse files

Merge branch 'dev' into remise_sorties

parents f7f10374 e25197b3
No related branches found
No related tags found
2 merge requests!29Remise sorties,!28Remise sorties
...@@ -35,7 +35,7 @@ export class AuthService { ...@@ -35,7 +35,7 @@ export class AuthService {
this.user$ = new BehaviorSubject(initialUser); this.user$ = new BehaviorSubject(initialUser);
} }
login(username: string, password: string) { login(username: string, password: string): Observable<boolean> {
return this.http.post<any>(this.loginUrl, { username: username, password: password }).pipe( return this.http.post<any>(this.loginUrl, { username: username, password: password }).pipe(
tap(data => this.token.set(data.token)), tap(data => this.token.set(data.token)),
map(data => this.userAdapter.adapt(data.user)), map(data => this.userAdapter.adapt(data.user)),
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
} }
#my-participations { #my-participations {
background: lighten($color-purple-light, 15); background: $color-purple-lighter;
} }
#page { #page {
......
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
} }
#visits { #visits {
// TODO use a background image // TODO use a background image?
background: $color-light-blue; background: $color-light-blue;
} }
#projects { #projects {
// TODO use a background image // TODO use a background image?
background: $color-purple-light; background: $color-purple-lighter;
} }
...@@ -80,9 +80,13 @@ ...@@ -80,9 +80,13 @@
</mat-form-field> </mat-form-field>
<div class="text-center"> <div class="text-center">
<button mat-raised-button color="primary" [disabled]="!formGroup.valid">M'inscrire</button> <button mat-raised-button color="primary" [disabled]="!formGroup.valid || loading">
M'inscrire
<app-load-spinner *ngIf="loading" [block]="false"></app-load-spinner>
</button>
</div> </div>
<p class="text-center"> <p class="text-center">
J'ai déjà un compte ! <a routerLink="/connexion">Me connecter</a> J'ai déjà un compte ! <a routerLink="/connexion">Me connecter</a>
</p> </p>
......
...@@ -3,7 +3,7 @@ import { FormGroup, FormBuilder, Validators } from '@angular/forms'; ...@@ -3,7 +3,7 @@ import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { MatSnackBar } from '@angular/material'; import { MatSnackBar } from '@angular/material';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { tap } from 'rxjs/operators'; import { tap, mergeMap } from 'rxjs/operators';
import { Registration, RegistrationService, PasswordErrorStateMatcher } from '../core'; import { Registration, RegistrationService, PasswordErrorStateMatcher } from '../core';
import { AuthService } from 'app/core'; import { AuthService } from 'app/core';
...@@ -17,6 +17,7 @@ export class StudentSignupComponent implements OnInit { ...@@ -17,6 +17,7 @@ export class StudentSignupComponent implements OnInit {
registration: Registration; registration: Registration;
formGroup: FormGroup; formGroup: FormGroup;
loading = false;
matcher = new PasswordErrorStateMatcher(); matcher = new PasswordErrorStateMatcher();
...@@ -52,16 +53,21 @@ export class StudentSignupComponent implements OnInit { ...@@ -52,16 +53,21 @@ export class StudentSignupComponent implements OnInit {
} }
submit() { submit() {
this.loading = true;
const registration: Registration = this.formGroup.value; const registration: Registration = this.formGroup.value;
const password: string = this.formGroup.controls.password.value; const password: string = this.formGroup.controls.password.value;
this.registrationService.create(registration, password).pipe( this.registrationService.create(registration, password).pipe(
tap(() => this.auth.login(registration.email, password)), mergeMap(() => this.auth.login(registration.email, password)),
tap(() => this.snackBar.open( tap(() => this.snackBar.open(
`Ton compte a été créé ! Tu es maintenant connecté.`, `Ton compte a été créé ! Tu es maintenant connecté.`,
'OK', 'OK',
{ duration: 3000 }, { duration: 3000 },
)), )),
tap(() => this.loading = false),
tap(() => this.router.navigate(['/'])), tap(() => this.router.navigate(['/'])),
).subscribe(); ).subscribe(
() => {},
(error) => this.loading = false,
);
} }
} }
...@@ -3,6 +3,7 @@ $color-darkest-blue: rgb(32, 26, 78); ...@@ -3,6 +3,7 @@ $color-darkest-blue: rgb(32, 26, 78);
$color-dark-blue: rgb(46, 37, 128); $color-dark-blue: rgb(46, 37, 128);
$color-purple: rgb(99, 92, 161); $color-purple: rgb(99, 92, 161);
$color-purple-light: rgb(151, 146, 192); $color-purple-light: rgb(151, 146, 192);
$color-purple-lighter: lighten($color-purple-light, 15);
$color-turquoise: rgb(43, 181, 186); $color-turquoise: rgb(43, 181, 186);
$color-light-blue: rgb(213, 250, 255); $color-light-blue: rgb(213, 250, 255);
$color-accent: #F3395E; $color-accent: #F3395E;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment