refactor (df/locale): centers module (#1269)

See: #1213
This commit is contained in:
Devendra Kharolia
2020-11-12 19:34:38 +05:30
committed by GitHub
parent d191d11c10
commit dbd34aaf42
9 changed files with 46 additions and 20 deletions
@@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */
import { CentersService } from 'app/centers/centers.service';
import { SettingsService } from 'app/settings/settings.service';
/**
* Close Center Component
@@ -31,12 +32,14 @@ export class CloseCenterComponent implements OnInit {
/**
* @param {FormBuilder} formBuilder Form Builder
* @param {CentersService} centersService Shares Service
* @param {SettingsService} settingsService Settings Service.
* @param {DatePipe} datePipe Date Pipe
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
*/
constructor(private formBuilder: FormBuilder,
private centersService: CentersService,
private settingsService: SettingsService,
private datePipe: DatePipe,
private route: ActivatedRoute,
private router: Router) {
@@ -65,8 +68,8 @@ export class CloseCenterComponent implements OnInit {
*/
submit() {
// TODO: Update once language and date settings are setup
const locale = 'en';
const dateFormat = 'dd MMMM yyyy';
const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat;
const prevClosedDate: Date = this.closeCenterForm.value.closureDate;
this.closeCenterForm.patchValue({
closureDate: this.datePipe.transform(prevClosedDate, dateFormat),