email reminders

This commit is contained in:
2026-05-03 09:43:10 -04:00
parent 815d4e0bdd
commit 6023fe5214
13 changed files with 616 additions and 2 deletions

View File

@@ -14,6 +14,7 @@
import type { PrismaClient } from "@/generated/prisma/client";
import { stripe } from "@/lib/stripe";
import { sendBookingConfirmation } from "@/lib/email";
import { scheduleReminderForBooking } from "@/lib/reminders";
/**
* Create a Stripe PaymentIntent for the booking's deposit and persist its id.
@@ -177,10 +178,19 @@ export async function recordPaymentFailed(
return { bookingId: booking.id };
}
/** Convenience used by the webhook to send the confirmation email after payment. */
/** Convenience used by the webhook after a payment succeeds and the booking
* transitions to CONFIRMED — sends the confirmation email and schedules the
* 24h reminder.
*/
export async function confirmAfterPayment(
db: PrismaClient,
bookingId: string,
): Promise<void> {
const booking = await db.booking.findUnique({
where: { id: bookingId },
select: { startsAt: true },
});
if (!booking) return;
await sendBookingConfirmation({ db, bookingId });
await scheduleReminderForBooking(bookingId, booking.startsAt);
}