diff --git a/src/lib/db.ts b/src/lib/db.ts index e745fd6..0fa3700 100644 --- a/src/lib/db.ts +++ b/src/lib/db.ts @@ -726,9 +726,13 @@ export function setGroupBookingStatus( ): void { const db = getDb(); if (status === "confirmed" && confirmation) { + // Auto-set reminder to 'coming' only if confirmed for today/tomorrow + const today = new Date().toISOString().split("T")[0]; + const tomorrow = new Date(Date.now() + 86400000).toISOString().split("T")[0]; + const reminderStatus = (confirmation.date === today || confirmation.date === tomorrow) ? "coming" : null; db.prepare( - "UPDATE group_bookings SET status = ?, confirmed_date = ?, confirmed_group = ?, confirmed_comment = ?, notified_confirm = 1, reminder_status = 'coming' WHERE id = ?" - ).run(status, confirmation.date, confirmation.group, confirmation.comment || null, id); + "UPDATE group_bookings SET status = ?, confirmed_date = ?, confirmed_group = ?, confirmed_comment = ?, notified_confirm = 1, reminder_status = ? WHERE id = ?" + ).run(status, confirmation.date, confirmation.group, confirmation.comment || null, reminderStatus, id); } else { db.prepare( "UPDATE group_bookings SET status = ?, confirmed_date = NULL, confirmed_group = NULL, confirmed_comment = NULL, notified_confirm = 1 WHERE id = ?"