From aeff7fd80d7726464c2a670b54c921ef8dd75b4d Mon Sep 17 00:00:00 2001 From: minhd-vu Date: Mon, 26 Feb 2024 01:43:27 -0500 Subject: [PATCH] add profile to navbar --- components/Navbar.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/components/Navbar.tsx b/components/Navbar.tsx index 0926841..56297a6 100644 --- a/components/Navbar.tsx +++ b/components/Navbar.tsx @@ -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 (
@@ -11,6 +22,11 @@ export default async function Navbar() {