Skip to content

Commit 0dc3890

Browse files
fix: add null-guards to dialog close callbacks in savings, clients, and loans views to prevent runtime errors
1 parent ad493a1 commit 0dc3890

3 files changed

Lines changed: 39 additions & 0 deletions

File tree

src/app/clients/clients-view/clients-view.component.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,9 @@ export class ClientsViewComponent implements OnInit {
276276
data: { deleteContext: `client with id: ${this.clientViewData.id}` }
277277
});
278278
deleteClientDialogRef.afterClosed().subscribe((response: any) => {
279+
if (!response) {
280+
return;
281+
}
279282
if (response.delete) {
280283
this.clientsService.deleteClient(this.clientViewData.id).subscribe(() => {
281284
this.router.navigate(['/clients'], { relativeTo: this.route });
@@ -290,6 +293,9 @@ export class ClientsViewComponent implements OnInit {
290293
private unassignStaff() {
291294
const unAssignStaffDialogRef = this.dialog.open(UnassignStaffDialogComponent);
292295
unAssignStaffDialogRef.afterClosed().subscribe((response: { confirm: any }) => {
296+
if (!response) {
297+
return;
298+
}
293299
if (response.confirm) {
294300
this.clientsService
295301
.executeClientCommand(this.clientViewData.id, 'unassignStaff', { staffId: this.clientViewData.staffId })
@@ -312,6 +318,9 @@ export class ClientsViewComponent implements OnInit {
312318
}
313319
});
314320
viewSignatureDialogRef.afterClosed().subscribe((response: any) => {
321+
if (!response) {
322+
return;
323+
}
315324
if (response.upload) {
316325
this.uploadSignature();
317326
} else if (response.draw) {
@@ -360,6 +369,9 @@ export class ClientsViewComponent implements OnInit {
360369
data: documents
361370
});
362371
deleteSignatureDialogRef.afterClosed().subscribe((response: any) => {
372+
if (!response) {
373+
return;
374+
}
363375
if (response.delete) {
364376
this.clientsService.deleteClientDocument(this.clientViewData.id, response.id).subscribe(() => {
365377
this.reload();

src/app/loans/loans-view/loans-view.component.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,9 @@ export class LoansViewComponent extends LoanProductBaseComponent implements OnIn
469469
}
470470
});
471471
recoverFromGuarantorDialogRef.afterClosed().subscribe((response: any) => {
472+
if (!response) {
473+
return;
474+
}
472475
if (response.confirm) {
473476
this.loansService.loanActionButtons(this.loanId, 'recoverGuarantees').subscribe(() => {
474477
this.reload();
@@ -500,6 +503,9 @@ export class LoansViewComponent extends LoanProductBaseComponent implements OnIn
500503
}
501504
});
502505
undoTransactionAccountDialogRef.afterClosed().subscribe((response: any) => {
506+
if (!response) {
507+
return;
508+
}
503509
if (response.confirm) {
504510
let undoCommand: string = '';
505511
switch (actionName) {
@@ -564,6 +570,9 @@ export class LoansViewComponent extends LoanProductBaseComponent implements OnIn
564570
data: { deleteContext: `with loan id: ${this.loanId}` }
565571
});
566572
deleteGuarantorDialogRef.afterClosed().subscribe((response: any) => {
573+
if (!response) {
574+
return;
575+
}
567576
if (response.delete) {
568577
this.loansService.deleteLoanAccount(this.loanId).subscribe(() => {
569578
this.router.navigate(['../../'], { relativeTo: this.route });

src/app/savings/savings-account-view/savings-account-view.component.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,9 @@ export class SavingsAccountViewComponent implements OnInit {
281281
data: { deleteContext: `savings account with id: ${this.savingsAccountData.id}` }
282282
});
283283
deleteSavingsAccountDialogRef.afterClosed().subscribe((response: any) => {
284+
if (!response) {
285+
return;
286+
}
284287
if (response.delete) {
285288
this.savingsService.deleteSavingsAccount(this.savingsAccountData.id).subscribe(() => {
286289
this.router.navigate(['../../'], { relativeTo: this.route });
@@ -295,6 +298,9 @@ export class SavingsAccountViewComponent implements OnInit {
295298
private calculateInterest() {
296299
const calculateInterestAccountDialogRef = this.dialog.open(CalculateInterestDialogComponent);
297300
calculateInterestAccountDialogRef.afterClosed().subscribe((response: any) => {
301+
if (!response) {
302+
return;
303+
}
298304
if (response.confirm) {
299305
this.savingsService
300306
.executeSavingsAccountCommand(this.savingsAccountData.id, 'calculateInterest', {})
@@ -311,6 +317,9 @@ export class SavingsAccountViewComponent implements OnInit {
311317
private postInterest() {
312318
const postInterestAccountDialogRef = this.dialog.open(PostInterestDialogComponent);
313319
postInterestAccountDialogRef.afterClosed().subscribe((response: any) => {
320+
if (!response) {
321+
return;
322+
}
314323
if (response.confirm) {
315324
this.savingsService
316325
.executeSavingsAccountCommand(this.savingsAccountData.id, 'postInterest', {})
@@ -329,6 +338,9 @@ export class SavingsAccountViewComponent implements OnInit {
329338
data: { isEnable: true }
330339
});
331340
deleteSavingsAccountDialogRef.afterClosed().subscribe((response: any) => {
341+
if (!response) {
342+
return;
343+
}
332344
if (response.confirm) {
333345
this.savingsService
334346
.executeSavingsAccountUpdateCommand(this.savingsAccountData.id, 'updateWithHoldTax', { withHoldTax: true })
@@ -347,6 +359,9 @@ export class SavingsAccountViewComponent implements OnInit {
347359
data: { isEnable: false }
348360
});
349361
disableWithHoldTaxDialogRef.afterClosed().subscribe((response: any) => {
362+
if (!response) {
363+
return;
364+
}
350365
if (response.confirm) {
351366
this.savingsService
352367
.executeSavingsAccountUpdateCommand(this.savingsAccountData.id, 'updateWithHoldTax', { withHoldTax: false })
@@ -378,6 +393,9 @@ export class SavingsAccountViewComponent implements OnInit {
378393
command = 'unblockDebit';
379394
}
380395
unblockSavingsAccountDialogRef.afterClosed().subscribe((response: { confirm: any }) => {
396+
if (!response) {
397+
return;
398+
}
381399
if (response.confirm) {
382400
this.savingsService.executeSavingsAccountCommand(this.savingsAccountData.id, command, {}).subscribe(() => {
383401
this.reload();

0 commit comments

Comments
 (0)