Add loading spinner to buttons during Stripe redirect

This commit is contained in:
Ian Gulliver
2026-01-17 08:32:00 -07:00
parent 5ddb6f75bc
commit 577960835b
2 changed files with 15 additions and 2 deletions

View File

@@ -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;
}
});

View File

@@ -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);
}