refactor (df/locale): organization module (#1268)

See: #1213
This commit is contained in:
Benura Abeywardena
2020-11-12 19:36:37 +05:30
committed by GitHub
parent dbd34aaf42
commit 5f90bc00bd
26 changed files with 139 additions and 62 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 teller component.
@@ -32,12 +33,14 @@ export class CreateTellerComponent implements OnInit {
* Retrieves the offices data from `resolve`.
* @param {FormBuilder} formBuilder Form Builder.
* @param {OrganizationService} organizationService Organization Service.
* @param {SettingsService} settingsService Settings Service.
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
* @param {DatePipe} datePipe Date Pipe to format date.
*/
constructor(private formBuilder: FormBuilder,
private organizationService: OrganizationService,
private settingsService: SettingsService,
private route: ActivatedRoute,
private router: Router,
private datePipe: DatePipe) {
@@ -77,13 +80,13 @@ export class CreateTellerComponent implements OnInit {
const prevStartDate: Date = this.tellerForm.value.startDate;
const prevEndDate: Date = this.tellerForm.value.endDate;
// TODO: Update once language and date settings are setup
const dateFormat = 'yyyy-MM-dd';
const dateFormat = this.settingsService.dateFormat;
this.tellerForm.patchValue({
startDate: this.datePipe.transform(prevStartDate, dateFormat),
endDate: this.datePipe.transform(prevEndDate, dateFormat)
});
const teller = this.tellerForm.value;
teller.locale = 'en';
teller.locale = this.settingsService.language.code;
teller.dateFormat = dateFormat;
this.organizationService.createTeller(teller).subscribe((response: any) => {
this.router.navigate(['../', response.resourceId], { relativeTo: this.route });