From f6d0491ca5fcd4da9f78211f2385b47f348bc384 Mon Sep 17 00:00:00 2001 From: "diana.dolgolyova" Date: Tue, 24 Mar 2026 18:00:29 +0300 Subject: [PATCH] fix: auto-set reminder 'coming' only for today/tomorrow confirmations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/lib/db.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 = ?"