refactor (df/locale): loans module (#1264)

See: #1213
This commit is contained in:
Shubhankar Bhadra
2020-10-25 13:06:23 +05:30
committed by GitHub
parent 2b5341aa2c
commit 9d438b140e
26 changed files with 179 additions and 84 deletions
@@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */
import { LoansService } from 'app/loans/loans.service';
import { DatePipe } from '@angular/common';
import { SettingsService } from 'app/settings/settings.service';
/**
* Loan Make Repayment Component
@@ -37,12 +38,14 @@ export class MakeRepaymentComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
* @param {DatePipe} datePipe Date Pipe.
* @param {SettingsService} settingsService Settings Service
*/
constructor(private formBuilder: FormBuilder,
private loanService: LoansService,
private route: ActivatedRoute,
private router: Router,
private datePipe: DatePipe) {
private datePipe: DatePipe,
private settingsService: SettingsService) {
this.loanId = this.route.parent.snapshot.params['loanId'];
}
@@ -99,12 +102,12 @@ export class MakeRepaymentComponent implements OnInit {
submit() {
const prevTransactionDate: Date = this.repaymentLoanForm.value.transactionDate;
// TODO: Update once language and date settings are setup
const dateFormat = 'dd-MM-yyyy';
const dateFormat = this.settingsService.dateFormat;
this.repaymentLoanForm.patchValue({
transactionDate: this.datePipe.transform(prevTransactionDate, dateFormat)
});
const repaymentLoanData = this.repaymentLoanForm.value;
repaymentLoanData.locale = 'en';
repaymentLoanData.locale = this.settingsService.language.code;
repaymentLoanData.dateFormat = dateFormat;
this.loanService.submitLoanActionButton(this.loanId, repaymentLoanData, 'repayment')
.subscribe((response: any) => {