diff --git a/src/app/pages/login/login.component.html b/src/app/pages/login/login.component.html index 3f8ec80..a8a58a7 100644 --- a/src/app/pages/login/login.component.html +++ b/src/app/pages/login/login.component.html @@ -1,4 +1,4 @@ -
+
BeReady-Logo

diff --git a/src/app/pages/login/login.component.ts b/src/app/pages/login/login.component.ts index 0860a91..e093db0 100644 --- a/src/app/pages/login/login.component.ts +++ b/src/app/pages/login/login.component.ts @@ -77,8 +77,6 @@ export class LoginComponent { color: 'danger' }); await toast.present(); - - // this.user().userForm.reset(); return false; } try { @@ -93,6 +91,5 @@ export class LoginComponent { }); await toast.present(); } - } } diff --git a/src/app/pages/ranking/ranking.component.html b/src/app/pages/ranking/ranking.component.html index 7373af9..975b042 100644 --- a/src/app/pages/ranking/ranking.component.html +++ b/src/app/pages/ranking/ranking.component.html @@ -3,37 +3,35 @@

-
-

1

-
-

Mathys

-

52 défis - 18 victoires

+ @for (user of users(); track user.id; let i = $index) { +
+ + @if (i === 0) { +

+ {{ i + 1 }} +

+ } @else if (i === 1) { +

+ {{ i + 1 }} +

+ } @else if (i === 2) { +

+ {{ i + 1 }} +

+ } @else { +

+ {{ i + 1 }} +

+ } + +
+

{{ user.username }}

+

{{ user.getUserStatsDto.totalChallenge }} défis + - {{ user.getUserStatsDto.totalWin }} victoires

+
+

{{ user.getUserStatsDto.score }} pts +

-

412 pts

-
-
-

2

-
-

Léa

-

47 défis - 15 victoires

-
-

389 pts

-
-
-

3

-
-

Noah

-

41 défis - 12 victoires

-
-

354 pts

-
-
-

4

-
-

Camille

-

38 défis - 10 victoires

-
-

321 pts

-
+ }
\ No newline at end of file diff --git a/src/app/pages/ranking/ranking.component.ts b/src/app/pages/ranking/ranking.component.ts index f7b3060..8e0afb8 100644 --- a/src/app/pages/ranking/ranking.component.ts +++ b/src/app/pages/ranking/ranking.component.ts @@ -1,5 +1,7 @@ -import {Component} from '@angular/core'; -import {IonicModule} from "@ionic/angular"; +import {Component, inject, OnInit, signal} from '@angular/core'; +import {IonicModule, LoadingController, ToastController} from "@ionic/angular"; +import {GetUserDto, OverallrankingService, UsersService} from "../../services/api"; +import {firstValueFrom} from "rxjs"; @Component({ selector: 'app-ranking', @@ -9,5 +11,37 @@ import {IonicModule} from "@ionic/angular"; IonicModule ] }) -export class RankingComponent { +export class RankingComponent implements OnInit { + private overallRankingService = inject(OverallrankingService); + private loadCtrl = inject(LoadingController); + private toastCtrl = inject(ToastController); + + users = signal([]); + + async ngOnInit() { + await this.fetchUsers(); + } + + async fetchUsers() { + const loading = await this.loadCtrl.create({ + message: 'Chargement...', + duration: 1000, + spinner: 'circles' + }); + await loading.present(); + + try { + const users = await firstValueFrom(this.overallRankingService.getOverallRankingEndpoint()); + this.users.set(users); + } catch (e) { + const toast = await this.toastCtrl.create({ + message: 'Impossible de charger les joueurs', + duration: 2000, + color: 'primary' + }); + await toast.present(); + } + } } + +//TODO: FAIRE NOS SERVICES POUR TOAST ET LOADING