Skip to content

Commit

Permalink
add profile to navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
minhd-vu committed Feb 26, 2024
1 parent 67f3cb6 commit aeff7fd
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions components/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import { getServerSession } from "next-auth";
import LoginButton from "./LoginButton";
import ThemeController from "./ThemeController";
import prisma from "@/lib/prisma";
import { User } from "@prisma/client";

export default async function Navbar() {
const session = await getServerSession();
let user: User | null = null;
if (session?.user?.email) {
user = await prisma.user.findUnique({
where: { email: session.user.email },
});
}

return (
<div className="navbar bg-base-100">
<div className="flex-1">
Expand All @@ -11,6 +22,11 @@ export default async function Navbar() {
</div>
<div className="flex-none">
<ul className="menu menu-horizontal px-2">
{user && (
<li>
<a href={`/user/${user.id}`}>Profile</a>
</li>
)}
<li>
<a href="/leaderboard">Leaderboard</a>
</li>
Expand Down

0 comments on commit aeff7fd

Please sign in to comment.