diff --git a/apps/client/src/app/pages/accounts/accounts-page.component.ts b/apps/client/src/app/pages/accounts/accounts-page.component.ts index 8ff389404..d0a78567b 100644 --- a/apps/client/src/app/pages/accounts/accounts-page.component.ts +++ b/apps/client/src/app/pages/accounts/accounts-page.component.ts @@ -25,7 +25,7 @@ import { MatDialog } from '@angular/material/dialog'; import { ActivatedRoute, Router, RouterModule } from '@angular/router'; import { Account as AccountModel } from '@prisma/client'; import { DeviceDetectorService } from 'ngx-device-detector'; -import { EMPTY, Subscription } from 'rxjs'; +import { EMPTY } from 'rxjs'; import { catchError } from 'rxjs/operators'; import { GfCreateOrUpdateAccountDialogComponent } from './create-or-update-account-dialog/create-or-update-account-dialog.component'; @@ -41,16 +41,16 @@ import { GfTransferBalanceDialogComponent } from './transfer-balance/transfer-ba templateUrl: './accounts-page.html' }) export class GfAccountsPageComponent implements OnInit { - public accounts: AccountModel[]; - public activitiesCount = 0; - public deviceType: string; - public hasImpersonationId: boolean; - public hasPermissionToCreateAccount: boolean; - public hasPermissionToUpdateAccount: boolean; - public routeQueryParams: Subscription; - public totalBalanceInBaseCurrency = 0; - public totalValueInBaseCurrency = 0; - public user: User; + protected accounts: AccountModel[]; + protected activitiesCount = 0; + protected hasImpersonationId: boolean; + protected hasPermissionToCreateAccount: boolean; + protected hasPermissionToUpdateAccount: boolean; + protected totalBalanceInBaseCurrency = 0; + protected totalValueInBaseCurrency = 0; + protected user: User; + + private deviceType: string; public constructor( private changeDetectorRef: ChangeDetectorRef, @@ -124,32 +124,7 @@ export class GfAccountsPageComponent implements OnInit { this.fetchAccounts(); } - public fetchAccounts() { - this.dataService - .fetchAccounts() - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe( - ({ - accounts, - activitiesCount, - totalBalanceInBaseCurrency, - totalValueInBaseCurrency - }) => { - this.accounts = accounts; - this.activitiesCount = activitiesCount; - this.totalBalanceInBaseCurrency = totalBalanceInBaseCurrency; - this.totalValueInBaseCurrency = totalValueInBaseCurrency; - - if (this.accounts?.length <= 0) { - this.router.navigate([], { queryParams: { createDialog: true } }); - } - - this.changeDetectorRef.markForCheck(); - } - ); - } - - public onDeleteAccount(aId: string) { + protected onDeleteAccount(aId: string) { this.reset(); this.dataService @@ -165,19 +140,44 @@ export class GfAccountsPageComponent implements OnInit { }); } - public onTransferBalance() { + protected onTransferBalance() { this.router.navigate([], { queryParams: { transferBalanceDialog: true } }); } - public onUpdateAccount(aAccount: AccountModel) { + protected onUpdateAccount(aAccount: AccountModel) { this.router.navigate([], { queryParams: { accountId: aAccount.id, editDialog: true } }); } - public openUpdateAccountDialog({ + private fetchAccounts() { + this.dataService + .fetchAccounts() + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe( + ({ + accounts, + activitiesCount, + totalBalanceInBaseCurrency, + totalValueInBaseCurrency + }) => { + this.accounts = accounts; + this.activitiesCount = activitiesCount; + this.totalBalanceInBaseCurrency = totalBalanceInBaseCurrency; + this.totalValueInBaseCurrency = totalValueInBaseCurrency; + + if (this.accounts?.length <= 0) { + this.router.navigate([], { queryParams: { createDialog: true } }); + } + + this.changeDetectorRef.markForCheck(); + } + ); + } + + private openUpdateAccountDialog({ balance, comment, currency,