diff --git a/static/give/afac26.html b/static/give/afac26.html index b91039a..d5edd37 100644 --- a/static/give/afac26.html +++ b/static/give/afac26.html @@ -174,7 +174,8 @@ selectedDonation = 'custom'; }); - document.getElementById('donate-btn').addEventListener('click', async () => { + const donateBtn = document.getElementById('donate-btn'); + donateBtn.addEventListener('click', async () => { let donationCents = 0; if (selectedDonation === 'custom') { donationCents = (parseInt(document.getElementById('custom-amount').value) || 0) * 100; @@ -187,9 +188,14 @@ return; } + donateBtn.loading = true; + donateBtn.disabled = true; const data = await api('POST', `/api/donate/${eventId}`, { donationCents }); if (data.url) { location.href = data.url; + } else { + donateBtn.loading = false; + donateBtn.disabled = false; } }); diff --git a/static/rsvp/afac26.html b/static/rsvp/afac26.html index 1a54b5c..e71c858 100644 --- a/static/rsvp/afac26.html +++ b/static/rsvp/afac26.html @@ -291,7 +291,8 @@ } } - document.getElementById('rsvp-btn').addEventListener('click', async () => { + const rsvpBtn = document.getElementById('rsvp-btn'); + rsvpBtn.addEventListener('click', async () => { let donationCents = 0; if (selectedDonation === 'custom') { donationCents = (parseInt(document.getElementById('custom-amount').value) || 0) * 100; @@ -299,10 +300,16 @@ donationCents = selectedDonation * 100; } + if (donationCents > 0) { + rsvpBtn.loading = true; + rsvpBtn.disabled = true; + } const data = await api('POST', `/api/rsvp/${eventId}`, { numPeople: selectedNumPeople, donationCents }); if (data.url) { location.href = data.url; } else { + rsvpBtn.loading = false; + rsvpBtn.disabled = false; updateUI(data); showConfirmation(data.numPeople, null); }