Confirmation Mode
By default, bookings are auto-confirmed. Confirmation mode lets providers review and approve each booking before it goes on the schedule.
How it works
Section titled “How it works”- Customer submits a booking request
- Booking is created with status
pending - Provider receives a notification to review
- Provider confirms or rejects the booking
- If no action is taken, the booking is auto-rejected after a configurable deadline
import { getInitialBookingStatus, getAutoRejectDeadline, isPendingBookingOverdue, CONFIRMATION_TIMEOUT_HOURS,} from "@thebookingkit/core";
// Determine initial status based on event type configconst status = getInitialBookingStatus(eventType.requiresConfirmation);// Returns "pending" or "confirmed"
// Calculate auto-reject deadlineconst deadline = getAutoRejectDeadline(booking.createdAt);// Returns a Date 24 hours after creation (default)
// Check if a pending booking has exceeded its deadlineconst overdue = isPendingBookingOverdue(booking.createdAt);// Returns true if past the deadlineAuto-reject
Section titled “Auto-reject”The default timeout is 24 hours (CONFIRMATION_TIMEOUT_HOURS = 24). A background job should run periodically to reject overdue bookings:
// In your job handler (Inngest, BullMQ, etc.)const overdueBookings = await findOverduePendingBookings();
for (const booking of overdueBookings) { if (isPendingBookingOverdue(booking.createdAt)) { await updateBookingStatus(booking.id, "rejected"); await sendRejectionEmail(booking); }}Enabling confirmation mode
Section titled “Enabling confirmation mode”Set requiresConfirmation: true on the event type:
await db.update(eventTypes).set({ requiresConfirmation: true,}).where(eq(eventTypes.id, eventTypeId));