fix(dashboard): report localStorage cache + delete account flow#23
Merged
Conversation
…api/auth/delete-account
…ut/delete, hydration fix
…logout-button.tsx
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Closes two UX gaps found after Week 4 merge: AI reports were lost on page reload (no persistence), and there was no way for a user to delete their account. Adds per-user localStorage caching for reports with auto-load on range switch, and a 2-step animated delete account flow with a new DELETE endpoint.
Changes
Code
app/dashboard/reports/report-form.tsx— localStorage cache per range; lazyuseStateinit loads last result on mount; range/date event handlers check cache (nouseEffectfor state — required by lint);createdAtbadge added toResultPanel;NEW REPORTbutton removed (range switch replaces it)app/dashboard/reports/page.tsx— passesuserEmailtoReportFormfor cache key scopingapp/api/auth/delete-account/route.ts—DELETEendpoint; verifies auth, callsprisma.user.delete(cascades to Sessions → Events/Tracks, UserSetting), clears session cookieapp/dashboard/account-menu.tsx— replacesLogoutButton; 2-step modal (account options → delete confirmation); spring animation identical toApiKeyModal; Escape key, error display,clearReportCacheon both logout and delete,typeof documentSSR guard forcreatePortalapp/dashboard/app-header.tsx— swaps<LogoutButton />for<AccountMenu userEmail={email} />app/dashboard/logout-button.tsx— deleted (dead code)Tooling / config
n/a
Docs / plan
n/a — fix branch, no formal plan file required
Design decisions
useEffectfor cache reads — project lint rule (react-hooks/set-state-in-effect) forbidssetStateinside effects; lazyuseStateinit handles the initial load, range/dateonChangehandlers cover subsequent changeswt:report:${email}:${range}prevents cross-account bleed when switching Google accounts on the same browserclearReportCacheon both logout and delete — on logout the cache keys remain valid (same email next login sees own data), but clearing on logout is explicit hygiene; on delete it removes orphaned keystypeof document !== "undefined"guard —"use client"components still run on the server in Next.js App Router;document.bodyas acreatePortalargument is evaluated before React sees it, so a short-circuit guard is required;mountedstate would also work but is blocked by the same lint ruleVerification
npx tsc --noEmit(dashboard) — cleannpm run lint(dashboard) — cleannpm run typecheck(extension) — cleanOut of scope (future PRs)
Closes