Stu Mason
Stu Mason

Activity

StuMason/cleanconnect
TidyLinker.com
TypeScript
Pull Request Merged

PR #162 merged: feat: same-day bookings

Summary

Lets a client book a cleaner for today when the cleaner has opted in and is available. Implements the plan in scratch/plans/plan-same-day-bookings.md.

  • New cleaner_profiles.accepts_same_day boolean (default off) plus an availableToday() scope that filters opted-in cleaners with a recurring slot for today's day-of-week
  • DirectBookingRequest now allows preferred_date = today, enforces a 1-hour lead-time, and rejects same-day bookings against cleaners who haven't opted in (per-field friendly errors, not the generic after rule)
  • ?available_today=1 on /cleaners filters the search results; the new checkbox in FilterPanel keeps URL state in sync and counts as an active filter
  • Cleaners can opt in during onboarding step 4 (rates) and toggle the flag from /cleaner/profile (new ToggleAcceptsSameDay action and route)
  • The booking dialog now allows today as the earliest date for opted-in cleaners (was hard-floored at tomorrow)
  • Cleaner request notification flags same-day urgency in subject + in-app heading
  • New bookings:close-lapsed-same-day scheduled command (every 5 minutes) cancels pending same-day jobs whose 1-hour cutoff has passed and emails the client a DirectBookingLapsedNotification pointing back at /cleaners?available_today=1

Deviations from the plan

  • The plan suggested putting the opt-in toggle on onboarding step 5; step 5 in this codebase is a no-form completion screen, so the toggle lives on step 4 alongside the other rate/preference inputs. The data is persisted via the existing SaveCleanerRates action.
  • Tests for the new request validation live under tests/Feature/DirectBooking/ (matches existing convention) rather than tests/Feature/Client/ as the plan suggested.

Deferred (open questions §10 in the plan)

  1. Reposting/"ending soon" surfacing to other cleaners — out of scope, needs its own design pass.
  2. Per-cleaner same-day notification volume cap — deferring until real volume gives us data; flagged for pre-launch.
  3. Did NOT auto-flip existing cleaners with today-availability to accepts_same_day = true. Default off; cleaners must actively opt in. Defer until Stu confirms otherwise.
  4. Auto-close cadence kept at every 5 minutes (acceptable lag is up to ~5min after the 1h window crosses).

Test plan

  • tests/Feature/DirectBooking/SameDayBookingTest.php — 5 tests covering the opt-in gate, lead-time gate, past-date rejection, and future-booking regression
  • tests/Feature/CleanerSearch/AvailableTodayFilterTest.php — 3 tests for the filter (opt-in + slot, missing slot, omitting filter)
  • tests/Feature/Cleaner/Onboarding/AcceptsSameDayOptInTest.php — 3 tests for step-4 opt-in and the profile-settings toggle
  • tests/Feature/Console/CloseLapsedSameDayBookingsTest.php — 4 tests covering the close + notify path, untouched far-future and outside-window jobs, and untouched in-progress jobs
  • Existing tests/Feature/Cleaner/SearchTest.php (17), all of tests/Feature/DirectBooking/ (37), and existing onboarding tests pass with no regressions
+853
additions
-27
deletions
27
files changed