Skip to content

Commit 9fcc3b0

Browse files
committed
Disable button and say 'sent!' when we've resent the email
1 parent 8fa1396 commit 9fcc3b0

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

app/components/email-input.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ export default Component.extend({
2626
}),
2727
isError: false,
2828
emailError: '',
29-
resendButtonText: computed('user.email_verification_sent', function() {
30-
if (this.get('user.email_verification_sent')) {
29+
disableResend: false,
30+
resendButtonText: computed('disableResend', 'user.email_verification_sent', function() {
31+
if (this.get('disableResend')) {
32+
return 'Sent!';
33+
} else if (this.get('user.email_verification_sent')) {
3134
return 'Resend';
3235
} else {
3336
return 'Send verification email';
@@ -81,6 +84,7 @@ export default Component.extend({
8184

8285
this.set('isEditing', false);
8386
this.set('notValidEmail', false);
87+
this.set('disableResend', false);
8488
},
8589

8690
cancelEdit() {
@@ -93,15 +97,17 @@ export default Component.extend({
9397

9498
this.get('ajax').raw(`/api/v1/users/${user.id}/resend`, {
9599
method: 'PUT'
96-
}).catch((error) => {
97-
if (error.payload) {
98-
this.set('isError', true);
99-
this.set('emailError', `Error in resending message: ${error.payload.errors[0].detail}`);
100-
} else {
101-
this.set('isError', true);
102-
this.set('emailError', 'Unknown error in resending message');
103-
}
104-
});
100+
})
101+
.then(() => this.set('disableResend', true))
102+
.catch((error) => {
103+
if (error.payload) {
104+
this.set('isError', true);
105+
this.set('emailError', `Error in resending message: ${error.payload.errors[0].detail}`);
106+
} else {
107+
this.set('isError', true);
108+
this.set('emailError', 'Unknown error in resending message');
109+
}
110+
});
105111
}
106112
}
107113
});

app/templates/components/email-input.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<p class='small-text'>Your email has not yet been verified.</p>
5151
</div>
5252
<div class='actions'>
53-
<button class='small yellow-button space-left' {{action 'resendEmail'}}>{{resendButtonText}}</button>
53+
<button class='small yellow-button space-left' {{action 'resendEmail'}} disabled={{disableResend}}>{{resendButtonText}}</button>
5454
</div>
5555
</div>
5656
{{/if}}

0 commit comments

Comments
 (0)