Stu Mason
Stu Mason

Activity

StuMason/cleanconnect
TidyLinker.com
TypeScript
Pull Request Opened

PR #165 opened: fix: booking dialog crash from stale `tomorrow` reference

Summary

A ReferenceError: tomorrow is not defined was crashing the cleaner profile page for logged-in clients — caught on dev via Sentry today (2026-05-20).

Root cause: PR #162 (same-day bookings) renamed the booking dialog's earliest-bookable date from tomorrowearliestDate. PR #161 (multi-day range bookings) heavily reworked the same file and added isRangeDateDisabled. Both landed within seconds of each other this morning, and three references to the old tomorrow name survived the merge:

  • isRangeDateDisabled's useCallback body — return d < tomorrow
  • its dependency array — [tomorrow]
  • the single-day picker's defaultMonth={tomorrow}

The dependency array [tomorrow] is evaluated on every render of BookingDialog, which mounts on the cleaner profile page — so the page threw on render for any authenticated client.

Neither #161 nor #162 was individually wrong; the broken state only existed in merged main.

Fix

All three references now point at earliestDate, the correct earliest bookable date (it already accounts for the cleaner's same-day opt-in). One-line-each rename, no behaviour change beyond un-crashing the page.

Tests

The existing DirectBookingFlowTest already asserts no JS errors on the profile page + single-day dialog as an authed client — those would have failed on the bad merge and pass now. Added one test covering the multi-day path specifically (the isRangeDateDisabled callback is where the stale reference lived): open the dialog → switch to "Multiple days" → range picker renders with no JS errors.

Test plan

  • CI: lint, Unit & Feature Tests, Browser Tests green
  • On dev after merge: log in as a client, open a cleaner profile, click Request Booking, switch to Multiple days — no crash, range picker works
  • Confirm the Sentry issue stops recurring
+18
additions
-3
deletions
2
files changed