([]);
readonly error = signal(
this.data.profile ? '' : 'Impossible de charger votre profil bailleur. Réessayez.',
);
@@ -63,6 +64,7 @@ export class LandlordProfileCompletionDialog {
save(profile: LandlordProfile): void {
if (this.saving()) return;
this.error.set('');
+ this.saveFieldErrors.set([]);
this.saving.set(true);
this.landlordProfile
.updateProfile(profile)
@@ -70,17 +72,24 @@ export class LandlordProfileCompletionDialog {
.subscribe({
next: () => this.dialogRef.close(),
error: (error: unknown) => {
- this.error.set(
- httpErrorMessage(
- error,
- 'Impossible d’enregistrer votre profil bailleur. Réessayez.',
- ),
+ const failure = saveFailure(
+ error,
+ 'Impossible d’enregistrer votre profil bailleur. Réessayez.',
);
+ this.error.set(failure.message);
+ this.saveFieldErrors.set(failure.fieldErrors);
this.saving.set(false);
},
});
}
+ clearSaveFieldError(field: string): void {
+ const remaining = this.saveFieldErrors().filter((error) => error.field !== field);
+ if (remaining.length === this.saveFieldErrors().length) return;
+ this.saveFieldErrors.set(remaining);
+ if (!remaining.length) this.error.set('');
+ }
+
logout(): void {
this.session.logout();
}
diff --git a/frontend/src/app/components/landlord-profile-form/landlord-profile-form.html b/frontend/src/app/components/landlord-profile-form/landlord-profile-form.html
index 42b91a4..748c0ed 100644
--- a/frontend/src/app/components/landlord-profile-form/landlord-profile-form.html
+++ b/frontend/src/app/components/landlord-profile-form/landlord-profile-form.html
@@ -4,8 +4,11 @@
(ngSubmit)="submit()"
[attr.aria-busy]="saving()"
>
- @if (error()) {
- {{ error() }}
+ @if (showSaveError()) {
+ {{ saveError() }}
+ }
+ @if (validationError()) {
+ {{ validationError() }}
}