Started profil page

This commit is contained in:
2026-04-14 15:48:36 +01:00
parent 83f68a3029
commit 90243bc671
50 changed files with 849 additions and 1654 deletions
+29 -26
View File
@@ -1,16 +1,19 @@
import {Component, inject, OnInit, signal} from '@angular/core';
import {IonicModule, ToastController} from "@ionic/angular";
import {addIcons} from "ionicons";
import {walkOutline, addOutline} from "ionicons/icons";
import {personOutline, addOutline, logOutOutline, settingsOutline, chevronForwardOutline, swapHorizontalOutline} from "ionicons/icons";
import {TitlePartComponent} from "../../components/title-part/title-part.component";
import {ChallengeCardComponent} from "../../components/challenge-card/challenge-card.component";
import * as signalR from '@microsoft/signalr';
import {GetRandomChallengeDto, RandomchallengesService} from "../../services/api";
import {GetRandomChallengeDto, GetUserDetailsDto, RandomchallengesService, UsersService} from "../../services/api";
import {firstValueFrom} from "rxjs";
addIcons({
'profile': walkOutline,
'profile': personOutline,
'add': addOutline,
'settings': settingsOutline,
'logout': logOutOutline,
'chevron': chevronForwardOutline,
'swap': swapHorizontalOutline,
});
@Component({
@@ -24,32 +27,15 @@ addIcons({
]
})
export class HomeComponent implements OnInit {
// private connection: signalR.HubConnection;
//
// ngOnInit(): void {
// this.connection = new signalR.HubConnectionBuilder()
// .withUrl('http://localhost:5235/timeHub', {
// withCredentials: true
// })
// .build();
//
// this.connection.on('ReceiveTime', (time) => {
// console.log('Server time:', time);
// });
//
// this.connection.start()
// .then(() => {
// console.log('Connected to SignalR');
// this.connection.invoke('SendTime');
// })
// .catch(err => console.error('Connection error:', err));
// }
private randomChallengeService = inject(RandomchallengesService)
private toastCtrl = inject(ToastController);
private usersService = inject(UsersService)
randomChallenge = signal<GetRandomChallengeDto>({});
user = signal<GetUserDetailsDto>({})
isModalOpen = false;
options = [1, 2, 3, 4, 5];
async ngOnInit() {
try {
@@ -64,4 +50,21 @@ export class HomeComponent implements OnInit {
await toast.present();
}
}
async setOpen(isOpen: boolean) {
if (isOpen) {
try {
const userInfo = await firstValueFrom(this.usersService.getUserDetailsEndpoint());
this.user.set(userInfo);
} catch (e) {
const toast = await this.toastCtrl.create({
message: 'Impossible de charger les données du joueur',
duration: 2000,
color: 'danger'
});
await toast.present();
}
}
this.isModalOpen = isOpen;
}
}