Simplify registration flow: mandatory signup redirect, payment emails, payment reminder cron

- EventRegistrationForm/WatcherForm/PerformerForm: remove session/login nudge/SuccessScreen;
  both roles redirect to /login?signup=1&email=<email>&next=/account after submit
- SuccessScreen.tsx deleted (no longer used)
- account.tsx: add 'Betaal nu' CTA via checkoutMutation (shown when watcher + paymentStatus pending)
- DB schema: add paymentReminderSentAt column to registration table
- Migration: 0008_payment_reminder_sent_at.sql
- email.ts: update registrationConfirmationHtml / sendConfirmationEmail with signupUrl param;
  add sendPaymentReminderEmail and sendPaymentConfirmationEmail functions
- routers/index.ts: wire payment reminder into runSendReminders() — queries watchers
  with paymentStatus pending, paymentReminderSentAt IS NULL, createdAt <= now-3days
- mollie.ts webhook: call sendPaymentConfirmationEmail after marking registration paid
This commit is contained in:
2026-03-11 11:08:03 +01:00
parent e59a588a9d
commit 17c6315dad
10 changed files with 399 additions and 523 deletions

View File

@@ -10,6 +10,7 @@ import { z } from "zod";
import {
sendCancellationEmail,
sendConfirmationEmail,
sendPaymentReminderEmail,
sendReminderEmail,
sendUpdateEmail,
} from "../email";
@@ -975,5 +976,40 @@ export async function runSendReminders(): Promise<{
}
}
// Payment reminders: watchers with pending payment older than 3 days
const threeDaysAgo = now - 3 * 24 * 60 * 60 * 1000;
const unpaidWatchers = await db
.select()
.from(registration)
.where(
and(
eq(registration.registrationType, "watcher"),
eq(registration.paymentStatus, "pending"),
isNull(registration.paymentReminderSentAt),
lte(registration.createdAt, new Date(threeDaysAgo)),
),
);
for (const reg of unpaidWatchers) {
if (!reg.managementToken) continue;
try {
await sendPaymentReminderEmail({
to: reg.email,
firstName: reg.firstName,
managementToken: reg.managementToken,
drinkCardValue: reg.drinkCardValue ?? undefined,
giftAmount: reg.giftAmount ?? undefined,
});
await db
.update(registration)
.set({ paymentReminderSentAt: new Date() })
.where(eq(registration.id, reg.id));
sent++;
} catch (err) {
errors.push(`payment-reminder ${reg.email}: ${String(err)}`);
console.error(`Failed to send payment reminder to ${reg.email}:`, err);
}
}
return { sent, skipped: false, errors };
}