From 465abe682023089291452e284887a3f10ea626d1 Mon Sep 17 00:00:00 2001 From: Maniska Date: Mon, 18 May 2026 12:18:09 +0530 Subject: [PATCH 1/3] feat: add back to dashboard link on public profile --- src/app/u/[username]/page.tsx | 60 ++++++++++++++++-------------- src/components/BackToDashboard.tsx | 27 ++++++++++++++ 2 files changed, 59 insertions(+), 28 deletions(-) create mode 100644 src/components/BackToDashboard.tsx diff --git a/src/app/u/[username]/page.tsx b/src/app/u/[username]/page.tsx index b7dff3a..d48dcdd 100644 --- a/src/app/u/[username]/page.tsx +++ b/src/app/u/[username]/page.tsx @@ -3,7 +3,7 @@ import BadgeSection from "@/components/BadgeSection"; import ContributionGraph from "@/components/ContributionGraph"; import StreakTracker from "@/components/StreakTracker"; import TopRepos from "@/components/TopRepos"; - +import BackToDashboard from "@/components/BackToDashboard"; interface PublicProfileData { username: string; userId: string; @@ -86,38 +86,42 @@ export default async function PublicProfilePage({ const { username } = params; const profile = await fetchPublicProfile(username); - if (!profile) { - return ( -
-
-

- Profile Not Found -

-

- This profile is not available or is private. -

- - Back to Home - -
+if (!profile) { + return ( +
+
+

+ Profile Not Found +

+

+ This profile is not available or is private. +

+ + Back to Home +
- ); - } +
+ ); +} return (
{/* Header */} -
-

- @{profile.username}'s Profile -

-

- GitHub activity and coding stats -

-
+ {/* Header */} +
+ + +

+ @{profile.username}'s Profile +

+ +

+ GitHub activity and coding stats +

+
{/* Row 1: Contribution graph + Streak */}
diff --git a/src/components/BackToDashboard.tsx b/src/components/BackToDashboard.tsx new file mode 100644 index 0000000..a8f1518 --- /dev/null +++ b/src/components/BackToDashboard.tsx @@ -0,0 +1,27 @@ +"use client"; + +import Link from "next/link"; +import { useSession } from "next-auth/react"; + +interface Props { + username: string; +} + +export default function BackToDashboard({ username }: Props) { + const { data: session } = useSession(); + + const currentUser = session?.user?.name; + + const isOwner = currentUser === username; + + if (!isOwner) return null; + + return ( + + ← Back to dashboard + + ); +} \ No newline at end of file From edad23f6067d3701605ca724c655fba1068280b9 Mon Sep 17 00:00:00 2001 From: Maniska Date: Tue, 19 May 2026 17:20:09 +0530 Subject: [PATCH 2/3] fix: resolve ownership check and merge conflicts --- src/app/u/[username]/page.tsx | 35 ++++++++++++++++++++---------- src/components/BackToDashboard.tsx | 3 +-- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/app/u/[username]/page.tsx b/src/app/u/[username]/page.tsx index d48dcdd..bc8c0e5 100644 --- a/src/app/u/[username]/page.tsx +++ b/src/app/u/[username]/page.tsx @@ -4,6 +4,7 @@ import ContributionGraph from "@/components/ContributionGraph"; import StreakTracker from "@/components/StreakTracker"; import TopRepos from "@/components/TopRepos"; import BackToDashboard from "@/components/BackToDashboard"; +import StatsCard from "@/components/StatsCard"; interface PublicProfileData { username: string; userId: string; @@ -49,8 +50,7 @@ export async function generateMetadata({ }): Promise { const { username } = params; const profile = await fetchPublicProfile(username); - - const baseUrl = process.env.NEXT_PUBLIC_APP_URL || process.env.NEXTAUTH_URL || "http://localhost:3000"; + const baseUrl = process.env.NEXT_PUBLIC_APP_URL || process.env.NEXTAUTH_URL || "http://localhost:3000"; const profileUrl = `${baseUrl}/u/${username}`; if (!profile) { @@ -85,7 +85,9 @@ export default async function PublicProfilePage({ }) { const { username } = params; const profile = await fetchPublicProfile(username); - +const avatarUrl = `https://avatars.githubusercontent.com/${profile?.username}`; +const topRepo = profile?.repos[0]?.name ?? ""; + if (!profile) { return (
@@ -111,16 +113,27 @@ if (!profile) {
{/* Header */} {/* Header */} -
- +
+
+ + +

+ @{profile.username}'s Profile +

-

- @{profile.username}'s Profile -

+

+ GitHub activity and coding stats +

+
-

- GitHub activity and coding stats -

+
{/* Row 1: Contribution graph + Streak */} diff --git a/src/components/BackToDashboard.tsx b/src/components/BackToDashboard.tsx index a8f1518..d7c45a0 100644 --- a/src/components/BackToDashboard.tsx +++ b/src/components/BackToDashboard.tsx @@ -10,8 +10,7 @@ interface Props { export default function BackToDashboard({ username }: Props) { const { data: session } = useSession(); - const currentUser = session?.user?.name; - +const currentUser = session?.githubLogin; const isOwner = currentUser === username; if (!isOwner) return null; From 587c06dcac999cd3b0023ba4f50e494d8b2c6574 Mon Sep 17 00:00:00 2001 From: Maniska Date: Tue, 19 May 2026 17:36:25 +0530 Subject: [PATCH 3/3] fix: resolve profile page merge conflicts --- src/app/u/[username]/page.tsx | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/src/app/u/[username]/page.tsx b/src/app/u/[username]/page.tsx index bc8c0e5..ddd2d70 100644 --- a/src/app/u/[username]/page.tsx +++ b/src/app/u/[username]/page.tsx @@ -4,7 +4,6 @@ import ContributionGraph from "@/components/ContributionGraph"; import StreakTracker from "@/components/StreakTracker"; import TopRepos from "@/components/TopRepos"; import BackToDashboard from "@/components/BackToDashboard"; -import StatsCard from "@/components/StatsCard"; interface PublicProfileData { username: string; userId: string; @@ -85,8 +84,7 @@ export default async function PublicProfilePage({ }) { const { username } = params; const profile = await fetchPublicProfile(username); -const avatarUrl = `https://avatars.githubusercontent.com/${profile?.username}`; -const topRepo = profile?.repos[0]?.name ?? ""; + if (!profile) { return ( @@ -112,30 +110,17 @@ if (!profile) { return (
{/* Header */} - {/* Header */} -
-
- - -

- @{profile.username}'s Profile -

+
+ -

- GitHub activity and coding stats -

-
+

+ @{profile.username}'s Profile +

- +

+ GitHub activity and coding stats +

- {/* Row 1: Contribution graph + Streak */}