Speed up payment/refund processing on the supervisor dashboard
Reconciling a Yoco payment and sending payment links blocked the HTTP response on ticket-PDF generation and email/WhatsApp sends; they now run in the background like the other payment flows already did. Registration/payment option loops (pricing, stock checks, ticket generation) now resolve concurrently instead of sequentially. The Payments page dropped a per-registration N+1 fetch and now refreshes its lists in parallel after each action. Added missing indexes for dashboard stats and donation-leg lookups, and made GET /api/registrations optionally paginated. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1057,20 +1057,22 @@ const sendPaymentLink = async (req, res) => {
|
||||
const { user, event } = registration;
|
||||
const message = `Hi ${user.name || ''}, here's your payment link for ${event?.title || 'your registration'}: ${redirectUrl}`;
|
||||
|
||||
// Validation is synchronous (fast, no network); the actual send is backgrounded since
|
||||
// SMTP/WAWP round trips shouldn't block this request.
|
||||
if (channel === 'email') {
|
||||
if (!user.email) { res.status(400); throw new Error('This user has no email address on file'); }
|
||||
const { sendMail } = require('../utils/email');
|
||||
await sendMail({
|
||||
sendMail({
|
||||
to: user.email,
|
||||
subject: `Payment link — ${event?.title || 'Registration'}`,
|
||||
text: message,
|
||||
html: `<p>Hi ${user.name || ''},</p><p>Here's your payment link for <strong>${event?.title || 'your registration'}</strong>:</p><p><a href="${redirectUrl}">${redirectUrl}</a></p>`
|
||||
});
|
||||
}).catch(e => console.error('Failed to send payment link email:', e));
|
||||
} else {
|
||||
const { isValidZAPhone } = require('../utils/whatsapp');
|
||||
if (!isValidZAPhone(user.phoneNumber)) { res.status(400); throw new Error('This user has no valid WhatsApp number on file'); }
|
||||
const { waTextAny } = require('../utils/notify');
|
||||
await waTextAny(user, message);
|
||||
waTextAny(user, message).catch(e => console.error('Failed to send payment link via WhatsApp:', e));
|
||||
}
|
||||
|
||||
return res.status(200).json({ sent: true, channel });
|
||||
|
||||
Reference in New Issue
Block a user