From eb070974db8092490bac8583ee8f17175a95b9a1 Mon Sep 17 00:00:00 2001 From: JaySoni1 Date: Wed, 3 Sep 2025 18:38:11 +0530 Subject: [PATCH] fix(client-profile): handle missing profile image and remove skipErrorHandler usage - Use standard HTTP error handling instead of skipErrorHandler - Handle 404 errors gracefully in component as expected behavior --- .../clients-view/clients-view.component.ts | 17 +++++++++++++---- src/app/clients/clients.service.ts | 5 ++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/app/clients/clients-view/clients-view.component.ts b/src/app/clients/clients-view/clients-view.component.ts index 0668ac269..74dc275cc 100644 --- a/src/app/clients/clients-view/clients-view.component.ts +++ b/src/app/clients/clients-view/clients-view.component.ts @@ -90,12 +90,21 @@ export class ClientsViewComponent implements OnInit { } ngOnInit() { - this.clientsService.getClientProfileImage(this.clientViewData.id).subscribe( - (base64Image: any) => { + this.clientsService.getClientProfileImage(this.clientViewData.id).subscribe({ + next: (base64Image: any) => { this.clientImage = this._sanitizer.bypassSecurityTrustResourceUrl(base64Image); }, - (error: any) => {} - ); + error: (error: any) => { + // 404 is expected when client has no profile image - not an error + if (error.status === 404) { + this.clientImage = null; + } else { + // Log other unexpected errors + console.error('Error loading client profile image:', error); + this.clientImage = null; + } + } + }); } isActive(): boolean { diff --git a/src/app/clients/clients.service.ts b/src/app/clients/clients.service.ts index 86b503dd0..cc642963d 100644 --- a/src/app/clients/clients.service.ts +++ b/src/app/clients/clients.service.ts @@ -4,6 +4,7 @@ import { HttpClient, HttpParams } from '@angular/common/http'; /** rxjs Imports */ import { Observable } from 'rxjs'; + /** * Clients service. */ @@ -170,9 +171,7 @@ export class ClientsService { getClientProfileImage(clientId: string) { const httpParams = new HttpParams().set('maxHeight', '150'); - return this.http - .skipErrorHandler() - .get(`/clients/${clientId}/images`, { params: httpParams, responseType: 'text' }); + return this.http.get(`/clients/${clientId}/images`, { params: httpParams, responseType: 'text' }); } uploadClientProfileImage(clientId: string, image: File) {