refactor (df/locale): groups module (#1263)

See: #1213
This commit is contained in:
Abhirup Pal
2020-10-16 20:26:58 +05:30
committed by GitHub
parent 6372656c98
commit 862fb62b26
11 changed files with 63 additions and 31 deletions
@@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */
import { GroupsService } from 'app/groups/groups.service';
import { SettingsService } from 'app/settings/settings.service';
/**
* Close Group Component
@@ -34,12 +35,14 @@ export class CloseGroupComponent implements OnInit {
* @param {DatePipe} datePipe Date Pipe
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {SettingsService} settingsService SettingsService
*/
constructor(private formBuilder: FormBuilder,
private groupsService: GroupsService,
private datePipe: DatePipe,
private route: ActivatedRoute,
private router: Router) {
private router: Router,
private settingsService: SettingsService) {
this.route.data.subscribe((data: { groupActionData: any }) => {
this.closureData = data.groupActionData.closureReasons;
});
@@ -65,8 +68,8 @@ export class CloseGroupComponent 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.closeGroupForm.value.closureDate;
this.closeGroupForm.patchValue({
closureDate: this.datePipe.transform(prevClosedDate, dateFormat),