Skip to content

feat: add back to dashboard link on public profile#314

Open
Mash4-4-4-4 wants to merge 4 commits into
Priyanshu-byte-coder:mainfrom
Mash4-4-4-4:fix-back-to-dashboard-link
Open

feat: add back to dashboard link on public profile#314
Mash4-4-4-4 wants to merge 4 commits into
Priyanshu-byte-coder:mainfrom
Mash4-4-4-4:fix-back-to-dashboard-link

Conversation

@Mash4-4-4-4
Copy link
Copy Markdown

Summary

Added a conditional “← Back to dashboard” link on public profile pages for profile owners.

Closes #211

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor / code cleanup

Changes Made

  • Created a BackToDashboard client component
  • Used useSession() to detect the logged-in user
  • Compared session username with the [username] route param
  • Rendered the dashboard navigation link only when the viewer is the profile owner
  • Added muted foreground hover styling matching the existing UI theme

How to Test

Steps for the reviewer to verify this works:

  1. Log into the application
  2. Open your own public profile route: /u/[your-username]
  3. Verify that the “← Back to dashboard” link appears at the top
  4. Click the link and confirm it navigates to /dashboard
  5. Open another user's public profile
  6. Verify that the link does not appear

Screenshots (if UI change)

Screenshot 2026-05-18 122211

Checklist

  • Linked issue in summary
  • npm run lint passes locally
  • No TypeScript errors (npm run type-check)
  • Self-reviewed the diff
  • Added/updated tests if applicable

@vercel
Copy link
Copy Markdown

vercel Bot commented May 18, 2026

@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.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Owner

@Priyanshu-byte-coder Priyanshu-byte-coder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Priyanshu-byte-coder
Copy link
Copy Markdown
Owner

One bug to fix — the ownership check uses the wrong session field:

// Replace:
const currentUser = session?.user?.name;
// With:
const currentUser = session?.githubLogin;

session.user.name is the display name (e.g. "John Doe"), not the GitHub login (e.g. "johndoe"). The public profile URL uses the GitHub login, so the comparison will always fail.

Fix and push — everything else looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[GOOD FIRST ISSUE] Add 'Back to dashboard' breadcrumb on public profile page

2 participants