brackt/app/routes
Chris Parsons 442b392461
Add audit logging for commissioner actions (#293)
Closes #144

* feat: add commissioner audit log for league transparency (issue #144)

Adds a complete audit log system so league members can verify that
settings, draft order, picks, and time banks have not been quietly
changed without their awareness.

Changes:
- database/schema.ts: new `audit_action` enum + `commissioner_audit_log`
  table (seasonId, leagueId, actorClerkId, actorDisplayName, action,
  affectedTeamIds[], details jsonb, createdAt)
- drizzle/0075: generated migration for the new table
- app/models/audit-log.ts: createAuditLogEntry, getAuditLogForSeason
  (paginated), logCommissionerAction (resolves display name automatically)
- app/lib/audit-log-display.ts: shared formatAuditDetail() helper used by
  both the league home widget and the full audit log page
- app/routes/leagues/$leagueId.audit-log.tsx: new read-only route at
  /leagues/:id/audit-log, accessible to all league members, with
  action-type filter and pagination
- app/routes.ts: registers the new route
- League home page ($leagueId.server.ts / $leagueId.tsx): "Recent Activity"
  summary card showing the last 5 entries with "View all" link
- Settings page ($leagueId.settings.tsx): "View Full Audit Log" link card;
  audit log calls added for league/draft settings changes, draft order
  set/randomized, and draft reset
- API routes: audit log calls added to draft.start, draft.pause,
  draft.resume, draft.rollback, draft.adjust-time-bank, draft.force-autopick,
  draft.force-manual-pick, draft.replace-pick
- Tests: 11 new unit tests for the audit-log model; mocks added to 3
  existing route test files to account for the new logCommissionerAction call

https://claude.ai/code/session_01NdiwK2fbtKhAD3XuD58fTm

* fix: validate action filter URL param against known enum values

The action filter on the audit log route was cast directly from the URL
search param to AuditAction without validation. An invalid value would
be passed into the Drizzle inArray() call, potentially throwing a
PostgreSQL enum type error. Now validates against the actual enum values
before using the filter.

https://claude.ai/code/session_01NdiwK2fbtKhAD3XuD58fTm

* Fix lint errors: use !== instead of != and toSorted instead of sort

https://claude.ai/code/session_01NdiwK2fbtKhAD3XuD58fTm

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-04-13 15:45:39 -07:00
..
__tests__ feat: batch qualifying results entry (#290) 2026-04-12 14:52:22 -07:00
admin/__tests__ fix: infer LLWS bracket side from name when externalId is null (#285) 2026-04-09 09:51:16 -04:00
api Add audit logging for commissioner actions (#293) 2026-04-13 15:45:39 -07:00
leagues Add audit logging for commissioner actions (#293) 2026-04-13 15:45:39 -07:00
teams feat: add meta title to all route pages (#109) 2026-03-10 12:10:52 -07:00
admin._index.tsx Improve admin dashboard stats and fix scoring event bugs (#230) 2026-03-25 20:46:54 -07:00
admin.data-sync.tsx Replace console.* with structured logger, fix no-inferrable-types (closes #98) (#199) 2026-03-21 13:41:39 -07:00
admin.participants.tsx feat: add meta title to all route pages (#109) 2026-03-10 12:10:52 -07:00
admin.sports-seasons.$id.clone.tsx feat: clone sports season (#282) (#288) 2026-04-11 22:03:37 -07:00
admin.sports-seasons.$id.elo-ratings.tsx Add CS2 Major Qualifying Points simulator and stage management (#260) 2026-04-05 16:40:05 -04:00
admin.sports-seasons.$id.events.$eventId.bracket.server.ts Refactor playoff event processing and improve code clarity (#261) 2026-04-05 18:11:43 -04:00
admin.sports-seasons.$id.events.$eventId.bracket.tsx fix: NBA play-in bracket advancement bugs (#292) 2026-04-12 22:25:32 -07:00
admin.sports-seasons.$id.events.$eventId.cs2-setup.tsx Add CS2 Major Qualifying Points simulator and stage management (#260) 2026-04-05 16:40:05 -04:00
admin.sports-seasons.$id.events.$eventId.helpers.ts feat: batch qualifying results entry (#290) 2026-04-12 14:52:22 -07:00
admin.sports-seasons.$id.events.$eventId.server.ts feat: batch qualifying results entry (#290) 2026-04-12 14:52:22 -07:00
admin.sports-seasons.$id.events.$eventId.tsx feat: batch qualifying results entry (#290) 2026-04-12 14:52:22 -07:00
admin.sports-seasons.$id.events.server.ts Replace console.* with structured logger, fix no-inferrable-types (closes #98) (#199) 2026-03-21 13:41:39 -07:00
admin.sports-seasons.$id.events.tsx Fix oxlint warnings: no-shadow, consistent-function-scoping, no-non-null-assertion, and others (#196) 2026-03-21 10:59:51 -07:00
admin.sports-seasons.$id.expected-values.server.ts fix: address VORP code review issues (#283) 2026-04-08 23:20:02 -04:00
admin.sports-seasons.$id.expected-values.tsx Fix oxlint warnings: no-shadow, consistent-function-scoping, no-non-null-assertion, and others (#196) 2026-03-21 10:59:51 -07:00
admin.sports-seasons.$id.futures-odds.tsx Replace console.* with structured logger, fix no-inferrable-types (closes #98) (#199) 2026-03-21 13:41:39 -07:00
admin.sports-seasons.$id.golf-skills.tsx Prevent duplicate participants within a sports season, fixes #69 (#236) 2026-03-27 01:09:04 -07:00
admin.sports-seasons.$id.participants.tsx fix: infer LLWS bracket side from name when externalId is null (#285) 2026-04-09 09:51:16 -04:00
admin.sports-seasons.$id.regular-standings.tsx Replace console.* with structured logger, fix no-inferrable-types (closes #98) (#199) 2026-03-21 13:41:39 -07:00
admin.sports-seasons.$id.simulate.tsx Add FIFA World Cup 2026 support with group stage display and Monte Carlo simulator (#242) 2026-03-29 10:27:47 -07:00
admin.sports-seasons.$id.standings.tsx Replace console.* with structured logger, fix no-inferrable-types (closes #98) (#199) 2026-03-21 13:41:39 -07:00
admin.sports-seasons.$id.surface-elo.tsx Prevent duplicate participants within a sports season, fixes #69 (#236) 2026-03-27 01:09:04 -07:00
admin.sports-seasons.$id.tsx feat: clone sports season (#282) (#288) 2026-04-11 22:03:37 -07:00
admin.sports-seasons.new.tsx Replace isDraftable boolean with draftOn/draftOff date range (#263) 2026-04-05 22:09:52 -04:00
admin.sports-seasons.tsx feat: sort admin sports seasons by status, sport name, then year (#286) 2026-04-09 10:07:18 -04:00
admin.sports.$id.tsx Add golf qualifying points simulator (Plackett-Luce Monte Carlo) (#223) 2026-03-24 21:46:02 -07:00
admin.sports.new.tsx Replace console.* with structured logger, fix no-inferrable-types (closes #98) (#199) 2026-03-21 13:41:39 -07:00
admin.sports.tsx feat: add meta title to all route pages (#109) 2026-03-10 12:10:52 -07:00
admin.standings-snapshots.tsx Replace console.* with structured logger, fix no-inferrable-types (closes #98) (#199) 2026-03-21 13:41:39 -07:00
admin.templates.$id.tsx Replace console.* with structured logger, fix no-inferrable-types (closes #98) (#199) 2026-03-21 13:41:39 -07:00
admin.templates.new.tsx Replace console.* with structured logger, fix no-inferrable-types (closes #98) (#199) 2026-03-21 13:41:39 -07:00
admin.templates.tsx feat: add meta title to all route pages (#109) 2026-03-10 12:10:52 -07:00
admin.tsx feat: add meta title to all route pages (#109) 2026-03-10 12:10:52 -07:00
api.admin.export-sports-data.ts feat: add admin routes and checkbox component for sports management 2025-10-12 21:54:49 -07:00
home.tsx Add upcoming events pages and fix timezone filtering, fixes #213 (#235) 2026-03-27 00:49:16 -07:00
how-to-play.tsx Add rules page, rewrite how-to-play, and fix scoring display (#20) 2026-02-21 21:58:51 -08:00
i.$inviteCode.tsx Optimize user data fetching with batch queries and centralize display name logic (#176) 2026-03-18 16:46:07 -07:00
rules.tsx Add rules page, rewrite how-to-play, and fix scoring display (#20) 2026-02-21 21:58:51 -08:00
support.tsx Add support page with Discord link and contact form, fixes #233 (#234) 2026-03-26 17:17:49 -07:00
test-socket.tsx Replace console.* with structured logger, fix no-inferrable-types (closes #98) (#199) 2026-03-21 13:41:39 -07:00
upcoming-events.tsx Add upcoming events pages and fix timezone filtering, fixes #213 (#235) 2026-03-27 00:49:16 -07:00
user-profile.tsx feat: add meta title to all route pages (#109) 2026-03-10 12:10:52 -07:00