fix: account link in dashboard user drop down#18
fix: account link in dashboard user drop down#18pax2678 wants to merge 5 commits intomichaelshimeles:mainfrom
Conversation
…dated in Polar. Select the latest subscription when querying subscription based on userId.
…. priceId is not updated after a user changes the subscription creating confusion. Changes Summary: Checkout Creation (lines 52-54): - REMOVED: priceId: productPriceId, from the metadata object - RESULT: Metadata now only contains userId when creating Polar checkouts Impact: - Polar subscriptions: Will only store userId in metadata (no priceId) - Convex subscriptions: Will only store userId in metadata (no priceId) - Price tracking: Still works via the polarPriceId field in the subscription record - User linking: Preserved via userId in metadata for webhook processing
Changes Made:
- Removed duplicate Settings link from sidebar
navigation
- Eliminated redundant Settings entry in navSecondary
array in app-sidebar.tsx
- Fixed Settings link in user dropdown navigation
- Added proper routing to Settings dropdown item in
nav-user.tsx
- Settings link now navigates to /dashboard/settings
when clicked
- Used asChild pattern with React Router Link for
proper navigation
Result:
- Eliminates confusing duplicate Settings links in
dashboard
- Provides single, functional Settings access through
user dropdown
- Improves user experience with cleaner navigation
structure
The "Account" link in the dashboard user dropdown will use Clerk's openUserProfile() function, which is exactly the same mechanism that the homepage "Manage account" link uses through the UserButton component. Summary of Changes: Updated app/components/dashboard/nav-user.tsx: 1. Added openUserProfile import from useClerk hook 2. Added click handler to Account dropdown item that calls openUserProfile() Result: - ✅ Dashboard Account link now opens Clerk's UserProfile modal (same as homepage "Manage account") - ✅ Consistent behavior between homepage and dashboard user account access - ✅ Uses Clerk's native functionality rather than custom routing Now when users click "Account" in the dashboard user dropdown, it will open the same Clerk Account Profile page that appears when clicking "Manage account" from the homepage user button dropdown.
|
@pax2678 is attempting to deploy a commit to the Goshen Labs Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughRemoves the Settings item from the dashboard’s secondary navigation. Updates the user menu: Account opens the Clerk profile; Settings links to /dashboard/settings via a router Link. Adjusts subscription logic to fetch the latest subscription with descending order and augments webhook handling to store polarPriceId; removes priceId from checkout metadata. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant UI as Dashboard UI
participant Clerk as Clerk SDK
participant Router as App Router
participant Svc as Subscriptions Service
participant DB as Subscriptions DB
participant WH as Webhook Handler
rect rgb(237,245,255)
note over UI: User dropdown interactions
User->>UI: Open user menu
UI->>Clerk: Account clicked -> openUserProfile()
UI->>Router: Settings clicked -> navigate /dashboard/settings
end
rect rgb(240,255,240)
note over Svc,DB: Subscription lookup (latest)
UI->>Svc: checkUserSubscriptionStatus(userId)
Svc->>DB: query subscriptions for userId<br/>order desc, take first
DB-->>Svc: latest subscription
Svc-->>UI: status/result
end
rect rgb(255,250,235)
note over WH,DB: Webhook update
alt subscription.updated
WH->>DB: patch subscription with polarPriceId = event.price_id
else other events
WH->>WH: handle as before
end
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
app/components/dashboard/nav-user.tsx (1)
85-89: Prefer onSelect over onClick for menu item activationRadix-based menus fire
onSelectfor both mouse and keyboard. This improves a11y and avoids edge cases with focus management.- <DropdownMenuItem onClick={() => openUserProfile()}> + <DropdownMenuItem onSelect={() => openUserProfile()}> <IconUserCircle /> Account </DropdownMenuItem>convex/subscriptions.ts (2)
237-238: Repeat: fix comment and validate ordering on this querySame clarification as above; ensure the intended “latest subscription” is returned.
- .order("desc") // Order by createdAt in descending order + .order("desc") // Order by _creationTime in descending order (latest first)
265-266: Repeat: fix comment and confirm latest-first behaviorAlign the comment and double-check index capabilities here as well.
- .order("desc") // Order by createdAt in descending order + .order("desc") // Order by _creationTime in descending order (latest first)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
app/components/dashboard/app-sidebar.tsx(1 hunks)app/components/dashboard/nav-user.tsx(3 hunks)convex/subscriptions.ts(5 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
app/components/dashboard/app-sidebar.tsx (2)
app/components/dashboard/nav-secondary.tsx (2)
NavSecondary(15-58)item(31-53)app/routes/dashboard/settings.tsx (1)
Page(4-16)
convex/subscriptions.ts (1)
app/routes/pricing.tsx (1)
priceId(57-97)
app/components/dashboard/nav-user.tsx (3)
app/components/ui/dropdown-menu.tsx (1)
DropdownMenuItem(248-248)app/routes/dashboard/settings.tsx (1)
Page(4-16)app/components/homepage/navbar.tsx (1)
loaderData(16-174)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: cubic · AI code reviewer
🔇 Additional comments (5)
app/components/dashboard/app-sidebar.tsx (1)
29-29: Settings removed from sidebar — confirm discoverability and product intentWith
navSecondarynow empty, Settings is only reachable from the user menu. If that’s intentional, we're good; otherwise consider keeping a secondary entry or adding a tooltip/inline hint. Also verify no docs/screens reference the old sidebar Settings link.app/components/dashboard/nav-user.tsx (3)
35-35: Good switch to Clerk’s openUserProfileUsing
openUserProfilealigns with Clerk best practices and the PR goal. No issues.
89-95: Settings link composition looks good
DropdownMenuItem asChild + Linkis the right pattern; route consistency with/dashboard/settingsis maintained.
35-35: Scope note: PR includes non-menu changesThis PR also modifies sidebar nav (removing Settings) and Convex subscription queries/webhook patching. If feasible, split UI nav changes and billing/backend changes into separate PRs for easier review and rollback.
convex/subscriptions.ts (1)
333-345: Persisting polarPriceId on update — looks correctUpdating
polarPriceIdonsubscription.updatedaligns the record with Polar’s current price linkage. No issues spotted.
| .order("desc") // Order by createdAt in descending order | ||
| .first(); |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Ordering semantics: clarify and confirm index support
.order("desc") on a Convex query orders by the index’s natural order (commonly _creationTime), not a createdAt field. The inline comment is misleading; also confirm the subscriptions table/index supports ordering with this query shape to avoid runtime errors.
- .order("desc") // Order by createdAt in descending order
+ .order("desc") // Order by _creationTime in descending order (latest first)Optionally verify schema/indexes with the script below.
🏁 Script executed:
#!/bin/bash
# Show subscriptions table indexes
rg -n -C3 'defineTable\(|\.index\(' convex | rg -n -C3 'subscriptions|userId|polarId|by_token'
# Locate schema definitions
fd -a schema -t f convex | xargs -I{} rg -n -C4 'subscriptions|index\(' {}Length of output: 1952
Clarify ordering semantics on subscriptions query
File: convex/subscriptions.ts (lines 200–201)
- .order("desc") // Order by createdAt in descending order
+ .order("desc") // Order by _creationTime in descending order (latest first)The subscriptions table doesn’t define a createdAt field; .order() defaults to the internal _creationTime index.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| .order("desc") // Order by createdAt in descending order | |
| .first(); | |
| .order("desc") // Order by _creationTime in descending order (latest first) | |
| .first(); |
🤖 Prompt for AI Agents
In convex/subscriptions.ts around lines 200–201, the call .order("desc") is
misleading because there is no createdAt field on the subscriptions table and
Convex will use the internal _creationTime by default; explicitly specify the
index by replacing the ambiguous ordering with .order("_creationTime", "desc")
and update the inline comment to state that ordering is by the internal
_creationTime (or alternatively add a createdAt column to the subscriptions
schema and order by that if you prefer a public timestamp).
The "Account" link in the dashboard user dropdown will use Clerk's openUserProfile() function, which is exactly the same mechanism that the homepage "Manage account" link uses through the UserButton component.
Summary of Changes:
Updated app/components/dashboard/nav-user.tsx:
Added openUserProfile import from useClerk hook
Added click handler to Account dropdown item that calls openUserProfile()
Result:
✅ Dashboard Account link now opens Clerk's UserProfile modal (same as homepage "Manage account")
✅ Consistent behavior between homepage and dashboard user account access
✅ Uses Clerk's native functionality rather than custom routing
Now when users click "Account" in the dashboard user dropdown, it will open the same Clerk Account Profile page that appears when clicking "Manage account" from the homepage user button dropdown.
Summary by cubic
Aligns the dashboard Account link with the homepage by opening Clerk’s UserProfile modal. Also cleans up Settings navigation and fixes subscription metadata/retrieval for accurate pricing.
Summary by CodeRabbit
New Features
Bug Fixes
Chores