feat: add loan button (close action) (#855)

Fixes: #849
This commit is contained in:
Muskan Khedia
2020-06-09 10:27:33 +05:30
committed by GitHub
parent 347e84f366
commit a3f60783dc
17 changed files with 222 additions and 14 deletions
@@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
import { LoansService } from '../loans.service';
// Custom Imports
@@ -26,12 +26,14 @@ export class LoansViewComponent implements OnInit {
taskPermissionName: string
}[]
};
loanId: number;
constructor(private route: ActivatedRoute) {
constructor(private route: ActivatedRoute,
private router: Router) {
this.route.data.subscribe((data: { loanDetailsData: any, }) => {
this.loanDetailsData = data.loanDetailsData;
console.log('loandata:: ', this.loanDetailsData);
});
this.loanId = this.route.snapshot.params['loanId'];
}
ngOnInit() {
@@ -39,7 +41,6 @@ export class LoansViewComponent implements OnInit {
this.recalculateInterest = this.loanDetailsData.recalculateInterest || true;
this.status = this.loanDetailsData.status.value;
console.log('status: ', this.status);
// Defines the buttons based on the status of the loan account
if (this.status === 'Submitted and pending approval') {
this.buttons = ButtonConfig['Submitted and pending approval'];
@@ -102,10 +103,14 @@ export class LoansViewComponent implements OnInit {
} else if (this.status === 'Overpaid') {
this.buttons = ButtonConfig['Overpaid'];
} else if (this.status === 'Closed (written off)') {
this.buttons = ButtonConfig['Closed (written off)'];
this.buttons = ButtonConfig['ClosedWrittenOff'];
}
console.log('this.buttons: ', this.buttons);
}
loanAction(button: string) {
button = button.replace(' ', '-').toLowerCase();
this.router.navigate([button], { relativeTo: this.route });
}
}