diff --git a/src/app/u/[username]/page.tsx b/src/app/u/[username]/page.tsx index c587a714..6bcb90ae 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 StatsCard from "@/components/StatsCard"; +import BackToDashboard from "@/components/BackToDashboard"; interface PublicProfileData { username: string; @@ -50,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) { @@ -87,53 +86,43 @@ 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 +
- ); - } - - const avatarUrl = `https://avatars.githubusercontent.com/${profile.username}`; - const topRepo = profile.repos[0]?.name ?? ""; +
+ ); +} + return (
{/* Header */} -
-
-

- @{profile.username}'s Profile -

-

- GitHub activity and coding stats -

-
- {/* Download stats card button — client component */} - -
+
+ + +

+ @{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 00000000..d7c45a0a --- /dev/null +++ b/src/components/BackToDashboard.tsx @@ -0,0 +1,26 @@ +"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?.githubLogin; + const isOwner = currentUser === username; + + if (!isOwner) return null; + + return ( + + ← Back to dashboard + + ); +} \ No newline at end of file