wire up NavUser component to actual user data, get rid of hardcoded data - #3
wire up NavUser component to actual user data, get rid of hardcoded data#3timothymalcham wants to merge 4 commits into
Conversation
WalkthroughNavUser was refactored from a prop-driven component to a session/profile-driven component. AppSidebar no longer passes a hard-coded user object and now invokes NavUser without arguments. NavUser derives name, email, avatar, and initials from authClient.useSession() and an API getCurrentUserProfile query, renders a loading skeleton while session or profile data loads, and uses computed values for Avatar, AvatarFallback, and displayed text. The exported signature changed from `NavUser({ user })` to `NavUser()`. 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@apps/web/src/components/nav-user.tsx`:
- Around line 25-43: NavUser currently computes fallback name/email/initials
immediately which causes a flash of placeholders while authClient.useSession()
and useQuery(api.r2.getCurrentUserProfile) are loading; update NavUser to detect
loading (e.g., session.isLoading and profile.isLoading or equivalent flags from
authClient.useSession and useQuery) and either return null or render a small
skeleton component until the essential data (session.data or profile) is
available, and avoid computing derived values like name, email, avatar, and
initials until after loading completes.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@apps/web/src/components/nav-user.tsx`:
- Around line 50-55: The current sessionUser/email/name/avatar resolution uses
nullish coalescing (??) which preserves empty strings and can leave blank UI or
an <img src="">; update the logic in the
sessionUser/email/nameFromEmail/name/avatar/initials resolution to normalize
empty strings as missing (use || or explicit checks) so email and name fall back
when values are "" and avatar becomes undefined when empty, and ensure initials
generation uses the normalized name/email values.
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/web/src/components/nav-user.tsx (1)
65-80:⚠️ Potential issue | 🟡 MinorConsider adding error handling for sign-out failures.
If
authClient.signOutrejects, the error is silently ignored and the user receives no feedback. While sign-out failures are uncommon, adding basic error handling would improve UX.🛡️ Suggested fix with error handling
const handleSignOut = async () => { + try { await authClient.signOut({ fetchOptions: { onSuccess: () => { // The expectAuth: true setting only has affect before the initial authentication. // If a user signs out and signs back in, authenticated queries will likely be called // before authentication is ready, resulting in an error. // // For this reason, the current recommendation is to reload the page on sign out. // For apps that redirect based on authentication, signing out is typically all that's // needed as an unauth redirect will occur after reload. location.reload() }, }, }) + } catch (error) { + console.error("Sign out failed:", error) + // Optionally show a toast notification to the user + } }
No description provided.