brackt/app/models
Chris Parsons 22726550a6
Refactor user profile to comprehensive settings page (#403)
* Add account deletion and multi-section settings page

- Rename /user-profile → /settings with 301 redirect from old URL
- Add multi-section settings nav (Profile, Account, API placeholder, Data & Privacy)
  reusing existing SettingsDesktopNav/SettingsMobileGridNav components
- Implement account deletion via anonymization: wipes all PII from users row,
  releases team ownerships, removes commissioner records, deletes sessions/accounts
- Add data export request form that emails privacy@brackt.com via Resend
- Add deletedAt timestamp column to users table (migration 0100)
- Add anonymizeUserAccount() to user model
- Add removeAllCommissionersByUserId() to commissioner model
- Tests for both new model functions
- Update UserMenu "Profile" link → "Settings" at /settings

https://claude.ai/code/session_017Hvmof82Xr3UwKFc3pnC4X

* Address code review feedback on settings/account deletion

1. Wrap anonymizeUserAccount in a DB transaction so partial failures
   (e.g. session delete succeeds but user update fails) can't leave
   accounts in an inconsistent state
2. Escape user email and notes with escapeHtml() before interpolating
   into the data request email body
3. Reset AlertDialog confirmed state when dialog is dismissed via
   backdrop click or Escape key (onOpenChange handler)
4. Extract accounts DB query to app/models/account.ts (findLinkedAccountsByUserId)
   to comply with the "always query through app/models/" convention
5. Replace dynamic imports() in action handlers with static top-level imports
6. Remove the unused hard-delete deleteUser() function
7. Add lastDataRequestAt timestamp to users (migration 0101) and enforce
   a 30-day server-side cooldown on data export requests
8. Replace fragile actionData type casts with a proper ActionData
   discriminated union; narrowing now works without `as` assertions
9. Strengthen tests: verify which schema tables are passed to delete()
   and that operations run inside the transaction

https://claude.ai/code/session_017Hvmof82Xr3UwKFc3pnC4X

* Fix no-non-null-assertion lint error in PrivacySection

Replace non-null assertion with optional chaining on dataRequestCooldownUntil
to satisfy oxlint no-non-null-assertion rule.

https://claude.ai/code/session_017Hvmof82Xr3UwKFc3pnC4X

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-05-10 17:26:14 -07:00
..
__tests__ Refactor user profile to comprehensive settings page (#403) 2026-05-10 17:26:14 -07:00
account.ts Refactor user profile to comprehensive settings page (#403) 2026-05-10 17:26:14 -07:00
audit-log.ts Migrate auth from Clerk to BetterAuth (#354) 2026-04-29 10:03:50 -07:00
autodraft-settings.ts Add Storybook stories for new components from staged changes (#321) 2026-04-23 22:09:25 -07:00
canonical-golf-skills.ts Canonical golf skills migration + copy participants feature (#369) 2026-05-02 10:29:28 -07:00
canonical-surface-elo.ts Canonical golf skills migration + copy participants feature (#369) 2026-05-02 10:29:28 -07:00
commissioner.ts Refactor user profile to comprehensive settings page (#403) 2026-05-10 17:26:14 -07:00
cs2-major-stage.ts Canonical tournament layer: schema + backfill (1/2) (#365) 2026-05-01 20:13:18 -07:00
draft-pick.ts Canonical tournament layer: schema + backfill (1/2) (#365) 2026-05-01 20:13:18 -07:00
draft-queue.ts feat: proactively prune ineligible queue items after each pick (#59) 2026-03-02 22:07:22 -08:00
draft-slot.ts Fix avatar display bugs in navbar, standings, and draft views (#387) 2026-05-06 17:03:34 -07:00
draft-timer.ts Fix draft timer creation for teams without existing timers (#26) 2026-02-22 17:27:16 -08:00
draft-utils.ts Add Brackt as a league-private meta-sport (#200) (#377) 2026-05-04 20:31:44 -07:00
ev-snapshot.ts User/chris/ev f1 framework (#93) 2026-03-09 15:34:31 -07:00
event-result.ts Canonical tournament layer: schema + backfill (1/2) (#365) 2026-05-01 20:13:18 -07:00
golf-skills.ts Canonical golf skills migration + copy participants feature (#369) 2026-05-02 10:29:28 -07:00
group-stage-match.ts Canonical tournament layer: schema + backfill (1/2) (#365) 2026-05-01 20:13:18 -07:00
index.ts Remove sports_season_tournaments junction table — derive from scoring_events (#373) 2026-05-02 22:19:59 -07:00
league.ts Add oxlint linting setup with zero errors (#194) 2026-03-21 09:44:05 -07:00
participant-expected-value.ts Fix college hockey bracket resolution (#396) 2026-05-08 12:29:39 -07:00
participant-result.ts Canonical tournament layer: schema + backfill (1/2) (#365) 2026-05-01 20:13:18 -07:00
participant-season-result.ts Add oxlint linting setup with zero errors (#194) 2026-03-21 09:44:05 -07:00
participant.ts Canonical tournament layer: schema + backfill (1/2) (#365) 2026-05-01 20:13:18 -07:00
pending-standings-mappings.ts Add regular season standings for NBA/NHL (fixes #89) (#192) 2026-03-21 00:12:01 -07:00
playoff-match-game.ts Add playoff match game scheduling and odds management (#135) 2026-03-11 14:17:43 -07:00
playoff-match-odds.ts Add playoff match game scheduling and odds management (#135) 2026-03-11 14:17:43 -07:00
playoff-match.ts Fix bracket scoring logic to prefer template over DB defaults (#298) 2026-04-15 11:27:00 -07:00
qualifying-points.ts Canonical tournament layer: schema + backfill (1/2) (#365) 2026-05-01 20:13:18 -07:00
regular-season-standings.ts Deduplicate soccer simulator helpers (#391) 2026-05-07 11:48:57 -07:00
scoring-calculator.ts Add Brackt as a league-private meta-sport (#200) (#377) 2026-05-04 20:31:44 -07:00
scoring-event.ts Remove sports_season_tournaments junction table — derive from scoring_events (#373) 2026-05-02 22:19:59 -07:00
scoring-rules.ts Add FIFA World Cup 2026 support with group stage display and Monte Carlo simulator (#242) 2026-03-29 10:27:47 -07:00
season-participant.ts Canonical golf skills migration + copy participants feature (#369) 2026-05-02 10:29:28 -07:00
season-sport.ts feat: Refactor database connection handling in draft-related functions for improved flexibility 2025-10-26 20:35:55 -07:00
season-template-sport.ts refactor: remove isRequired field from season sports and templates 2025-10-13 15:00:59 -07:00
season-template.ts Improve admin dashboard stats and fix scoring event bugs (#230) 2026-03-25 20:46:54 -07:00
season.ts Use sport icons in league views (#394) 2026-05-07 23:06:49 -07:00
sport.ts Harden sport icon cleanup (#397) 2026-05-08 21:19:09 -07:00
sports-season.ts Add Brackt as a league-private meta-sport (#200) (#377) 2026-05-04 20:31:44 -07:00
standings.ts Add Storybook stories for new components from staged changes (#321) 2026-04-23 22:09:25 -07:00
surface-elo.ts Canonical tournament layer: 2026-05-01 21:04:48 -07:00
team-score-events.ts Canonical tournament layer: schema + backfill (1/2) (#365) 2026-05-01 20:13:18 -07:00
team.ts Remove backfill-flag-configs script (#389) 2026-05-06 20:35:02 -07:00
tournament-group.ts Add oxlint linting setup with zero errors (#194) 2026-03-21 09:44:05 -07:00
tournament-result.ts Canonical tournament layer: schema + backfill (1/2) (#365) 2026-05-01 20:13:18 -07:00
tournament.ts Canonical tournament layer: 2026-05-01 21:04:48 -07:00
user.ts Refactor user profile to comprehensive settings page (#403) 2026-05-10 17:26:14 -07:00
watchlist.ts Mobile draft room improvements: watchlist, collapsible picks feed, autodraft controls (#355) 2026-04-29 11:49:26 -07:00