-
+
+
+
+
+
+
Mon domaine de compétence
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Mes réseaux sociaux
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/shared/components/my-profile-update-form/my-profile-update-form.component.ts b/src/app/shared/components/my-profile-update-form/my-profile-update-form.component.ts
index ae2e85c..422c199 100644
--- a/src/app/shared/components/my-profile-update-form/my-profile-update-form.component.ts
+++ b/src/app/shared/components/my-profile-update-form/my-profile-update-form.component.ts
@@ -7,8 +7,6 @@ import {
Validators,
} from '@angular/forms';
import { UntilDestroy } from '@ngneat/until-destroy';
-import { NgClass } from '@angular/common';
-import { AuthService } from '@app/core/services/authentication/auth.service';
import { MyProfileUpdateCvFormComponent } from '@app/shared/components/my-profile-update-cv-form/my-profile-update-cv-form.component';
import { ToastrService } from 'ngx-toastr';
import { ProfileViewModel } from '@app/ui/profiles/profile.presenter.model';
@@ -16,21 +14,28 @@ import { ProfileFacade } from '@app/ui/profiles/profile.facade';
import { ActionType } from '@app/domain/action-type.util';
import { Profile } from '@app/domain/profiles/profile.model';
import { SectorFacade } from '@app/ui/sectors/sector.facade';
+import { NgTemplateOutlet } from '@angular/common';
+import { LoadingComponent } from '@app/shared/components/loading/loading.component';
@Component({
selector: 'app-my-profile-update-form',
standalone: true,
- imports: [ReactiveFormsModule, NgClass, MyProfileUpdateCvFormComponent],
+ imports: [
+ ReactiveFormsModule,
+ MyProfileUpdateCvFormComponent,
+ NgTemplateOutlet,
+ LoadingComponent,
+ ],
templateUrl: './my-profile-update-form.component.html',
styleUrl: './my-profile-update-form.component.scss',
})
@UntilDestroy()
export class MyProfileUpdateFormComponent implements OnInit {
private readonly toastrService = inject(ToastrService);
+ protected readonly ActionType = ActionType;
@Input({ required: true }) profile: ProfileViewModel = {} as ProfileViewModel;
private readonly formBuilder = inject(FormBuilder);
- protected readonly authService = inject(AuthService);
profileForm!: FormGroup;
private readonly profileFacade = new ProfileFacade();
@@ -44,28 +49,24 @@ export class MyProfileUpdateFormComponent implements OnInit {
protected readonly sectorError = this.sectorFacade.error;
constructor() {
- effect(() => {
- switch (this.loading().action) {
- case ActionType.UPDATE:
- if (!this.loading() && !this.error().hasError) {
- this.authService.updateUser();
+ let message = '';
- this.toastrService.success(
- ` Vos informations personnelles ont bien été modifier !`,
- `Mise à jour`,
- {
- closeButton: true,
- progressAnimation: 'decreasing',
- progressBar: true,
- }
- );
- }
+ effect(() => {
+ if (!this.loading().isLoading) {
+ switch (this.loading().action) {
+ case ActionType.UPDATE:
+ message = `Vos informations personnelles ont bien été modifier !`;
+ this.customToast(ActionType.UPDATE, message);
+ break;
+ }
}
- switch (this.sectorLoading().action) {
- case ActionType.READ:
- if (!this.sectorLoading() && !this.sectorError().hasError) {
- this.profileForm.get('secteur')!.setValue(this.sector().id);
- }
+ if (!this.sectorLoading().isLoading) {
+ switch (this.sectorLoading().action) {
+ case ActionType.READ:
+ if (!this.sectorLoading() && !this.sectorError().hasError) {
+ this.profileForm.get('secteur')!.setValue(this.sector().id);
+ }
+ }
}
});
}
@@ -125,4 +126,29 @@ export class MyProfileUpdateFormComponent implements OnInit {
this.profileFacade.update(this.profile.id, data);
}
+
+ private customToast(action: ActionType, message: string): void {
+ if (this.error().hasError) {
+ this.toastrService.error(
+ `Une erreur s'est produite, veuillez réessayer ulterieurement`,
+ `Erreur`,
+ {
+ closeButton: true,
+ progressAnimation: 'decreasing',
+ progressBar: true,
+ }
+ );
+ return;
+ }
+
+ this.toastrService.success(
+ `${message}`,
+ `${action === ActionType.UPDATE ? 'Mise à jour' : ''}`,
+ {
+ closeButton: true,
+ progressAnimation: 'decreasing',
+ progressBar: true,
+ }
+ );
+ }
}
diff --git a/src/app/ui/profiles/profile.facade.ts b/src/app/ui/profiles/profile.facade.ts
index dc7bd2a..0d801e1 100644
--- a/src/app/ui/profiles/profile.facade.ts
+++ b/src/app/ui/profiles/profile.facade.ts
@@ -11,12 +11,14 @@ import { CreateProfileUseCase } from '@app/usecase/profiles/create-profile.useca
import { UpdateProfileUseCase } from '@app/usecase/profiles/update-profile.usecase';
import { GetProfileUseCase } from '@app/usecase/profiles/get-profile.usecase';
import { ProfileDTO } from '@app/domain/profiles/dto/create-profile.dto';
+import { AuthService } from '@app/core/services/authentication/auth.service';
@Injectable({
providedIn: 'root',
})
export class ProfileFacade {
private profileRepository = inject(PROFILE_REPOSITORY_TOKEN);
+ protected readonly authService = inject(AuthService);
private listUseCase = new ListProfilesUseCase(this.profileRepository);
private createUseCase = new CreateProfileUseCase(this.profileRepository);
@@ -80,6 +82,7 @@ export class ProfileFacade {
this.updateUseCase.execute(profileId, profile).subscribe({
next: (profile: Profile) => {
this.profile.set(ProfilePresenter.toViewModel(profile));
+ this.authService.updateUser();
this.handleError(ActionType.UPDATE, false, null, false);
},
error: (err) => {