feat: add loan button (undo-approval) (#860)

Fixes: #858
This commit is contained in:
Benura Abeywardena
2020-06-11 01:18:12 +05:30
committed by GitHub
parent 8503dc6d97
commit fb52d3cf21
8 changed files with 113 additions and 2 deletions
@@ -0,0 +1,45 @@
/** Angular Imports. */
import { Component, OnInit } from '@angular/core';
import { FormControl, FormBuilder } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services. */
import { LoansService } from 'app/loans/loans.service';
/**
* Undo Loan component.
*/
@Component({
selector: 'mifosx-undo-approval',
templateUrl: './undo-approval.component.html',
styleUrls: ['./undo-approval.component.scss']
})
export class UndoApprovalComponent implements OnInit {
/** Form Controller. */
note: FormControl;
/**
* @param loanService Loan Service.
* @param route Activated Route.
* @param router Router.
*/
constructor(private loanService: LoansService,
private formBuilder: FormBuilder,
private route: ActivatedRoute,
private router: Router) { }
ngOnInit() {
this.note = this.formBuilder.control('');
}
/**
* Submits undo approval form.
*/
submit() {
const loanId = this.route.parent.snapshot.params['loanId'];
this.loanService.undoLoanApproval(loanId, {'note': this.note.value}).subscribe((response: any) => {
this.router.navigate(['../general'], {relativeTo: this.route});
});
}
}