diff --git a/peer-prep-fe/src/app/login/login.component.scss b/peer-prep-fe/src/app/login/login.component.css similarity index 75% rename from peer-prep-fe/src/app/login/login.component.scss rename to peer-prep-fe/src/app/login/login.component.css index 13a083e82c..75e6547eb4 100644 --- a/peer-prep-fe/src/app/login/login.component.scss +++ b/peer-prep-fe/src/app/login/login.component.css @@ -67,6 +67,9 @@ input.ng-valid.ng-touched { border-radius: 0.5rem; cursor: pointer; font-family: "Signika", sans-serif; + display: flex; + justify-content: center; + align-items: center; } .submit:hover { @@ -91,3 +94,28 @@ button:disabled { background-color: grey; cursor: not-allowed; } + +button:disabled:hover { + background-color: grey; + cursor: not-allowed; +} + +.spinner { + display: flex; + border: 3px solid #ffffff; + border-top: 3px solid rgb(255, 78, 196); + border-radius: 50%; + width: 30px; + height: 30px; + flex-direction: space-around; + animation: spin 1s linear infinite; +} + +@keyframes spin { + 0% { + transform: rotate(0deg); + } + 100% { + transform: rotate(360deg); + } +} \ No newline at end of file diff --git a/peer-prep-fe/src/app/login/login.component.html b/peer-prep-fe/src/app/login/login.component.html index 657b7039db..863e33c0dd 100644 --- a/peer-prep-fe/src/app/login/login.component.html +++ b/peer-prep-fe/src/app/login/login.component.html @@ -2,14 +2,6 @@

Login

- - -
Login class="submit" type="submit" (click)="loginAccount()" - [disabled]="loginForm.invalid"> - Login + [disabled]="loginForm.invalid || isLoading"> + + + + + Login + -
-
diff --git a/peer-prep-fe/src/app/login/login.component.ts b/peer-prep-fe/src/app/login/login.component.ts index dc19e75324..19759baf7b 100644 --- a/peer-prep-fe/src/app/login/login.component.ts +++ b/peer-prep-fe/src/app/login/login.component.ts @@ -27,6 +27,9 @@ const MODULES: any[] = [ styleUrl: "./login.component.scss" }) export class LoginComponent { + + isLoading = false; + constructor( private router: Router, private authService: authService @@ -44,12 +47,13 @@ export class LoginComponent { return window.location.hostname !== "localhost" } - loginAccount() { + async loginAccount() { + this.isLoading = true let apiUrl: string = this.isProduction() ? `${baseUrlProduction}/auth/login` : "http://localhost:3001/auth/login" if (this.loginForm.invalid) { } - + fetch(apiUrl, { method: "POST", headers: { @@ -70,8 +74,8 @@ export class LoginComponent { // return response.json(); // Parse the JSON from the response }) .then((data) => { + this.isLoading = false; this.authService.login(data) - //this.router.navigate(["/landing"]) // Redirect to homepage when succesfully created account console.log(data) // Handle the response data }) .catch((error) => {