disable register btn on click

This commit is contained in:
Chneemann 2024-05-30 13:09:07 +02:00
parent 5aaf762481
commit 8dbf568d79
3 changed files with 20 additions and 7 deletions

View file

@ -45,14 +45,22 @@
<div class="ownAvatarContainer">
<div>{{ "chooseAvatar.ownAvatar" | translate }}</div>
<div>
<button class="BtnUpload" (click)="fileInput.click()">
<button
class="BtnUpload"
(click)="fileInput.click()"
[disabled]="loginService.isBtnDisabled"
>
{{ "chooseAvatar.avatarBtn" | translate }}
</button>
</div>
</div>
<div class="avatarBottom">
<button class="hoverBtn" (click)="loginService.register()">
<button
class="aktivButton"
(click)="loginService.register()"
[disabled]="loginService.isBtnDisabled"
>
{{ "chooseAvatar.Btn" | translate }}
</button>
</div>

View file

@ -76,6 +76,9 @@ section {
background-color: #444df2;
color: #ffff;
}
&:disabled {
@include buttonGrey;
}
}
.avatarBottom {
@ -89,9 +92,10 @@ button {
@include buttonGrey;
cursor: pointer;
}
.hoverBtn {
&:hover {
background-color: #676eec;
.aktivButton {
@include aktivButtonBlue;
&:disabled {
@include buttonGrey;
}
}
@media (max-width: 570px) {

View file

@ -64,6 +64,7 @@ export class loginService {
let currentUser = this.userService.getCurrentUserId();
if (currentUser !== null) {
this.router.navigate([`/main`]);
this.isBtnDisabled = false;
}
}
@ -88,7 +89,6 @@ export class loginService {
.catch((error) => {
console.error('Error when retrieving the user document:', error);
});
this.isBtnDisabled = false;
})
.catch((error) => {
const errorCode = error.code;
@ -154,7 +154,6 @@ export class loginService {
this.getUserIdInLocalStorage(userId);
this.email = '';
this.password = '';
this.isBtnDisabled = false;
})
.catch((error) => {
console.error(error);
@ -171,6 +170,7 @@ export class loginService {
* Registers a new user with Firebase authentication and stores user data in Firestore.
*/
register() {
this.isBtnDisabled = true;
const auth = getAuth();
createUserWithEmailAndPassword(auth, this.email, this.password)
.then((userCredential) => {
@ -190,6 +190,7 @@ export class loginService {
.catch((error) => {
console.error(error);
this.deleteUserFormData();
this.isBtnDisabled = false;
});
}