Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Task/improve type safety in user detail dialog component (#7292)

Kenrick Tandriancb692f8d06f7
diff --git a/apps/client/src/app/components/user-detail-dialog/user-detail-dialog.component.ts b/apps/client/src/app/components/user-detail-dialog/user-detail-dialog.component.ts
index 73e09f612c..637fe8c31a 100644
--- a/apps/client/src/app/components/user-detail-dialog/user-detail-dialog.component.ts
+++ b/apps/client/src/app/components/user-detail-dialog/user-detail-dialog.component.ts
@@ -9,7 +9,7 @@ import {
Component,
CUSTOM_ELEMENTS_SCHEMA,
DestroyRef,
- Inject,
+ inject,
OnInit
} from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
@@ -49,28 +49,30 @@ import {
templateUrl: './user-detail-dialog.html'
})
export class GfUserDetailDialogComponent implements OnInit {
- public baseCurrency: string;
- public readonly getCountryName = getCountryName;
- public subscriptionsDataSource = new MatTableDataSource<Subscription>();
- public subscriptionsDisplayedColumns = [
+ protected baseCurrency: string;
+ protected readonly getCountryName = getCountryName;
+ protected readonly subscriptionsDataSource =
+ new MatTableDataSource<Subscription>();
+ protected readonly subscriptionsDisplayedColumns = [
'createdAt',
'type',
'price',
'expiresAt'
];
- public user: AdminUserResponse;
-
- public constructor(
- private adminService: AdminService,
- private changeDetectorRef: ChangeDetectorRef,
- @Inject(MAT_DIALOG_DATA) public data: UserDetailDialogParams,
- private dataService: DataService,
- private destroyRef: DestroyRef,
- public dialogRef: MatDialogRef<
- GfUserDetailDialogComponent,
- UserDetailDialogResult
- >
- ) {
+ protected user: AdminUserResponse;
+
+ protected readonly data = inject<UserDetailDialogParams>(MAT_DIALOG_DATA);
+
+ private readonly adminService = inject(AdminService);
+ private readonly changeDetectorRef = inject(ChangeDetectorRef);
+ private readonly dataService = inject(DataService);
+ private readonly destroyRef = inject(DestroyRef);
+ private readonly dialogRef =
+ inject<MatDialogRef<GfUserDetailDialogComponent, UserDetailDialogResult>>(
+ MatDialogRef
+ );
+
+ public constructor() {
this.baseCurrency = this.dataService.fetchInfo().baseCurrency;
addIcons({
@@ -98,14 +100,14 @@ export class GfUserDetailDialogComponent implements OnInit {
});
}
- public deleteUser() {
+ protected deleteUser() {
this.dialogRef.close({
action: 'delete',
userId: this.data.userId
});
}
- public getSum() {
+ protected getSum() {
return getSum(
this.subscriptionsDataSource.data
.filter(({ price }) => {
@@ -117,7 +119,7 @@ export class GfUserDetailDialogComponent implements OnInit {
).toNumber();
}
- public getType({ createdAt, expiresAt, price }: Subscription) {
+ protected getType({ createdAt, expiresAt, price }: Subscription) {
if (price) {
return $localize`Paid`;
}
@@ -127,7 +129,7 @@ export class GfUserDetailDialogComponent implements OnInit {
: $localize`Coupon`;
}
- public onClose() {
+ protected onClose() {
this.dialogRef.close();
}
}