-
+
-
- }
- @case ('password') {
-
-
-
- }
- @case ('designation') {
-
-
-
- }
- @case ('gallery') {
-
-
-
+ }
+ @case ('profile') {
+
+
+
+ }
+ @case ('password') {
+
+
+
+ }
+ @case ('designation') {
+
+
+
+ }
+ @case ('gallery') {
+
+
+
+ }
}
}
diff --git a/src/app/pages/home/home.component.ts b/src/app/pages/home/home.component.ts
index 08d83d5..5b94641 100644
--- a/src/app/pages/home/home.component.ts
+++ b/src/app/pages/home/home.component.ts
@@ -1,15 +1,15 @@
import {Component, inject, OnInit, signal} from '@angular/core';
-import {IonicModule, LoadingController, ToastController} from "@ionic/angular";
+import {IonicModule, LoadingController, ModalController, ToastController} from "@ionic/angular";
import {addIcons} from "ionicons";
import {personOutline, addOutline, settingsOutline} from "ionicons/icons";
import {TitlePartComponent} from "../../components/title-part/title-part.component";
import {ChallengeCardComponent} from "../../components/challenge-card/challenge-card.component";
import {
- AchievementsService,
- GetAchievementDto,
+ AchievementsService, CreateGroupDto,
+ GetAchievementDto, GetGroupDto,
GetRandomChallengeDto,
GetUserChallengeDto,
- GetUserDetailsDto,
+ GetUserDetailsDto, GroupsService,
RandomchallengesService,
UsersService
} from "../../services/api";
@@ -26,6 +26,7 @@ import {PasswordFormComponent} from "../../components/password-form/password-for
import {DesignationFormComponent} from "../../components/designation-form/designation-form.component";
import {GalleryComponent} from "../../components/gallery/gallery.component";
import {GroupsComponent} from "../../components/groups/groups.component";
+import {GroupFormComponent} from "../../components/group-form/group-form.component";
addIcons({
'profile': personOutline,
@@ -54,6 +55,7 @@ type View = 'menu' | 'profile' | 'password' | 'designation' | 'gallery';
DesignationFormComponent,
GalleryComponent,
GroupsComponent,
+ GroupFormComponent,
]
})
export class HomeComponent implements OnInit {
@@ -62,13 +64,16 @@ export class HomeComponent implements OnInit {
private usersService = inject(UsersService);
private loadCtrl = inject(LoadingController);
private achievementsService = inject(AchievementsService);
+ private groupsService = inject(GroupsService);
randomChallenge = signal
({});
user = signal({})
userChallenge = signal([]);
userAchievement = signal([])
+ groups = signal([])
isModalOpen = false;
+ isGroupModal = false;
view: View = 'menu';
setView(choice: View) {
@@ -82,7 +87,9 @@ export class HomeComponent implements OnInit {
async ngOnInit() {
try {
const randomChallenge = await firstValueFrom(this.randomChallengeService.generateRandomChallengeEndpoint());
+ const groups = await firstValueFrom(this.groupsService.getAllGroupsEndpoint());
this.randomChallenge.set(randomChallenge);
+ this.groups.set(groups);
} catch {
const toast = await this.toastCtrl.create({
message: 'Impossible de générer un défi aléatoire',
@@ -93,31 +100,42 @@ export class HomeComponent implements OnInit {
}
}
- async setOpen(isOpen: boolean) {
+ async setOpen(isOpen: boolean, profil: boolean) {
if (isOpen) {
const loading = await this.loadCtrl.create({
message: 'Chargement...',
spinner: 'lines-sharp-small'
});
await loading.present();
- try {
- const userInfo = await firstValueFrom(this.usersService.getUserDetailsEndpoint());
- const userChallenge = await firstValueFrom(this.usersService.getAllUserChallengesEndpoint());
- const userAchievement = await firstValueFrom((this.achievementsService.getUserAchievementsEndpoint()));
- this.user.set(userInfo);
- this.userChallenge.set(userChallenge);
- this.userAchievement.set(userAchievement);
- } catch {
- const toast = await this.toastCtrl.create({
- message: 'Impossible de charger les données du joueur',
- duration: 2000,
- color: 'danger'
- });
- await toast.present();
+ if (profil) {
+ this.isGroupModal = !profil;
+ try {
+ const userInfo = await firstValueFrom(this.usersService.getUserDetailsEndpoint());
+ const userChallenge = await firstValueFrom(this.usersService.getAllUserChallengesEndpoint());
+ const userAchievement = await firstValueFrom((this.achievementsService.getUserAchievementsEndpoint()));
+
+ this.user.set(userInfo);
+ this.userChallenge.set(userChallenge);
+ this.userAchievement.set(userAchievement);
+ } catch {
+ const toast = await this.toastCtrl.create({
+ message: 'Impossible de charger les données du joueur',
+ duration: 2000,
+ color: 'danger'
+ });
+ await toast.present();
+ }
+ } else {
+ this.isGroupModal = !profil;
}
await loading.dismiss();
}
this.isModalOpen = isOpen;
}
+
+ async updateGroup(newGroup: CreateGroupDto) {
+ this.groups.update(x => [...x, newGroup])
+ await this.setOpen(false, true);
+ }
}
\ No newline at end of file