feat: unify walk-in and call-in reservation flows with 15min TTL, guest booking support, and slot awareness
- backend/handlers/bookings/admin_reserve.go:
- Add explicit reservation_type field ("walkin" | "callin") to request struct
- Remove TTL-based heuristic for type detection
- Walk-in: uses duration_minutes, allows null user_id, 1min past grace
- Call-in: requires service_ids, validates future time, calculates duration from services
- Both types now use 15-minute TTL
- backend/handlers/scheduling/time-blockers.go:
- Update CleanupOldReservations: both walkin and callin use 15min TTL (was 10min/60min)
- frontend/WalkInBooking.svelte:
- Full rewrite of reservation logic
- If available now and >15min remaining: reserve from now to slot end
- If <=15min or not available: reserve next full slot
- Always reserves before opening modal (never open without hold)
- Passes reservedDuration to modal
- TTL changed from 5 to 15 minutes
- frontend/WalkInCreateModal.svelte:
- Replace dead commented-out guest code with working guest creation
- Guest account created at submit time (not earlier)
- Phone defaults to +447700900000 if blank
- Phone field marked optional with helper text
- Name split into firstName/lastName for backend
- Validation relaxed: only name required for guests
- frontend/BookingCreateModal.svelte:
- TTL changed from 60 to 15 minutes
- Add reservation_type: "callin" to reserve payload
- Guest creation uses correct firstName/lastName fields
- Default guest phone to +447700900000
- Reservation no longer requires selectedUserId (works for guests)
- docs: Update Future Work backlog to mark completed items
This commit is contained in:
@@ -337,19 +337,20 @@ func CheckTimeBlockerOverlap(ctx context.Context, startTime, endTime time.Time)
|
||||
// CleanupOldReservations deletes expired reservations:
|
||||
// - Logged-in (RESERVATION:user): older than 1 hour
|
||||
// - Anonymous (RESERVATION:anon): older than 10 minutes
|
||||
// - Admin walk-in (RESERVATION:admin:walkin:%): older than 10 minutes
|
||||
// - Admin call-in (RESERVATION:admin:callin:%): older than 1 hour
|
||||
// - Admin walk-in (RESERVATION:admin:walkin:%): older than 15 minutes
|
||||
// - Admin call-in (RESERVATION:admin:callin:%): older than 15 minutes
|
||||
func CleanupOldReservations(ctx context.Context) error {
|
||||
oneHourAgo := time.Now().Add(-1 * time.Hour)
|
||||
tenMinutesAgo := time.Now().Add(-10 * time.Minute)
|
||||
fifteenMinutesAgo := time.Now().Add(-15 * time.Minute)
|
||||
|
||||
_, err := db.DB.Exec(ctx, `
|
||||
DELETE FROM time_blockers
|
||||
WHERE (description LIKE 'RESERVATION:user:%' AND created_at < $1)
|
||||
OR (description LIKE 'RESERVATION:anon:%' AND created_at < $2)
|
||||
OR (description LIKE 'RESERVATION:admin:walkin:%' AND created_at < $2)
|
||||
OR (description LIKE 'RESERVATION:admin:walkin:%' AND created_at < $3)
|
||||
OR (description LIKE 'RESERVATION:admin:callin:%' AND created_at < $3)
|
||||
`, oneHourAgo, tenMinutesAgo, oneHourAgo)
|
||||
`, oneHourAgo, tenMinutesAgo, fifteenMinutesAgo)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user