-
Notifications
You must be signed in to change notification settings - Fork 0
guest flow for scheduler + usePlanPersistence hook #421
Description
Problem
The scheduler currently requires login to use. Every plan is saved to the DB and identified by a planId in the URL. This means users who aren't signed in can't use the scheduler at all, which is a barrier to entry — ideally a user should be able to explore the scheduler and generate schedules before committing to creating an account.
Additionally, all plan state currently flows through the DB. There's no clean separation between "persisting a plan" and "managing filter state", which makes the codebase harder to extend and causes prop drilling throughout the component tree.
Solution
Introduce a guest flow where the URL is the source of truth instead of the DB, and extract plan persistence logic into a usePlanPersistence hook that abstracts over both flows. Components should be unaware of which flow is active.
- Logged in — plan loads from DB on mount, changes autosave to DB, URL always reflects current state
- Guest — all state lives in URL params, no DB writes, refresh restores state from URL
In both flows, the URL should always be kept in sync with the current state by the hook. The URL is the single source of truth for what the user sees — the DB is just a persistence layer that mirrors it for logged in users.
Deliverables
usePlanPersistencehook owning plan loading, autosave, and guest vs logged in decision- Guest flow working end to end including login transition
generator/page.tsxandAddCoursesModalupdated to handle both URL schemas
Notes
usePlanPersistencecould possibly depend on creating auseSchedulerFiltershook forfiltersandsetFilters. IfuseSchedulerFiltershas not yet been extracted fromSchedulerWrapper, that work should be done as part of this ticket first. (Ofc only if deemed to be needed).- A minimal
SchedulerContextprovidingplanIdandisGuestis acceptable if prop drilling becomes painful during implementation. Full context is a separate future ticket.