fix: auto-set reminder 'coming' only for today/tomorrow confirmations

Confirming a booking for today or tomorrow auto-sets reminder_status
to 'coming'. Confirming for later dates leaves it unset — admin will
need to check closer to the event.
This commit is contained in:
2026-03-24 18:00:29 +03:00
parent a959c22a4c
commit f6d0491ca5

View File

@@ -726,9 +726,13 @@ export function setGroupBookingStatus(
): void { ): void {
const db = getDb(); const db = getDb();
if (status === "confirmed" && confirmation) { 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( db.prepare(
"UPDATE group_bookings SET status = ?, confirmed_date = ?, confirmed_group = ?, confirmed_comment = ?, notified_confirm = 1, reminder_status = 'coming' WHERE 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, id); ).run(status, confirmation.date, confirmation.group, confirmation.comment || null, reminderStatus, id);
} else { } else {
db.prepare( db.prepare(
"UPDATE group_bookings SET status = ?, confirmed_date = NULL, confirmed_group = NULL, confirmed_comment = NULL, notified_confirm = 1 WHERE id = ?" "UPDATE group_bookings SET status = ?, confirmed_date = NULL, confirmed_group = NULL, confirmed_comment = NULL, notified_confirm = 1 WHERE id = ?"