Format date fields without patch form

This commit is contained in:
Jose Alberto Hernandez
2022-06-10 10:34:19 +02:00
committed by Arnold Gálovics
parent 9d43181cea
commit 6ea3d97538
191 changed files with 1408 additions and 1173 deletions
@@ -13,8 +13,6 @@ import { Dates } from 'app/core/utils/dates';
styleUrls: ['./foreclosure.component.scss']
})
export class ForeclosureComponent implements OnInit {
loanId: any;
foreclosureForm: FormGroup;
/** Minimum Date allowed. */
@@ -24,7 +22,6 @@ export class ForeclosureComponent implements OnInit {
foreclosuredata: any;
paymentTypes: any;
/**
* @param {FormBuilder} formBuilder Form Builder.
* @param {LoansService} systemService Loan Service.
@@ -108,19 +105,20 @@ export class ForeclosureComponent implements OnInit {
}
submit() {
const transactionDate = this.foreclosureForm.value.transactionDate;
const foreclosureFormData = this.foreclosureForm.value;
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
this.foreclosureForm.patchValue({
transactionDate: this.dateUtils.formatDate(transactionDate, dateFormat)
});
const formData = {
transactionDate: this.foreclosureForm.value.transactionDate,
locale: this.settingsService.language.code,
dateFormat: dateFormat,
note: this.foreclosureForm.value.note
const prevTransactionDate = this.foreclosureForm.value.transactionDate;
if (foreclosureFormData.transactionDate instanceof Date) {
foreclosureFormData.transactionDate = this.dateUtils.formatDate(prevTransactionDate, dateFormat);
}
const data = {
...foreclosureFormData,
dateFormat,
locale
};
this.loanService.loanForclosureData(this.loanId, formData)
this.loanService.loanForclosureData(this.loanId, data)
.subscribe((response: any) => {
this.router.navigate([`../../general`], { relativeTo: this.route });
});