2026-02-05 18:36:19 +01:00
|
|
|
import { Routes, Route, Navigate } from 'react-router-dom'
|
feat: auth-aware UI and role-based access control (#67)
## Summary
- Add `is_admin` column to users table with Alembic migration and a `require_admin` FastAPI dependency that protects all admin-facing write endpoints (games, pokemon, evolutions, bosses, routes CRUD)
- Expose admin status to frontend via user API and update AuthContext to fetch/store `isAdmin` after login
- Make navigation menu auth-aware (different links for logged-out, logged-in, and admin users) and protect frontend routes with `ProtectedRoute` and `AdminRoute` components, preserving deep-linking through redirects
- Fix test reliability: `drop_all` before `create_all` to clear stale PostgreSQL enums from interrupted test runs
- Fix test auth: add `admin_client` fixture and use valid UUID for mock user so tests pass with new admin-protected endpoints
## Test plan
- [x] All 252 backend tests pass
- [ ] Verify non-admin users cannot access admin write endpoints (games, pokemon, evolutions, bosses CRUD)
- [ ] Verify admin users can access admin endpoints normally
- [ ] Verify navigation shows correct links for logged-out, logged-in, and admin states
- [ ] Verify `/admin/*` routes redirect non-admin users with a toast
- [ ] Verify `/runs/new` and `/genlockes/new` redirect unauthenticated users to login, then back after auth
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Reviewed-on: https://gitea.nerdboden.de/pokemon/nuzlocke-tracker/pulls/67
Co-authored-by: Julian Tabel <juliantabel.jt@gmail.com>
Co-committed-by: Julian Tabel <juliantabel.jt@gmail.com>
2026-03-21 11:44:05 +01:00
|
|
|
import { Layout, ProtectedRoute, AdminRoute } from './components'
|
2026-02-05 18:36:19 +01:00
|
|
|
import { AdminLayout } from './components/admin'
|
2026-02-14 16:41:24 +01:00
|
|
|
import {
|
2026-03-20 21:41:38 +01:00
|
|
|
AuthCallback,
|
2026-02-14 16:41:24 +01:00
|
|
|
GenlockeDetail,
|
|
|
|
|
GenlockeList,
|
|
|
|
|
Home,
|
2026-03-20 16:38:54 +01:00
|
|
|
JournalEntryPage,
|
2026-03-20 21:41:38 +01:00
|
|
|
Login,
|
2026-02-14 16:41:24 +01:00
|
|
|
NewGenlocke,
|
|
|
|
|
NewRun,
|
|
|
|
|
RunList,
|
|
|
|
|
RunEncounters,
|
2026-03-21 13:56:48 +01:00
|
|
|
Settings,
|
2026-03-20 21:41:38 +01:00
|
|
|
Signup,
|
2026-02-14 16:41:24 +01:00
|
|
|
Stats,
|
|
|
|
|
} from './pages'
|
Improve admin panel UX with toasts, evolution CRUD, sorting, drag-and-drop, and responsive layout
Add sonner toast notifications to all mutations, evolution management backend
(CRUD endpoints with search/pagination) and frontend (form modal with pokemon
selector, paginated list page), sortable AdminTable columns (Region/Gen/Year
on Games), drag-and-drop route reordering via @dnd-kit, skeleton loading states,
card-styled table wrappers, and responsive mobile nav in AdminLayout.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 13:09:27 +01:00
|
|
|
import {
|
|
|
|
|
AdminGames,
|
|
|
|
|
AdminGameDetail,
|
|
|
|
|
AdminPokemon,
|
|
|
|
|
AdminRouteDetail,
|
|
|
|
|
AdminEvolutions,
|
2026-02-08 10:54:47 +01:00
|
|
|
AdminRuns,
|
2026-02-09 10:51:47 +01:00
|
|
|
AdminGenlockes,
|
|
|
|
|
AdminGenlockeDetail,
|
Improve admin panel UX with toasts, evolution CRUD, sorting, drag-and-drop, and responsive layout
Add sonner toast notifications to all mutations, evolution management backend
(CRUD endpoints with search/pagination) and frontend (form modal with pokemon
selector, paginated list page), sortable AdminTable columns (Region/Gen/Year
on Games), drag-and-drop route reordering via @dnd-kit, skeleton loading states,
card-styled table wrappers, and responsive mobile nav in AdminLayout.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 13:09:27 +01:00
|
|
|
} from './pages/admin'
|
2026-02-04 17:13:58 +01:00
|
|
|
|
|
|
|
|
function App() {
|
|
|
|
|
return (
|
|
|
|
|
<Routes>
|
|
|
|
|
<Route path="/" element={<Layout />}>
|
|
|
|
|
<Route index element={<Home />} />
|
2026-03-20 21:41:38 +01:00
|
|
|
<Route path="login" element={<Login />} />
|
|
|
|
|
<Route path="signup" element={<Signup />} />
|
|
|
|
|
<Route path="auth/callback" element={<AuthCallback />} />
|
2026-02-05 15:28:50 +01:00
|
|
|
<Route path="runs" element={<RunList />} />
|
feat: auth-aware UI and role-based access control (#67)
## Summary
- Add `is_admin` column to users table with Alembic migration and a `require_admin` FastAPI dependency that protects all admin-facing write endpoints (games, pokemon, evolutions, bosses, routes CRUD)
- Expose admin status to frontend via user API and update AuthContext to fetch/store `isAdmin` after login
- Make navigation menu auth-aware (different links for logged-out, logged-in, and admin users) and protect frontend routes with `ProtectedRoute` and `AdminRoute` components, preserving deep-linking through redirects
- Fix test reliability: `drop_all` before `create_all` to clear stale PostgreSQL enums from interrupted test runs
- Fix test auth: add `admin_client` fixture and use valid UUID for mock user so tests pass with new admin-protected endpoints
## Test plan
- [x] All 252 backend tests pass
- [ ] Verify non-admin users cannot access admin write endpoints (games, pokemon, evolutions, bosses CRUD)
- [ ] Verify admin users can access admin endpoints normally
- [ ] Verify navigation shows correct links for logged-out, logged-in, and admin states
- [ ] Verify `/admin/*` routes redirect non-admin users with a toast
- [ ] Verify `/runs/new` and `/genlockes/new` redirect unauthenticated users to login, then back after auth
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Reviewed-on: https://gitea.nerdboden.de/pokemon/nuzlocke-tracker/pulls/67
Co-authored-by: Julian Tabel <juliantabel.jt@gmail.com>
Co-committed-by: Julian Tabel <juliantabel.jt@gmail.com>
2026-03-21 11:44:05 +01:00
|
|
|
<Route path="runs/new" element={<ProtectedRoute><NewRun /></ProtectedRoute>} />
|
2026-02-07 14:20:26 +01:00
|
|
|
<Route path="runs/:runId" element={<RunEncounters />} />
|
2026-03-20 16:38:54 +01:00
|
|
|
<Route path="runs/:runId/journal/:entryId" element={<JournalEntryPage />} />
|
2026-02-09 10:39:59 +01:00
|
|
|
<Route path="genlockes" element={<GenlockeList />} />
|
feat: auth-aware UI and role-based access control (#67)
## Summary
- Add `is_admin` column to users table with Alembic migration and a `require_admin` FastAPI dependency that protects all admin-facing write endpoints (games, pokemon, evolutions, bosses, routes CRUD)
- Expose admin status to frontend via user API and update AuthContext to fetch/store `isAdmin` after login
- Make navigation menu auth-aware (different links for logged-out, logged-in, and admin users) and protect frontend routes with `ProtectedRoute` and `AdminRoute` components, preserving deep-linking through redirects
- Fix test reliability: `drop_all` before `create_all` to clear stale PostgreSQL enums from interrupted test runs
- Fix test auth: add `admin_client` fixture and use valid UUID for mock user so tests pass with new admin-protected endpoints
## Test plan
- [x] All 252 backend tests pass
- [ ] Verify non-admin users cannot access admin write endpoints (games, pokemon, evolutions, bosses CRUD)
- [ ] Verify admin users can access admin endpoints normally
- [ ] Verify navigation shows correct links for logged-out, logged-in, and admin states
- [ ] Verify `/admin/*` routes redirect non-admin users with a toast
- [ ] Verify `/runs/new` and `/genlockes/new` redirect unauthenticated users to login, then back after auth
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Reviewed-on: https://gitea.nerdboden.de/pokemon/nuzlocke-tracker/pulls/67
Co-authored-by: Julian Tabel <juliantabel.jt@gmail.com>
Co-committed-by: Julian Tabel <juliantabel.jt@gmail.com>
2026-03-21 11:44:05 +01:00
|
|
|
<Route path="genlockes/new" element={<ProtectedRoute><NewGenlocke /></ProtectedRoute>} />
|
2026-02-09 10:39:59 +01:00
|
|
|
<Route path="genlockes/:genlockeId" element={<GenlockeDetail />} />
|
2026-02-07 20:46:36 +01:00
|
|
|
<Route path="stats" element={<Stats />} />
|
2026-03-21 13:56:48 +01:00
|
|
|
<Route path="settings" element={<ProtectedRoute><Settings /></ProtectedRoute>} />
|
2026-02-14 16:41:24 +01:00
|
|
|
<Route
|
|
|
|
|
path="runs/:runId/encounters"
|
|
|
|
|
element={<Navigate to=".." relative="path" replace />}
|
|
|
|
|
/>
|
feat: auth-aware UI and role-based access control (#67)
## Summary
- Add `is_admin` column to users table with Alembic migration and a `require_admin` FastAPI dependency that protects all admin-facing write endpoints (games, pokemon, evolutions, bosses, routes CRUD)
- Expose admin status to frontend via user API and update AuthContext to fetch/store `isAdmin` after login
- Make navigation menu auth-aware (different links for logged-out, logged-in, and admin users) and protect frontend routes with `ProtectedRoute` and `AdminRoute` components, preserving deep-linking through redirects
- Fix test reliability: `drop_all` before `create_all` to clear stale PostgreSQL enums from interrupted test runs
- Fix test auth: add `admin_client` fixture and use valid UUID for mock user so tests pass with new admin-protected endpoints
## Test plan
- [x] All 252 backend tests pass
- [ ] Verify non-admin users cannot access admin write endpoints (games, pokemon, evolutions, bosses CRUD)
- [ ] Verify admin users can access admin endpoints normally
- [ ] Verify navigation shows correct links for logged-out, logged-in, and admin states
- [ ] Verify `/admin/*` routes redirect non-admin users with a toast
- [ ] Verify `/runs/new` and `/genlockes/new` redirect unauthenticated users to login, then back after auth
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Reviewed-on: https://gitea.nerdboden.de/pokemon/nuzlocke-tracker/pulls/67
Co-authored-by: Julian Tabel <juliantabel.jt@gmail.com>
Co-committed-by: Julian Tabel <juliantabel.jt@gmail.com>
2026-03-21 11:44:05 +01:00
|
|
|
<Route path="admin" element={<AdminRoute><AdminLayout /></AdminRoute>}>
|
2026-02-05 18:36:19 +01:00
|
|
|
<Route index element={<Navigate to="/admin/games" replace />} />
|
|
|
|
|
<Route path="games" element={<AdminGames />} />
|
|
|
|
|
<Route path="games/:gameId" element={<AdminGameDetail />} />
|
2026-02-16 20:39:41 +01:00
|
|
|
<Route path="games/:gameId/routes/:routeId" element={<AdminRouteDetail />} />
|
2026-02-05 18:36:19 +01:00
|
|
|
<Route path="pokemon" element={<AdminPokemon />} />
|
Improve admin panel UX with toasts, evolution CRUD, sorting, drag-and-drop, and responsive layout
Add sonner toast notifications to all mutations, evolution management backend
(CRUD endpoints with search/pagination) and frontend (form modal with pokemon
selector, paginated list page), sortable AdminTable columns (Region/Gen/Year
on Games), drag-and-drop route reordering via @dnd-kit, skeleton loading states,
card-styled table wrappers, and responsive mobile nav in AdminLayout.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 13:09:27 +01:00
|
|
|
<Route path="evolutions" element={<AdminEvolutions />} />
|
2026-02-08 10:54:47 +01:00
|
|
|
<Route path="runs" element={<AdminRuns />} />
|
2026-02-09 10:51:47 +01:00
|
|
|
<Route path="genlockes" element={<AdminGenlockes />} />
|
2026-02-16 20:39:41 +01:00
|
|
|
<Route path="genlockes/:genlockeId" element={<AdminGenlockeDetail />} />
|
2026-02-05 18:36:19 +01:00
|
|
|
</Route>
|
2026-02-04 17:13:58 +01:00
|
|
|
</Route>
|
|
|
|
|
</Routes>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default App
|