This was generated by AI during triage.
Split from #27 (item 6 of 6).
Problem
FestivalSelection renders content and then redirects via useEffect when there is exactly one festival, causing a flash before redirect. The subdomain-redirect logic is also duplicated between the effect (handleFestivalClick) and FestivalCard.handleClick.
Verified:
src/pages/FestivalSelection.tsx:37-41 — useEffect calls handleFestivalClick when availableFestivals.length === 1 (note: handleFestivalClick not in deps)
src/pages/FestivalSelection.tsx:26-35 / 104-112 — duplicated subdomain logic
src/routes/index.tsx — route has no beforeLoad/loader.
Fix
Move the single-festival redirect into the route beforeLoad (fetch festivals via ensureQueryData, throw redirect when exactly one). Keep FestivalCard.handleClick for user-initiated clicks. Remove the useEffect from FestivalSelection.tsx.
⚠️ Subdomain caveat: the effect currently redirects to a subdomain URL (createFestivalSubdomainUrl) via window.location.href when on the main domain, and only uses the in-app path off-main. A router throw redirect can only do in-app navigation, not a cross-origin subdomain jump. Decide how the single-festival case should behave on the main domain — if a subdomain redirect is required there, that part can't move into beforeLoad and should stay a window.location redirect (ideally hoisted out of render). Confirm before implementing.
Related
Part of the router-loader adoption tracked in #53 (Effort 2).
Acceptance
- Single festival: redirect happens with no visible flash of the selection grid (subdomain behavior preserved per the decision above).
- 0 or 2+ festivals: selection grid renders as before.
Files
src/routes/index.tsx
src/pages/FestivalSelection.tsx
Split from #27 (item 6 of 6).
Problem
FestivalSelectionrenders content and then redirects viauseEffectwhen there is exactly one festival, causing a flash before redirect. The subdomain-redirect logic is also duplicated between the effect (handleFestivalClick) andFestivalCard.handleClick.Verified:
src/pages/FestivalSelection.tsx:37-41—useEffectcallshandleFestivalClickwhenavailableFestivals.length === 1(note:handleFestivalClicknot in deps)src/pages/FestivalSelection.tsx:26-35/104-112— duplicated subdomain logicsrc/routes/index.tsx— route has nobeforeLoad/loader.Fix
Move the single-festival redirect into the route
beforeLoad(fetch festivals viaensureQueryData,throw redirectwhen exactly one). KeepFestivalCard.handleClickfor user-initiated clicks. Remove theuseEffectfromFestivalSelection.tsx.createFestivalSubdomainUrl) viawindow.location.hrefwhen on the main domain, and only uses the in-app path off-main. A routerthrow redirectcan only do in-app navigation, not a cross-origin subdomain jump. Decide how the single-festival case should behave on the main domain — if a subdomain redirect is required there, that part can't move intobeforeLoadand should stay awindow.locationredirect (ideally hoisted out of render). Confirm before implementing.Related
Part of the router-loader adoption tracked in #53 (Effort 2).
Acceptance
Files
src/routes/index.tsxsrc/pages/FestivalSelection.tsx