feat: initialize language and date-format settings (#1214)

See: #1213
This commit is contained in:
Karan Takalkar
2020-08-16 20:08:28 +05:30
committed by GitHub
parent 1071f3828b
commit 199a8b6c9c
6 changed files with 137 additions and 14 deletions
@@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common';
/** Custom Services */
import { OrganizationService } from '../../organization.service';
import { SettingsService } from 'app/settings/settings.service';
/**
* Create Office component.
@@ -36,6 +37,7 @@ export class CreateOfficeComponent implements OnInit {
*/
constructor(private formBuilder: FormBuilder,
private organizationService: OrganizationService,
private settingsService: SettingsService,
private router: Router,
private route: ActivatedRoute,
private datePipe: DatePipe) {
@@ -67,12 +69,12 @@ export class CreateOfficeComponent implements OnInit {
submit() {
const prevOpeningDate: Date = this.officeForm.value.openingDate;
// TODO: Update once language and date settings are setup
const dateFormat = 'yyyy-MM-dd';
const dateFormat = this.settingsService.dateFormat;
this.officeForm.patchValue({
openingDate: this.datePipe.transform(prevOpeningDate, dateFormat)
});
const office = this.officeForm.value;
office.locale = 'en';
office.locale = this.settingsService.language.code;
office.dateFormat = dateFormat;
this.organizationService.createOffice(office).subscribe(response => {
this.router.navigate(['../'], { relativeTo: this.route });