Skip to content

Commit

Permalink
Show loading state on verify button (#21)
Browse files Browse the repository at this point in the history
* Show loading state on verify button

* Update
  • Loading branch information
datlechin authored Dec 10, 2023
1 parent 8ac4518 commit 275458e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion js/src/forum/components/TwoFactorEnableModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default class TwoFactorEnableModal extends Modal {
this.token = Stream('');
this.code = null;
this.activeTab = 'qrcode';
this.loading = false;
}

className() {
Expand Down Expand Up @@ -108,7 +109,11 @@ export default class TwoFactorEnableModal extends Modal {
/>
</div>
<div className="Form-group">
<Button type="submit" className="Button Button--primary" onclick={this.verifyToken.bind(this)}>
<Button
type="submit"
className="Button Button--primary" onclick={this.verifyToken.bind(this)}
loading={this.loading}
>
{app.translator.trans('ianm-twofactor.forum.security.verify_button')}
</Button>
</div>
Expand Down Expand Up @@ -153,6 +158,8 @@ export default class TwoFactorEnableModal extends Modal {
}

verifyToken() {
this.loading = true;

app
.request({
method: 'POST',
Expand All @@ -170,6 +177,9 @@ export default class TwoFactorEnableModal extends Modal {
.catch((error) => {
//alert('Verification failed. Please try again.');
//error.alert.content = 'Verification failed. Please try again.';
})
.finally(() => {
this.loading = false;
});
}

Expand Down

0 comments on commit 275458e

Please sign in to comment.