diff --git a/src/app/components/group-info/group-info.component.ts b/src/app/components/group-info/group-info.component.ts index 9666d28..85f6b75 100644 --- a/src/app/components/group-info/group-info.component.ts +++ b/src/app/components/group-info/group-info.component.ts @@ -1,4 +1,4 @@ -import {Component, computed, inject, input, OnInit, signal} from '@angular/core'; +import {Component, computed, inject, input, OnInit, output, signal} from '@angular/core'; import {GetGroupDetailsDto, GroupsService} from "../../services/api"; import {addIcons} from "ionicons"; import {peopleOutline, banOutline, arrowUpCircleOutline} from "ionicons/icons"; @@ -33,6 +33,8 @@ export class GroupInfoComponent implements OnInit { date = computed(() => moment(this.group().creationDate).format('DD/MM/YYYY')); + idGroup = output(); + options = [1, 2, 3]; ngOnInit() { @@ -76,8 +78,11 @@ export class GroupInfoComponent implements OnInit { }); await loading.present(); + const oldGroup = this.group().id; + try { - await firstValueFrom(this.groupsService.leaveGroupEndpoint(this.group().id)); + await firstValueFrom(this.groupsService.leaveGroupEndpoint(oldGroup)); + this.idGroup.emit(oldGroup); const toast = await this.toastCtrl.create({ message: 'Vous avez quitter ce groupe', duration: 2000, @@ -105,8 +110,11 @@ export class GroupInfoComponent implements OnInit { }); await loading.present(); + const oldGroup = this.group().id; + try { - await firstValueFrom(this.groupsService.deleteGroupEndpoint(this.group().id)); + await firstValueFrom(this.groupsService.deleteGroupEndpoint(oldGroup)); + this.idGroup.emit(oldGroup); const toast = await this.toastCtrl.create({ message: 'Groupe supprimé', duration: 2000, diff --git a/src/app/pages/home/home.component.html b/src/app/pages/home/home.component.html index 1f36426..30050b2 100644 --- a/src/app/pages/home/home.component.html +++ b/src/app/pages/home/home.component.html @@ -158,7 +158,7 @@ - + \ No newline at end of file diff --git a/src/app/pages/home/home.component.ts b/src/app/pages/home/home.component.ts index 1fbbbd7..0277898 100644 --- a/src/app/pages/home/home.component.ts +++ b/src/app/pages/home/home.component.ts @@ -149,4 +149,8 @@ export class HomeComponent implements OnInit { this.groupSelected.set(null); await this.navCtrl.navigateRoot('/home'); } + + removeGroup(groupId: number) { + this.groups.update(x => x.filter(g => g.id !== groupId)); + } } \ No newline at end of file