From 21841fd969d5f09203b743760f0d9fec4b1cdf4e Mon Sep 17 00:00:00 2001 From: creme332 <65414576+creme332@users.noreply.github.com> Date: Wed, 22 May 2024 13:44:44 +0400 Subject: [PATCH] show loading animation on checkout button after form submission --- public/js_original/cart-view.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/public/js_original/cart-view.js b/public/js_original/cart-view.js index dc5cca23..c530d71c 100644 --- a/public/js_original/cart-view.js +++ b/public/js_original/cart-view.js @@ -50,6 +50,9 @@ function updateCart(e) { } async function checkout() { + // set loading animation on checkout button to prevent multiple form submissions + document.querySelector("#checkout-btn").setAttribute("aria-busy", "true"); + const myCart = Cart(); const items = myCart.getItems(); @@ -63,6 +66,9 @@ async function checkout() { body: JSON.stringify(data), }); + // stop loading animation + document.querySelector("#checkout-btn").setAttribute("aria-busy", "false"); + if (response.ok) { // Clear cart items from localStorage if checkout is successful myCart.clear();