Files
nuzlocke-tracker/.beans/nuzlocke-tracker-h205--auth-aware-navigation-menu.md
Julian Tabel 7ff271efba chore(auth-aware-ui-and-role-based-access-control): Expose admin status to frontend via user API
The frontend needs to know if the current user is an admin so it can show/hide the Admin nav link and protect admin routes client-side.

Bean: nuzlocke-tracker-5svj

chore: Update beans
2026-03-21 11:23:54 +01:00

1.4 KiB

title, status, type, priority, created_at, updated_at, parent, blocked_by
title status type priority created_at updated_at parent blocked_by
Auth-aware navigation menu completed task normal 2026-03-21T10:06:20Z 2026-03-21T10:22:34Z nuzlocke-tracker-ce4o
nuzlocke-tracker-5svj

Update the Layout component to show different nav links based on auth state and admin role.

Checklist

  • Replace static `navLinks` array with dynamic links based on `useAuth()` state
  • Logged out: Home, Runs, Genlockes, Stats (no New Run, no Admin)
  • Logged in (non-admin): New Run, My Runs, Genlockes, Stats
  • Logged in (admin): New Run, My Runs, Genlockes, Stats, Admin
  • Update both desktop and mobile nav (they share the same `navLinks` array, so this should be automatic)
  • Verify menu updates reactively on login/logout

Files to change

  • `frontend/src/components/Layout.tsx` — make `navLinks` dynamic based on auth state

Summary of Changes

  • Removed static navLinks array from module scope
  • Added dynamic navLinks computation inside Layout component using useMemo
  • Navigation now depends on user and isAdmin from useAuth():
    • Logged out: Home, Runs, Genlockes, Stats
    • Logged in (non-admin): New Run, My Runs, Genlockes, Stats
    • Logged in (admin): New Run, My Runs, Genlockes, Stats, Admin
  • Updated isActive function to handle Home route (/) correctly
  • Both desktop and mobile nav automatically use the same dynamic navLinks array