Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Show "Sending..." state immediately after clicking the send but… #7065

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions application/src/main/resources/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,21 @@ const Toast = (function () {
};
})();

function sendVerificationCode(button, sendRequest) {
function sendVerificationCode(button, sendRequest,sentButtonName,sendingButtonName) {
let timer;
const countdown = 60;

button.addEventListener("click", () => {
button.disabled = true;
button.textContent = sendingButtonName;
sendRequest()
.then(() => {
startCountdown();
Toast.success(i18nResources.sendVerificationCodeSuccess);
})
.catch((e) => {
button.disabled = false;
button.textContent = sentButtonName;
if (e instanceof Error) {
Toast.error(e.message);
} else {
Expand All @@ -119,7 +121,7 @@ function sendVerificationCode(button, sendRequest) {
remainingTime--;
} else {
clearInterval(timer);
button.textContent = "Send";
button.textContent = sentButtonName;
button.disabled = false;
button.classList.remove("disabled");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@
}

const emailCodeSendButton = document.getElementById("emailCodeSendButton");
sendVerificationCode(emailCodeSendButton, sendRequest);
const sendingButtonName = /*[[#{form.emailCode.sending}]]*/ "";
const sentButtonName = /*[[#{form.emailCode.sendButton}]]*/ "";
sendVerificationCode(emailCodeSendButton, sendRequest,sentButtonName,sendingButtonName);
});
</script>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ form.displayName.label=名称
form.email.label=电子邮箱
form.emailCode.label=邮箱验证码
form.emailCode.sendButton=发送
form.emailCode.sending=发送中
form.emailCode.send.emptyValidation=请先输入邮箱地址
form.password.label=密码
form.confirmPassword.label=确认密码
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ form.displayName.label=Display Name
form.email.label=Email
form.emailCode.label=Email Verification Code
form.emailCode.sendButton=Send
form.emailCode.sending=Sending
form.emailCode.send.emptyValidation=Please enter your email address first
form.password.label=Password
form.confirmPassword.label=Confirm Password
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ form.displayName.label=Nombre
form.email.label=Correo Electrónico
form.emailCode.label=Código de Verificación
form.emailCode.sendButton=Enviar
form.emailCode.sending=Enviando
form.emailCode.send.emptyValidation=Por favor, introduce tu dirección de correo electrónico primero
form.password.label=Contraseña
form.confirmPassword.label=Confirmar Contraseña
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ form.displayName.label=名稱
form.email.label=電子郵件
form.emailCode.label=郵箱驗證碼
form.emailCode.sendButton=發送
form.emailCode.sending=發送中
form.emailCode.send.emptyValidation=請先輸入電子郵件地址
form.password.label=密碼
form.confirmPassword.label=確認密碼
Expand Down