Browse Source

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

Improve type safety
pull/7294/head
Kenrick Tandrian 4 days ago
committed by GitHub
parent
commit
cb692f8d06
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 46
      apps/client/src/app/components/user-detail-dialog/user-detail-dialog.component.ts

46
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();
}
}

Loading…
Cancel
Save