Created social page

This commit is contained in:
2026-03-28 15:45:09 +01:00
parent 8dc66363ce
commit fdb4cf119b
73 changed files with 1097 additions and 1748 deletions
@@ -0,0 +1,67 @@
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, GetFriendDto} from "../../services/api";
import {firstValueFrom} from "rxjs";
import {FriendsStateService} from "../../services/friends-state";
addIcons({
'close': closeCircleOutline,
});
@Component({
selector: 'app-friends-list',
templateUrl: './friends-list.component.html',
styleUrls: ['./friends-list.component.scss'],
imports: [
IonicModule
]
})
export class FriendsListComponent implements OnInit {
private friendsService = inject(FriendsService);
private toastCtrl = inject(ToastController);
private friendsState = inject(FriendsStateService);
friends = this.friendsState.friends;
async ngOnInit() {
await this.fetchFriends();
}
async fetchFriends() {
try {
const friends = await firstValueFrom(this.friendsService.getAllFriendsEndpoint());
this.friendsState.setFriends(friends);
} catch (e) {
const toast = await this.toastCtrl.create({
message: 'Amis introuvables',
duration: 2000,
color: 'primary'
});
await toast.present();
}
}
async deleteFriend(friendId: number) {
try {
await firstValueFrom(this.friendsService.deleteFriendEndpoint(friendId));
const toast = await this.toastCtrl.create({
message: 'Vous avez supprimé cet ami',
duration: 2000,
color: 'success'
});
await toast.present();
} catch (e) {
const toast = await this.toastCtrl.create({
message: 'Vous ne pouvez pas supprimer cet ami',
duration: 2000,
color: 'danger'
});
await toast.present();
}
this.friendsState.removeFriend(friendId);
}
}
//TODO : QUAND ON CLIQUE SUR UN JOUEUR ON PEUT VOIR SA PAGE (VAUT AUSSI POUR CLASSEMENT