Fixed error with visibility of all groups after change
This commit is contained in:
@@ -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 {GetGroupDetailsDto, GroupsService} from "../../services/api";
|
||||||
import {addIcons} from "ionicons";
|
import {addIcons} from "ionicons";
|
||||||
import {peopleOutline, banOutline, arrowUpCircleOutline} from "ionicons/icons";
|
import {peopleOutline, banOutline, arrowUpCircleOutline} from "ionicons/icons";
|
||||||
@@ -33,6 +33,8 @@ export class GroupInfoComponent implements OnInit {
|
|||||||
|
|
||||||
date = computed<string>(() => moment(this.group().creationDate).format('DD/MM/YYYY'));
|
date = computed<string>(() => moment(this.group().creationDate).format('DD/MM/YYYY'));
|
||||||
|
|
||||||
|
idGroup = output<number>();
|
||||||
|
|
||||||
options = [1, 2, 3];
|
options = [1, 2, 3];
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@@ -76,8 +78,11 @@ export class GroupInfoComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
await loading.present();
|
await loading.present();
|
||||||
|
|
||||||
|
const oldGroup = this.group().id;
|
||||||
|
|
||||||
try {
|
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({
|
const toast = await this.toastCtrl.create({
|
||||||
message: 'Vous avez quitter ce groupe',
|
message: 'Vous avez quitter ce groupe',
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
@@ -105,8 +110,11 @@ export class GroupInfoComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
await loading.present();
|
await loading.present();
|
||||||
|
|
||||||
|
const oldGroup = this.group().id;
|
||||||
|
|
||||||
try {
|
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({
|
const toast = await this.toastCtrl.create({
|
||||||
message: 'Groupe supprimé',
|
message: 'Groupe supprimé',
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
|
|||||||
@@ -158,7 +158,7 @@
|
|||||||
</ion-toolbar>
|
</ion-toolbar>
|
||||||
</ion-header>
|
</ion-header>
|
||||||
<ion-content class="ion-padding" style="--background: #f7f6f2;">
|
<ion-content class="ion-padding" style="--background: #f7f6f2;">
|
||||||
<app-group-info [groupSelected]="groupSelected()"></app-group-info>
|
<app-group-info (idGroup)="removeGroup($event)" [groupSelected]="groupSelected()"></app-group-info>
|
||||||
</ion-content>
|
</ion-content>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</ion-modal>
|
</ion-modal>
|
||||||
@@ -149,4 +149,8 @@ export class HomeComponent implements OnInit {
|
|||||||
this.groupSelected.set(null);
|
this.groupSelected.set(null);
|
||||||
await this.navCtrl.navigateRoot('/home');
|
await this.navCtrl.navigateRoot('/home');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeGroup(groupId: number) {
|
||||||
|
this.groups.update(x => x.filter(g => g.id !== groupId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user