Fixed error with modal and datas
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import {Component, inject, OnInit} from '@angular/core';
|
||||
import {Component, inject, OnInit, signal} from '@angular/core';
|
||||
import {IonicModule, ToastController} from "@ionic/angular";
|
||||
import {closeCircleOutline} from 'ionicons/icons';
|
||||
import {addIcons} from "ionicons";
|
||||
import {FriendsService} from "../../services/api";
|
||||
import {FriendsService, GetUserDto, UsersService} from "../../services/api";
|
||||
import {firstValueFrom} from "rxjs";
|
||||
import {FriendsStateService} from "../../services/friends-state";
|
||||
|
||||
@@ -20,9 +20,14 @@ addIcons({
|
||||
})
|
||||
export class FriendsListComponent implements OnInit {
|
||||
private friendsService = inject(FriendsService);
|
||||
private usersService = inject(UsersService);
|
||||
private toastCtrl = inject(ToastController);
|
||||
private friendsState = inject(FriendsStateService);
|
||||
|
||||
selectedFriend = signal<GetUserDto>(null);
|
||||
|
||||
isModalOpen = false;
|
||||
|
||||
friends = this.friendsState.friends;
|
||||
|
||||
async ngOnInit() {
|
||||
@@ -62,6 +67,21 @@ export class FriendsListComponent implements OnInit {
|
||||
}
|
||||
this.friendsState.removeFriend(friendId);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO : QUAND ON CLIQUE SUR UN JOUEUR ON PEUT VOIR SA PAGE (VAUT AUSSI POUR CLASSEMENT
|
||||
async setOpen(isOpen: boolean, userId: number) {
|
||||
if (isOpen) {
|
||||
try {
|
||||
const userInfo = await firstValueFrom(this.usersService.getUserEndpoint(userId));
|
||||
this.selectedFriend.set(userInfo);
|
||||
} catch (e) {
|
||||
const toast = await this.toastCtrl.create({
|
||||
message: 'Impossible de charger les données du joueur',
|
||||
duration: 2000,
|
||||
color: 'primary'
|
||||
});
|
||||
await toast.present();
|
||||
}
|
||||
}
|
||||
this.isModalOpen = isOpen;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user