From 16d600d21150d8ca27dcc8d78b67deb46612ade3 Mon Sep 17 00:00:00 2001 From: SnehaRH Date: Fri, 27 Mar 2026 14:53:29 +0530 Subject: [PATCH] fix: prevent user logout on sub store indent receive error Stop the HTTP interceptor from clearing session and redirecting to login on non-authentication errors. Only 401/403 errors now trigger logout. Added error handling in the receiveIndent subscribe to show a single user-friendly error message. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../core/services/http-interceptor.service.ts | 14 +++++----- ...b-store-indent-order-worklist.component.ts | 26 ++++++++++++------- src/environments/environment.ci.ts.template | 2 +- src/environments/environment.local.ts | 2 +- src/environments/environment.prod.ts | 2 +- src/environments/environment.test.ts | 2 +- 6 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/app/app-modules/core/services/http-interceptor.service.ts b/src/app/app-modules/core/services/http-interceptor.service.ts index 4e40432..194d699 100644 --- a/src/app/app-modules/core/services/http-interceptor.service.ts +++ b/src/app/app-modules/core/services/http-interceptor.service.ts @@ -81,15 +81,13 @@ export class HttpInterceptorService implements HttpInterceptor { if (error.status === 401 || error.status === 403) { this.confirmationService.alert( - "Session expired. Please log in again to continue", 'error' + 'Session expired. Please log in again to continue', + 'error', ); - } else this.confirmationService.alert( - error.error.errorMessage || "Something went wrong. Please try again later.", - 'error', - ); - this.router.navigate(['/login']); - sessionStorage.clear(); - localStorage.clear(); + this.router.navigate(['/login']); + sessionStorage.clear(); + localStorage.clear(); + } this.spinnerService.show(); return throwError(error.error); }), diff --git a/src/app/app-modules/inventory/indent/indent-order-worklist/sub-store-indent-order-worklist/sub-store-indent-order-worklist.component.ts b/src/app/app-modules/inventory/indent/indent-order-worklist/sub-store-indent-order-worklist/sub-store-indent-order-worklist.component.ts index a09f087..51380a0 100644 --- a/src/app/app-modules/inventory/indent/indent-order-worklist/sub-store-indent-order-worklist/sub-store-indent-order-worklist.component.ts +++ b/src/app/app-modules/inventory/indent/indent-order-worklist/sub-store-indent-order-worklist/sub-store-indent-order-worklist.component.ts @@ -114,17 +114,25 @@ export class SubStoreIndentOrderWorklistComponent implements OnInit, DoCheck { console.log('acceptorder', acceptorder); this.inventoryService .receiveIndentOrder(acceptorder) - .subscribe((acceptOrderResponse) => { - if (acceptOrderResponse.statusCode === 200) { + .subscribe( + (acceptOrderResponse) => { + if (acceptOrderResponse.statusCode === 200) { + this.confirmationService.alert( + acceptOrderResponse.data.response, + 'success', + ); + this.showSubstoreOrderWorklist(this.orderReqObject); + } else { + this.confirmationService.alert(acceptOrderResponse.errorMessage); + } + }, + (error) => { + console.error('Error receiving indent', error); this.confirmationService.alert( - acceptOrderResponse.data.response, - 'success', + error?.errorMessage || this.currentLanguageSet?.inventory?.receiveIndentFailed || 'Failed to receive indent. Please try again.', ); - this.showSubstoreOrderWorklist(this.orderReqObject); - } else { - this.confirmationService.alert(acceptOrderResponse.errorMessage); - } - }); + }, + ); } goToUpdateIndentRequest(indentDetails: any) { console.log('indentDetails', indentDetails); diff --git a/src/environments/environment.ci.ts.template b/src/environments/environment.ci.ts.template index a6f6563..2615ef6 100644 --- a/src/environments/environment.ci.ts.template +++ b/src/environments/environment.ci.ts.template @@ -115,7 +115,7 @@ export const environment = { viewItemListForMainStoreUrl: `${INVENTORY_API}indentController/getIndentOrderWorklist`, getSaveDispenseListUrl: `${INVENTORY_API}indentController/issueIndent`, - receiveIndentOrderUrl: `${INVENTORY_API}/indentController/receiveIndent`, + receiveIndentOrderUrl: `${INVENTORY_API}indentController/receiveIndent`, updateIndentOrderUrl: `${INVENTORY_API}indentController/updateIndentOrder`, /* Report URL's*/ diff --git a/src/environments/environment.local.ts b/src/environments/environment.local.ts index 15400f0..27eec21 100644 --- a/src/environments/environment.local.ts +++ b/src/environments/environment.local.ts @@ -124,7 +124,7 @@ export const environment = { viewItemListForMainStoreUrl: `${INVENTORY_API}indentController/getIndentOrderWorklist`, getSaveDispenseListUrl: `${INVENTORY_API}indentController/issueIndent`, - receiveIndentOrderUrl: `${INVENTORY_API}/indentController/receiveIndent`, + receiveIndentOrderUrl: `${INVENTORY_API}indentController/receiveIndent`, updateIndentOrderUrl: `${INVENTORY_API}indentController/updateIndentOrder`, /* Report URL's*/ diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index bd52b42..91fc35d 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -125,7 +125,7 @@ export const environment = { viewItemListForMainStoreUrl: `${INVENTORY_API}indentController/getIndentOrderWorklist`, getSaveDispenseListUrl: `${INVENTORY_API}indentController/issueIndent`, - receiveIndentOrderUrl: `${INVENTORY_API}/indentController/receiveIndent`, + receiveIndentOrderUrl: `${INVENTORY_API}indentController/receiveIndent`, updateIndentOrderUrl: `${INVENTORY_API}indentController/updateIndentOrder`, /* Report URL's*/ diff --git a/src/environments/environment.test.ts b/src/environments/environment.test.ts index e12747a..573c12f 100644 --- a/src/environments/environment.test.ts +++ b/src/environments/environment.test.ts @@ -119,7 +119,7 @@ export const environment = { viewItemListForMainStoreUrl: `${INVENTORY_API}indentController/getIndentOrderWorklist`, getSaveDispenseListUrl: `${INVENTORY_API}indentController/issueIndent`, - receiveIndentOrderUrl: `${INVENTORY_API}/indentController/receiveIndent`, + receiveIndentOrderUrl: `${INVENTORY_API}indentController/receiveIndent`, updateIndentOrderUrl: `${INVENTORY_API}indentController/updateIndentOrder`, /* Report URL's*/