refactor(df/locale): clients module (#1257)

See: #1213
This commit is contained in:
Abhirup Pal
2020-10-16 20:17:59 +05:30
committed by GitHub
parent ee2f53e503
commit aeeb2cc5f1
17 changed files with 104 additions and 50 deletions
@@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */
import { ClientsService } from 'app/clients/clients.service';
import { SettingsService } from 'app/settings/settings.service';
/**
* Activate Client Component
@@ -32,12 +33,14 @@ export class ActivateClientComponent implements OnInit {
* @param {DatePipe} datePipe Date Pipe
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {SettingsService} settingsService Settings Service
*/
constructor(private formBuilder: FormBuilder,
private clientsService: ClientsService,
private datePipe: DatePipe,
private route: ActivatedRoute,
private router: Router) {
private router: Router,
private settingsService: SettingsService) {
this.clientId = this.route.parent.snapshot.params['clientId'];
}
@@ -63,8 +66,8 @@ export class ActivateClientComponent 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 prevActivationDate: Date = this.activateClientForm.value.activationDate;
this.activateClientForm.patchValue({
activationDate: this.datePipe.transform(prevActivationDate, dateFormat),
@@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common';
/** Custom Services */
import { ClientsService } from 'app/clients/clients.service';
import { SettingsService } from 'app/settings/settings.service';
/**
* Add Clients Charge component.
@@ -37,13 +38,15 @@ export class AddClientChargeComponent implements OnInit {
* @param {Router} router Router
* @param {DatePipe} datePipe Date Pipe
* @param {ClientsService} clientsService Clients Service
* @param {SettingsService} settingsService Setting service
*/
constructor(
private formBuilder: FormBuilder,
private route: ActivatedRoute,
private router: Router,
private datePipe: DatePipe,
private clientsService: ClientsService
private clientsService: ClientsService,
private settingsService: SettingsService
) {
this.route.data.subscribe((data: { clientActionData: any }) => {
this.clientChargeOptions = data.clientActionData.chargeOptions;
@@ -111,7 +114,7 @@ export class AddClientChargeComponent implements OnInit {
*/
submit() {
const clientCharge = this.clientChargeForm.value;
clientCharge.locale = 'en';
clientCharge.locale = this.settingsService.language.code;
if (!clientCharge.feeInterval) {
clientCharge.feeInterval = this.chargeDetails.feeInterval;
}
@@ -124,7 +127,7 @@ export class AddClientChargeComponent implements OnInit {
clientCharge.feeOnMonthDay = this.datePipe.transform(prevDate, monthDayFormat);
}
} else {
const dateFormat = 'yyyy-MM-dd';
const dateFormat = this.settingsService.dateFormat;
clientCharge.dateFormat = dateFormat;
if (clientCharge.dueDate) {
const prevDate = this.clientChargeForm.value.dueDate;
@@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */
import { ClientsService } from 'app/clients/clients.service';
import { SettingsService } from 'app/settings/settings.service';
/**
* Close Client Component
@@ -34,12 +35,14 @@ export class CloseClientComponent implements OnInit {
* @param {DatePipe} datePipe Date Pipe
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {SettingsService} settingsService Setting service
*/
constructor(private formBuilder: FormBuilder,
private clientsService: ClientsService,
private datePipe: DatePipe,
private route: ActivatedRoute,
private router: Router) {
private router: Router,
private settingsService: SettingsService) {
this.route.data.subscribe((data: { clientActionData: any }) => {
this.closureData = data.clientActionData.narrations;
});
@@ -65,8 +68,8 @@ export class CloseClientComponent 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.closeClientForm.value.closureDate;
this.closeClientForm.patchValue({
closureDate: this.datePipe.transform(prevClosedDate, dateFormat),
@@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */
import { ClientsService } from 'app/clients/clients.service';
import { SettingsService } from 'app/settings/settings.service';
/**
* Reactivate Client Component
@@ -32,12 +33,14 @@ export class ReactivateClientComponent implements OnInit {
* @param {DatePipe} datePipe Date Pipe
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {SettingsService} settingsService Setting service
*/
constructor(private formBuilder: FormBuilder,
private clientsService: ClientsService,
private datePipe: DatePipe,
private route: ActivatedRoute,
private router: Router) {
private router: Router,
private settingsService: SettingsService) {
this.clientId = this.route.parent.snapshot.params['clientId'];
}
@@ -63,8 +66,8 @@ export class ReactivateClientComponent 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 prevReactivationDate: Date = this.reactivateClientForm.value.reactivationDate;
this.reactivateClientForm.patchValue({
reactivationDate: this.datePipe.transform(prevReactivationDate, dateFormat),
@@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */
import { ClientsService } from 'app/clients/clients.service';
import { SettingsService } from 'app/settings/settings.service';
/**
* Reject Client Component
@@ -34,12 +35,14 @@ export class RejectClientComponent implements OnInit {
* @param {DatePipe} datePipe Date Pipe
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {SettingsService} settingsService Setting service
*/
constructor(private formBuilder: FormBuilder,
private clientsService: ClientsService,
private datePipe: DatePipe,
private route: ActivatedRoute,
private router: Router) {
private router: Router,
private settingsService: SettingsService) {
this.route.data.subscribe((data: { clientActionData: any }) => {
this.rejectionData = data.clientActionData.narrations;
});
@@ -65,8 +68,8 @@ export class RejectClientComponent 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 prevRejectedDate: Date = this.rejectClientForm.value.rejectionDate;
this.rejectClientForm.patchValue({
rejectionDate: this.datePipe.transform(prevRejectedDate, dateFormat),
@@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */
import { ClientsService } from 'app/clients/clients.service';
import { SettingsService } from 'app/settings/settings.service';
/**
* Transfer Client Component
@@ -34,12 +35,14 @@ export class TransferClientComponent implements OnInit {
* @param {DatePipe} datePipe Date Pipe
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {SettingsService} settingsService Setting service
*/
constructor(private formBuilder: FormBuilder,
private clientsService: ClientsService,
private datePipe: DatePipe,
private route: ActivatedRoute,
private router: Router) {
private router: Router,
private settingsService: SettingsService) {
this.route.data.subscribe((data: { clientActionData: any }) => {
this.officeData = data.clientActionData;
});
@@ -66,8 +69,8 @@ export class TransferClientComponent 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.transferClientForm.value.transferDate;
this.transferClientForm.patchValue({
transferDate: this.datePipe.transform(prevClosedDate, dateFormat),
@@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */
import { ClientsService } from 'app/clients/clients.service';
import { SettingsService } from 'app/settings/settings.service';
/**
* Undo Client Rejection Component
@@ -37,7 +38,8 @@ export class UndoClientRejectionComponent implements OnInit {
private clientsService: ClientsService,
private datePipe: DatePipe,
private route: ActivatedRoute,
private router: Router) {
private router: Router,
private settingsService: SettingsService) {
this.clientId = this.route.parent.snapshot.params['clientId'];
}
@@ -63,8 +65,8 @@ export class UndoClientRejectionComponent 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 prevReopenedDate: Date = this.undoClientRejectionForm.value.reopenedDate;
this.undoClientRejectionForm.patchValue({
reopenedDate: this.datePipe.transform(prevReopenedDate, dateFormat),
@@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */
import { ClientsService } from 'app/clients/clients.service';
import { SettingsService } from 'app/settings/settings.service';
/**
* Withdraw Client Component
@@ -34,12 +35,14 @@ export class WithdrawClientComponent implements OnInit {
* @param {DatePipe} datePipe Date Pipe
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
* @param {SettingsService} settingsService Setting service
*/
constructor(private formBuilder: FormBuilder,
private clientsService: ClientsService,
private datePipe: DatePipe,
private route: ActivatedRoute,
private router: Router) {
private router: Router,
private settingsService: SettingsService) {
this.route.data.subscribe((data: { clientActionData: any }) => {
this.withdrawalData = data.clientActionData.narrations;
});
@@ -65,8 +68,8 @@ export class WithdrawClientComponent 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 prevWithdrawalDate: Date = this.withdrawClientForm.value.withdrawalDate;
this.withdrawClientForm.patchValue({
withdrawalDate: this.datePipe.transform(prevWithdrawalDate, dateFormat),