buttons cannot be clicked multiple times

This commit is contained in:
Chneemann 2024-08-30 10:59:39 +02:00
parent da1a1b1516
commit 06928fe245
9 changed files with 32 additions and 8 deletions

View file

@ -39,7 +39,10 @@
[imgPath]="'play'"
[imgPath]="'arrow_right'"
[imgReverse]="true"
[disabled]="!isUserEmailValid(authData.mail) && authData.mail.length > 0"
[disabled]="
(!isUserEmailValid(authData.mail) && authData.mail.length > 0) ||
authData.send
"
></app-btn-large>
</form>
</section>

View file

@ -16,6 +16,7 @@ import { AuthService } from '../../services/auth.service';
export class AuthComponent {
authData = {
mail: '',
send: false,
};
constructor(
@ -42,11 +43,13 @@ export class AuthComponent {
email: this.authData.mail,
};
try {
this.authData.send = true;
await this.authService.checkAuthUserMail(body);
const queryParams = { mail: this.authData.mail };
this.router.navigate(['/register'], { queryParams });
this.errorService.clearError();
} catch (error) {
this.authData.send = false;
this.errorService.handleError(error);
}
}

View file

@ -38,7 +38,7 @@
</div>
<app-btn-large
[value]="'Send Email'"
[disabled]="!isUserEmailValid(authData.mail)"
[disabled]="!isUserEmailValid(authData.mail) || authData.send"
></app-btn-large>
</form>
} @else { @if (sendMailSuccess) {
@ -132,7 +132,8 @@
!isUserEmailValid(authData.mail) ||
authData.password !== authData.passwordConfirm ||
!authData.password ||
!authData.passwordConfirm
!authData.passwordConfirm ||
authData.send
"
></app-btn-large>
</form>

View file

@ -19,6 +19,7 @@ export class ForgotPasswordComponent implements OnInit {
token: '',
password: '',
passwordConfirm: '',
send: false,
};
sendMailSuccess: boolean = false;
@ -70,10 +71,12 @@ export class ForgotPasswordComponent implements OnInit {
email: this.authData.mail,
};
try {
this.authData.send = true;
await this.authService.forgotPassword(body);
this.sendMailSuccess = true;
this.errorService.clearError();
} catch (error) {
this.authData.send = false;
this.sendMailSuccess = false;
this.errorService.handleError(error);
}
@ -85,14 +88,14 @@ export class ForgotPasswordComponent implements OnInit {
token: this.authData.token,
new_password: this.authData.password,
};
console.log(body);
try {
this.authData.send = true;
await this.authService.changePassword(body);
this.queryEmail = false;
this.queryEmailSuccess = true;
this.errorService.clearError();
} catch (error) {
this.authData.send = false;
this.errorService.handleError(error);
}
}

View file

@ -83,13 +83,16 @@
!authData.mail ||
(!isUserEmailValid(authData.mail) && authData.mail.length > 0) ||
!password.valid ||
authData.guestLogin
authData.guestLogin ||
authData.send
"
></app-btn-large>
<app-btn-large
[value]="'Guest Log in'"
[disabled]="
authData.guestLogin || (!!authData.mail && !!authData.password)
authData.guestLogin ||
(!!authData.mail && !!authData.password) ||
authData.send
"
(click)="guestLogin()"
></app-btn-large>

View file

@ -45,6 +45,7 @@ export class LoginComponent {
password: environment.guestPassword,
};
try {
this.authData.send = true;
await this.authService.login(body, this.authData.checkbox);
this.authData.mail = '';
this.authData.password = '';
@ -52,6 +53,7 @@ export class LoginComponent {
this.router.navigate(['/browse/']);
this.errorService.clearError();
} catch (error) {
this.authData.send = false;
this.errorService.handleError(error);
}
}
@ -63,11 +65,13 @@ export class LoginComponent {
password: this.authData.password,
};
try {
this.authData.send = true;
await this.authService.login(body, this.authData.checkbox);
ngForm.resetForm();
this.router.navigate(['/browse/']);
this.errorService.clearError();
} catch (error) {
this.authData.send = false;
this.errorService.handleError(error);
}
}

View file

@ -123,7 +123,8 @@
authData.password !== authData.passwordConfirm ||
!authData.password ||
!authData.passwordConfirm ||
!authData.privacyPolicy
!authData.privacyPolicy ||
authData.send
"
></app-btn-large>
</form>

View file

@ -19,6 +19,7 @@ export class RegisterComponent implements OnInit {
password: '',
passwordConfirm: '',
privacyPolicy: false,
send: false,
};
registrationSuccess: boolean = false;
@ -49,11 +50,13 @@ export class RegisterComponent implements OnInit {
password: this.authData.password,
};
try {
this.authData.send = true;
await this.authService.register(body);
ngForm.resetForm();
this.registrationSuccess = true;
this.errorService.clearError();
} catch (error) {
this.authData.send = false;
this.errorService.handleError(error);
}
}

View file

@ -18,6 +18,7 @@ export class VerifyEmailComponent {
authData = {
mail: '',
token: '',
send: false,
};
constructor(
@ -40,10 +41,12 @@ export class VerifyEmailComponent {
token: this.authData.token,
};
try {
this.authData.send = true;
await this.authService.verifyEmail(body);
this.verified = true;
this.errorService.clearError();
} catch (error) {
this.authData.send = false;
this.verified = false;
this.errorService.handleError(error);
}