From f9dc91228bc05e0638896cb18f9ca7993494905e Mon Sep 17 00:00:00 2001 From: rr-bw <102181210+rr-bw@users.noreply.github.com> Date: Wed, 11 Sep 2024 16:47:43 -0700 Subject: [PATCH] refactor to use a uiState enum for UI states --- libs/auth/src/angular/login/login.component.html | 11 ++--------- libs/auth/src/angular/login/login.component.ts | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/libs/auth/src/angular/login/login.component.html b/libs/auth/src/angular/login/login.component.html index 7f63afd8d0..8effb5147e 100644 --- a/libs/auth/src/angular/login/login.component.html +++ b/libs/auth/src/angular/login/login.component.html @@ -42,11 +42,7 @@ [bitSubmit]="submit" [formGroup]="formGroup" > - - - +
@@ -105,16 +101,13 @@

- -
+
diff --git a/libs/auth/src/angular/login/login.component.ts b/libs/auth/src/angular/login/login.component.ts index f037d55956..4a68001ce9 100644 --- a/libs/auth/src/angular/login/login.component.ts +++ b/libs/auth/src/angular/login/login.component.ts @@ -1,6 +1,6 @@ import { CommonModule } from "@angular/common"; import { Component, ElementRef, Input, NgZone, OnDestroy, OnInit, ViewChild } from "@angular/core"; -import { FormBuilder, ReactiveFormsModule, Validators } from "@angular/forms"; +import { FormBuilder, FormControl, ReactiveFormsModule, Validators } from "@angular/forms"; import { ActivatedRoute, Router, RouterModule } from "@angular/router"; import { first, firstValueFrom, of, Subject, switchMap, take, takeUntil } from "rxjs"; @@ -43,6 +43,11 @@ import { LoginService } from "./login.service"; const BroadcasterSubscriptionId = "LoginComponent"; +export enum LoginUiState { + EMAIL_ENTRY = "EmailEntry", + MASTER_PASSWORD_ENTRY = "MasterPasswordEntry", +} + @Component({ standalone: true, templateUrl: "./login.component.html", @@ -68,6 +73,7 @@ export class LoginComponentV2 implements OnInit, OnDestroy { captchaToken: string = null; clientType: ClientType; ClientType = ClientType; + LoginUiState = LoginUiState; registerRoute$ = this.registerRouteService.registerRoute$(); // TODO: remove when email verification flag is removed showLoginWithDevice = false; validatedEmail = false; @@ -81,14 +87,18 @@ export class LoginComponentV2 implements OnInit, OnDestroy { rememberEmail: [false], }); - get emailFormControl() { + get emailFormControl(): FormControl { return this.formGroup.controls.email; } - get loggedEmail() { + get loggedEmail(): string { return this.formGroup.value.email; } + get uiState(): LoginUiState { + return this.validatedEmail ? LoginUiState.MASTER_PASSWORD_ENTRY : LoginUiState.EMAIL_ENTRY; + } + // Web properties enforcedPasswordPolicyOptions: MasterPasswordPolicyOptions; policies: Policy[];