feat: add back to dashboard link on public profile#314
Conversation
|
@Mash4-4-4-4 is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Thanks for your first PR on DevTrack! 🎉
A maintainer will review it within 48 hours. While you wait:
- Make sure CI is passing (type-check + lint)
- Double-check the PR description is filled out and the issue is linked
- Feel free to ask questions in Discussions if you need help
Priyanshu-byte-coder
left a comment
There was a problem hiding this comment.
Component logic is right (only show link when viewer = owner) but wrong session field used for comparison:
// ❌ session.user.name is the GitHub display name ('John Doe'), not the login
const isOwner = currentUser === username; // where currentUser = session?.user?.name
// ✅ githubLogin is the actual GitHub username used in the URL
import { useSession } from 'next-auth/react';
const { data: session } = useSession();
const isOwner = session?.githubLogin === username;If the user's display name differs from their login (e.g. name='Priyanshu Doshi', login='Priyanshu-byte-coder'), the back button never shows. One-line fix.
|
One bug to fix — the ownership check uses the wrong session field: // Replace:
const currentUser = session?.user?.name;
// With:
const currentUser = session?.githubLogin;
Fix and push — everything else looks good. |
Summary
Added a conditional “← Back to dashboard” link on public profile pages for profile owners.
Closes #211
Type of Change
Changes Made
BackToDashboardclient componentuseSession()to detect the logged-in user[username]route paramHow to Test
Steps for the reviewer to verify this works:
/u/[your-username]/dashboardScreenshots (if UI change)
Checklist
npm run lintpasses locallynpm run type-check)