From 8052754a4bcc3d07208d11aad764d2bb3492166d Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Wed, 5 Nov 2025 15:52:09 -0800 Subject: add profile page to navbar --- backend/src/routes/user.ts | 3 ++- frontend/src/components/NavBar.tsx | 11 +++++++++++ frontend/src/pages/Profile.tsx | 13 +++++++------ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/backend/src/routes/user.ts b/backend/src/routes/user.ts index 7e030fd..96a452e 100644 --- a/backend/src/routes/user.ts +++ b/backend/src/routes/user.ts @@ -31,7 +31,8 @@ export const handleMeRoute = async (req: express.Request, res: express.Response) FROM "Score" s INNER JOIN "Game" g ON g."internalName" = s."gameInternalName" WHERE s."userId" = ${parseInt(userId as string)} - ORDER BY s."gameInternalName", s."timestamp" DESC; + ORDER BY s."gameInternalName", s."timestamp" DESC + LIMIT 5; `; const scoreCountByGame: SafeGameCount[] = await prisma.$queryRaw` SELECT diff --git a/frontend/src/components/NavBar.tsx b/frontend/src/components/NavBar.tsx index 296ac49..6edfcde 100644 --- a/frontend/src/components/NavBar.tsx +++ b/frontend/src/components/NavBar.tsx @@ -21,6 +21,17 @@ export const NavBar = ({ currentPage, user, handleLogout }: { > Home + setIsMobileMenuOpen(false)} + > + Profile + { const { user, isLoading, logout } = useAuth(); - const targetUser = + let targetUser = new URLSearchParams(window.location.search).get("userId") || ""; // looking at profile of this user const navigate = useNavigate(); const [fetchingHeatmapData, setFetchingHeatmapData] = useState(true); @@ -101,14 +101,15 @@ const Profile = () => { } }, [targetUser]); - if (!targetUser) { - navigate("/"); - } - if (!user) { return ; } + if (!targetUser) { + targetUser = user.id.toString(); + } + + if (isLoading || fetchingHeatmapData || fetchingUserData) { return ; } @@ -129,7 +130,7 @@ const Profile = () => { return (
- + {/* Main Content */}
-- cgit v1.2.3