diff --git a/src/app/components/designation-form/designation-form.component.html b/src/app/components/designation-form/designation-form.component.html
new file mode 100644
index 0000000..5e255b0
--- /dev/null
+++ b/src/app/components/designation-form/designation-form.component.html
@@ -0,0 +1,25 @@
+
\ No newline at end of file
diff --git a/src/app/components/designation-form/designation-form.component.scss b/src/app/components/designation-form/designation-form.component.scss
new file mode 100644
index 0000000..e69de29
diff --git a/src/app/components/designation-form/designation-form.component.ts b/src/app/components/designation-form/designation-form.component.ts
new file mode 100644
index 0000000..9864c20
--- /dev/null
+++ b/src/app/components/designation-form/designation-form.component.ts
@@ -0,0 +1,101 @@
+import {Component, inject, input, OnInit, output, signal} from '@angular/core';
+import {FormControl, FormGroup, ReactiveFormsModule} from "@angular/forms";
+import {IonicModule, LoadingController, ToastController} from "@ionic/angular";
+import {DesignationsService, GetDesignationDto, GetUserDetailsDto, UsersService} from "../../services/api";
+import {firstValueFrom} from "rxjs";
+
+@Component({
+ selector: 'app-designation-form',
+ templateUrl: './designation-form.component.html',
+ styleUrls: ['./designation-form.component.scss'],
+ imports: [
+ IonicModule,
+ ReactiveFormsModule
+ ]
+})
+export class DesignationFormComponent implements OnInit {
+ private designationsService = inject(DesignationsService);
+ private usersService = inject(UsersService);
+ private loadCtrl = inject(LoadingController);
+ private toastCtrl = inject(ToastController);
+
+ designationForm: FormGroup = new FormGroup({
+ designationId: new FormControl(null)
+ });
+
+ designations = signal([]);
+ user = input.required();
+ userDesignation = output();
+
+ async ngOnInit() {
+ const loading = await this.loadCtrl.create({
+ message: 'Chargement...',
+ spinner: 'lines-sharp-small'
+ });
+ await loading.present();
+
+ this.designationForm.patchValue({
+ designationId: this.user().designationId,
+ });
+
+ try {
+ const designation = await firstValueFrom(this.designationsService.getAllDesignationsEndpoint());
+ this.designations.set(designation);
+
+ await loading.dismiss();
+ } catch {
+ const toast = await this.toastCtrl.create({
+ message: 'Impossible de récupérer les titres',
+ duration: 2000,
+ color: 'danger'
+ });
+ await toast.present();
+ await loading.dismiss();
+ }
+ }
+
+ async updateDesignation() {
+ const loading = await this.loadCtrl.create({
+ message: 'Modification...',
+ spinner: 'lines-sharp-small'
+ });
+ await loading.present();
+
+ try {
+ const form = this.designationForm.getRawValue();
+ const label = this.designations().find(x => x.id == form.designationId).label;
+
+ await firstValueFrom(this.usersService.patchUserDesignationEndpoint(form));
+ const userEdited = {
+ id: this.user().id,
+ firstName: this.user().firstName,
+ name: this.user().name,
+ username: this.user().username,
+ email: this.user().email,
+ designationId: form.designationId,
+ designationName: label,
+ creationDate: this.user().creationDate,
+ getUserStatsDto: this.user().getUserStatsDto
+ }
+
+ this.userDesignation.emit(userEdited);
+
+ const toast = await this.toastCtrl.create({
+ message: 'Modification réussie',
+ duration: 2000,
+ color: 'success'
+ });
+
+ await loading.dismiss();
+ await toast.present();
+ } catch {
+ const toast = await this.toastCtrl.create({
+ message: 'Modification impossible',
+ duration: 2000,
+ color: 'danger'
+ });
+ await loading.dismiss();
+ await toast.present();
+ }
+ }
+}
diff --git a/src/app/components/profil-form/profil-form.component.ts b/src/app/components/profil-form/profil-form.component.ts
index 50bb72c..b0b4cd7 100644
--- a/src/app/components/profil-form/profil-form.component.ts
+++ b/src/app/components/profil-form/profil-form.component.ts
@@ -1,7 +1,7 @@
import {Component, inject, input, OnInit, output} from '@angular/core';
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators} from "@angular/forms";
import {IonicModule, LoadingController, ToastController} from "@ionic/angular";
-import {GetUserDetailsDto, GetUserStatsDto, UsersService} from "../../services/api";
+import {GetUserDetailsDto, UsersService} from "../../services/api";
import {firstValueFrom} from "rxjs";
@Component({
@@ -74,6 +74,7 @@ export class ProfilFormComponent implements OnInit {
name: form.name,
username: form.username,
email: form.email,
+ designationId: this.user().designationId,
designationName: this.user().designationName,
creationDate: this.user().creationDate,
getUserStatsDto: this.user().getUserStatsDto
diff --git a/src/app/pages/home/home.component.html b/src/app/pages/home/home.component.html
index b332a29..a0a5339 100644
--- a/src/app/pages/home/home.component.html
+++ b/src/app/pages/home/home.component.html
@@ -102,7 +102,8 @@
@case ('designation') {
-
Formulaire designation
+
}
diff --git a/src/app/pages/home/home.component.ts b/src/app/pages/home/home.component.ts
index 854e483..8bf7cf7 100644
--- a/src/app/pages/home/home.component.ts
+++ b/src/app/pages/home/home.component.ts
@@ -23,6 +23,7 @@ import {UserAchievementsComponent} from "../../components/user-achievements/user
import {ModalComponent} from "../../components/modal/modal.component";
import {ProfilFormComponent} from "../../components/profil-form/profil-form.component";
import {PasswordFormComponent} from "../../components/password-form/password-form.component";
+import {DesignationFormComponent} from "../../components/designation-form/designation-form.component";
addIcons({
'profile': personOutline,
@@ -47,7 +48,8 @@ type View = 'menu' | 'profile' | 'password' | 'designation' | 'gallery';
ModalComponent,
ProfilFormComponent,
PasswordFormComponent,
- PasswordFormComponent
+ PasswordFormComponent,
+ DesignationFormComponent
]
})
export class HomeComponent implements OnInit {
diff --git a/src/app/services/api/README.md b/src/app/services/api/README.md
index 29f22fe..4d71313 100644
--- a/src/app/services/api/README.md
+++ b/src/app/services/api/README.md
@@ -59,9 +59,9 @@ In your Angular project:
```typescript
-import { ApplicationConfig } from '@angular/core';
-import { provideHttpClient } from '@angular/common/http';
-import { provideApi } from '';
+import {ApplicationConfig} from '@angular/core';
+import {provideHttpClient} from '@angular/common/http';
+import {provideApi} from '';
export const appConfig: ApplicationConfig = {
providers: [
diff --git a/src/app/services/api/model/get-user-details-dto.ts b/src/app/services/api/model/get-user-details-dto.ts
index e644f7a..60cf3c4 100644
--- a/src/app/services/api/model/get-user-details-dto.ts
+++ b/src/app/services/api/model/get-user-details-dto.ts
@@ -16,6 +16,7 @@ export interface GetUserDetailsDto {
name?: string | null;
username?: string | null;
email?: string | null;
+ designationId?: number | null;
designationName?: string | null;
creationDate?: string;
getUserStatsDto?: GetUserStatsDto | null;
diff --git a/src/app/services/api/model/get-user-dto.ts b/src/app/services/api/model/get-user-dto.ts
index a744617..f17f9d6 100644
--- a/src/app/services/api/model/get-user-dto.ts
+++ b/src/app/services/api/model/get-user-dto.ts
@@ -15,6 +15,7 @@ export interface GetUserDto {
firstName?: string | null;
name?: string | null;
username?: string | null;
+ designationId?: number | null;
designationName?: string | null;
getUserStatsDto?: GetUserStatsDto | null;
}