refactor: store selected week in a cookie, not the URL
Build and Deploy / Build & Push (push) Successful in 1m7s

The home page no longer reads ?week=YYYY-MM-DD from the URL. Selected week
lives in the tcWeek cookie, set via a server action that revalidates the
home page so the next render reflects it. The URL stays at "/" regardless
of which week the user is viewing.

WeekNav prev/next/today buttons (and the arrow-key bindings) call the
server action directly — no router.refresh dance, no client-side cookie
write. BackToCalendarLink drops its localStorage-based href reconstruction
and just links to "/" since the cookie already remembers the right week
across navigations.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-30 08:39:20 -04:00
parent 44d079efb9
commit 6447db3008
8 changed files with 56 additions and 32 deletions
+7 -1
View File
@@ -420,12 +420,18 @@ park/[id]/page.tsx (Server)
2. **Opening-time refresh**: For each park open today, calculates milliseconds until its opening time using `msUntilLocalTime()` (timezone-aware). Schedules `router.refresh()` at opening and again 30 seconds later (to pick up ride counts after Queue-Times starts reporting).
3. **Keyboard navigation**: Left/right arrow keys navigate between weeks (via `WeekNav` component).
### Cookies
| Name | Purpose |
|------|---------|
| `tcWeek` | Selected week start date (`YYYY-MM-DD`). Set by `WeekNav` and read server-side by `app/page.tsx`, so the home page renders the right week without polluting the URL. |
### localStorage
| Key | Purpose |
|-----|---------|
| `lastWeek` | Remembers the last viewed week start date, used by `BackToCalendarLink` to return to the correct week |
| `coasterMode` | Persists the "Coasters only" toggle state across sessions |
| `fastLaneMode` | Persists the Fast Lane wait toggle on the park page |
### Responsive Design