Browse Source

Task/improve type safety in user account registration dialog component (#7301)

* fix(client): resolve type errors

* feat(client): enforce encapsulation

* feat(client): replace constructor based DI with inject functions

* feat(client): implement viewChild signal
pull/7303/head
Kenrick Tandrian 3 days ago
committed by GitHub
parent
commit
9cea437b2c
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 40
      apps/client/src/app/pages/register/user-account-registration-dialog/user-account-registration-dialog.component.ts

40
apps/client/src/app/pages/register/user-account-registration-dialog/user-account-registration-dialog.component.ts

@ -9,8 +9,8 @@ import {
Component,
CUSTOM_ELEMENTS_SCHEMA,
DestroyRef,
Inject,
ViewChild
inject,
viewChild
} from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
@ -53,26 +53,28 @@ import { UserAccountRegistrationDialogParams } from './interfaces/interfaces';
templateUrl: 'user-account-registration-dialog.html'
})
export class GfUserAccountRegistrationDialogComponent {
@ViewChild(MatStepper) stepper!: MatStepper;
protected readonly stepper = viewChild.required(MatStepper);
public accessToken: string;
public authToken: string;
public isCreateAccountButtonDisabled = true;
public isDisclaimerChecked = false;
public role: string;
public routerLinkAboutTermsOfService =
protected accessToken: string | undefined;
protected authToken: string;
protected isCreateAccountButtonDisabled = true;
protected isDisclaimerChecked = false;
protected role: string;
protected readonly routerLinkAboutTermsOfService =
publicRoutes.about.subRoutes.termsOfService.routerLink;
public constructor(
private changeDetectorRef: ChangeDetectorRef,
@Inject(MAT_DIALOG_DATA) public data: UserAccountRegistrationDialogParams,
private dataService: DataService,
private destroyRef: DestroyRef
) {
protected readonly data =
inject<UserAccountRegistrationDialogParams>(MAT_DIALOG_DATA);
private readonly changeDetectorRef = inject(ChangeDetectorRef);
private readonly dataService = inject(DataService);
private readonly destroyRef = inject(DestroyRef);
public constructor() {
addIcons({ arrowForwardOutline, checkmarkOutline, copyOutline });
}
public createAccount() {
protected createAccount() {
this.dataService
.postUser()
.pipe(takeUntilDestroyed(this.destroyRef))
@ -81,17 +83,17 @@ export class GfUserAccountRegistrationDialogComponent {
this.authToken = authToken;
this.role = role;
this.stepper.next();
this.stepper().next();
this.changeDetectorRef.markForCheck();
});
}
public enableCreateAccountButton() {
protected enableCreateAccountButton() {
this.isCreateAccountButtonDisabled = false;
}
public onChangeDislaimerChecked() {
protected onChangeDislaimerChecked() {
this.isDisclaimerChecked = !this.isDisclaimerChecked;
}
}

Loading…
Cancel
Save