Added vue from groups

This commit is contained in:
2026-04-25 16:12:24 +01:00
parent a1446f39ca
commit 3e6aae68d2
5 changed files with 254 additions and 0 deletions
@@ -0,0 +1,53 @@
import {Component, inject, OnInit, signal} from '@angular/core';
import {IonicModule, LoadingController, ToastController} from "@ionic/angular";
import {GetGroupDto, GroupsService} from "../../services/api";
import {firstValueFrom} from "rxjs";
import {addIcons} from "ionicons";
import {chatbubblesOutline, chevronForwardOutline} from "ionicons/icons";
addIcons({
'group': chatbubblesOutline,
'chevron': chevronForwardOutline,
});
@Component({
selector: 'app-groups',
templateUrl: './groups.component.html',
styleUrls: ['./groups.component.scss'],
imports: [
IonicModule
]
})
export class GroupsComponent implements OnInit {
private groupsService = inject(GroupsService);
private toastCtrl = inject(ToastController);
private loadCtrl = inject(LoadingController);
groups = signal<GetGroupDto[]>([]);
async ngOnInit() {
await this.fetchGroups();
}
async fetchGroups() {
const loading = await this.loadCtrl.create({
message: 'Chargement...',
spinner: 'lines-sharp-small'
});
await loading.present();
try {
const groups = await firstValueFrom(this.groupsService.getAllGroupsEndpoint());
this.groups.set(groups);
}
catch {
const toast = await this.toastCtrl.create({
message: 'Impossible de charger les groupes du joueur',
duration: 2000,
color: 'danger'
});
await toast.present();
}
await loading.dismiss();
}
}