From 896e3fd7e8c7c6a115ac44b71bad06c7917737b8 Mon Sep 17 00:00:00 2001 From: Nitesh Yadav Date: Mon, 19 Oct 2026 15:33:22 +0530 Subject: [PATCH] fix(credit-bureau): keep customer enquiry list stable and add back navigation in alert detail Co-Authored-By: Claude Sonnet 5.5 --- .../cic-alert-detail.component.html | 25 +++++++++++--- .../cic-alert-detail.component.ts | 34 ++++++++++++++++++- 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/src/app/credit-bureau/cic-alert-detail/cic-alert-detail.component.html b/src/app/credit-bureau/cic-alert-detail/cic-alert-detail.component.html index 399e2bcfe..ac9fb4fa4 100644 --- a/src/app/credit-bureau/cic-alert-detail/cic-alert-detail.component.html +++ b/src/app/credit-bureau/cic-alert-detail/cic-alert-detail.component.html @@ -12,6 +12,12 @@
Loading…
} @if (alert) { + @if (history.length) { +
+ You are viewing another enquiry of this customer. + +
+ }

@@ -160,8 +166,8 @@ @if (alert.otherAlertsOfCustomer?.length) {

- Other enquiries on this customer - {{ alert.otherAlertsOfCustomer?.length }} more + All enquiries on this customer + {{ customerEnquiries.length }} in total

@@ -174,10 +180,19 @@ - @for (o of alert.otherAlertsOfCustomer; track o.id) { - + @for (o of customerEnquiries; track o.id) { + - +
{{ o.enquiryDate | date: 'dd MMM yyyy' }}{{ o.loanType }} + {{ o.loanType }} + @if (o.id === alert.id) { + (shown above) + } + {{ o.amount | number: '1.0-0' }} {{ o.status }} diff --git a/src/app/credit-bureau/cic-alert-detail/cic-alert-detail.component.ts b/src/app/credit-bureau/cic-alert-detail/cic-alert-detail.component.ts index bc3c6aed7..8055ed319 100644 --- a/src/app/credit-bureau/cic-alert-detail/cic-alert-detail.component.ts +++ b/src/app/credit-bureau/cic-alert-detail/cic-alert-detail.component.ts @@ -52,6 +52,10 @@ export class CicAlertDetailComponent implements OnChanges { info: string | null = null; showRaw = false; + /** Alerts visited before the current one, so the user can go back after opening another enquiry of the customer. */ + history: number[] = []; + private autoSeen = true; + action: 'ACTIONED' | 'DISMISSED' | null = null; remarks = ''; @@ -59,9 +63,27 @@ export class CicAlertDetailComponent implements OnChanges { readonly statusTone = cicStatusTone; ngOnChanges(): void { + this.history = []; + this.autoSeen = true; if (this.alertId) this.load(); } + openOther(id: number): void { + if (this.alertId) this.history.push(this.alertId); + this.alertId = id; + // Only the alert opened from the dashboard counts as "seen"; browsing the customer's other enquiries changes nothing. + this.autoSeen = false; + this.load(); + } + + back(): void { + const id = this.history.pop(); + if (!id) return; + this.alertId = id; + this.autoSeen = false; + this.load(); + } + load(): void { if (!this.alertId) return; this.loading = true; @@ -73,8 +95,9 @@ export class CicAlertDetailComponent implements OnChanges { next: (a) => { this.alert = a; this.loading = false; + setTimeout(() => document.querySelector('.cic-modal')?.scrollTo({ top: 0 })); // Opening a new alert is seeing it. - if (a.status === 'NEW' && a.clientId) this.setStatus('SEEN', null, true); + if (this.autoSeen && a.status === 'NEW' && a.clientId) this.setStatus('SEEN', null, true); }, error: (e) => { this.loading = false; @@ -139,6 +162,15 @@ export class CicAlertDetailComponent implements OnChanges { }); } + /** All of the customer's enquiries, this one included, in a fixed order so the list does not reshuffle when one is opened. */ + get customerEnquiries(): CicAlert[] { + if (!this.alert) return []; + return [ + this.alert, + ...(this.alert.otherAlertsOfCustomer ?? []) + ].sort((x, y) => (y.enquiryDate ?? '').localeCompare(x.enquiryDate ?? '') || y.id - x.id); + } + get exposure(): number { return (this.alert?.clientLoans ?? []).reduce((s, l) => s + Number(l.outstanding ?? 0), 0); }