This commit is contained in:
Anshu 2026-02-04 18:28:39 -06:00 committed by GitHub
commit 38cb90363f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -11,6 +11,7 @@ import { Component, OnInit, inject } from '@angular/core';
import { UntypedFormBuilder, UntypedFormGroup, Validators, ReactiveFormsModule } from '@angular/forms';
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
import { SettingsService } from 'app/settings/settings.service';
import { Dates } from 'app/core/utils/dates';
/** Custom Services */
import { SystemService } from '../../../system.service';
@ -35,6 +36,7 @@ export class EditConfigurationComponent implements OnInit {
private settingsService = inject(SettingsService);
private route = inject(ActivatedRoute);
private router = inject(Router);
private dateUtils = inject(Dates);
/** Minimum transaction date allowed. */
minDate = new Date(2000, 0, 1);
@ -94,20 +96,33 @@ export class EditConfigurationComponent implements OnInit {
this.configurationForm.value.stringValue != null ||
this.configurationForm.value.dateValue != null
) {
const payload = {
const payload: any = {
...this.configurationForm.value
};
if (!this.configurationForm.value.stringValue) {
delete payload.stringValue;
}
if (this.configurationForm.value.dateValue != null) {
payload.locale = this.settingsService.language.code;
payload.dateFormat = this.settingsService.dateFormat;
// Format the date according to the dateFormat setting
const dateFormat = this.settingsService.dateFormat || 'dd MMMM yyyy';
const formattedDate = this.dateUtils.formatDate(this.configurationForm.value.dateValue, dateFormat);
if (formattedDate) {
payload.dateValue = formattedDate;
payload.locale = this.settingsService.language.code;
payload.dateFormat = dateFormat;
} else {
// Avoid sending invalid/null date to backend
delete payload.dateValue;
}
} else {
delete payload.dateValue;
}
this.systemService.updateConfiguration(this.configuration.id, payload).subscribe((response: any) => {
this.systemService.updateConfiguration(this.configuration.id, payload).subscribe(() => {
this.router.navigate(['../../'], { relativeTo: this.route });
});
}