preventing users from double click on submit

This commit is contained in:
Beverly Nguyen
2025-03-13 15:04:12 -07:00
parent ff65471084
commit 821265cf6e
7 changed files with 32 additions and 14 deletions

View File

@@ -682,4 +682,4 @@ def slugify(text):
"""
Converts text to lowercase, replaces spaces with hyphens, and removes invalid characters.
"""
return re.sub(r'[^a-z0-9-]', '', re.sub(r'\s+', '-', text.lower()))
return re.sub(r"[^a-z0-9-]", "", re.sub(r"\s+", "-", text.lower()))

View File

@@ -13,7 +13,8 @@
} else {
$submitButton.data('clicked', 'true');
setTimeout(renableSubmitButton($submitButton), 1500);
$submitButton.prop('disabled', true);
setTimeout(renableSubmitButton($submitButton), 10000);
}
@@ -22,7 +23,7 @@
let renableSubmitButton = $submitButton => () => {
$submitButton.data('clicked', '');
$submitButton.prop('disabled', false);
};
$('form').on('submit', disableSubmitButtons);

View File

@@ -924,6 +924,10 @@ def get_template_error_dict(exception):
def preview_notification(service_id, template_id):
recipient = get_recipient()
if not recipient:
current_app.logger.warning(
f"No recipient found for service {service_id}, template {template_id}. Redirecting..."
)
return redirect(
url_for(
".send_one_off",

View File

@@ -77,13 +77,16 @@
help='3' if help else 0
)}}" class='page-footer'>
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<!-- <p>Placeholder: This message will be delivered to <b>400 phone numbers</b> and will use a total of <b>800 message parts</b>, leaving Washington DSHS with <b>249,200 message parts remaining</b>.</p> -->
<h3>Does everything look good?</h3>
{% if not error %}
{% set button_text %}
{{ "Schedule" if scheduled_for else 'Send'}}
{% endset %}
{{ usaButton({ "text": button_text }) }}
{{ usaButton({
"text": button_text,
"type": submit,
"preventDoubleClick": True,
}) }}
{% endif %}
</form>
</div>