brackt/app
Chris Parsons d92f73e449
Extract chess clock presets to shared constant (#432)
* Fix custom chess-clock timer detection and save settings blocker

- Extract getInitialDraftSpeed() helper so both useState init and
  resetSettingsFormState use the same logic; unrecognized presets
  now produce a "custom:{bank}:{incr}" string instead of falling
  back to "standard", so the custom section auto-expands correctly
  (e.g. 8 hr bank + 30 min increment is no longer shown as Standard)
- resetSettingsFormState was not resetting draftSpeed at all; fixed
- Clear hasUnsavedSettingsChanges in the Form's onSubmit so the
  useBlocker check is false at the moment the save navigation starts,
  preventing the "Leave without saving?" dialog from firing on save
- Replace the cleared-on-success useEffect with one that re-marks
  dirty when the action returns an error, so the warning reappears
  after a failed save

https://claude.ai/code/session_01DgHNkvJXGizx41CE2tkVS1

* Address code review: single source of truth for presets, useEffect guard, tests

- Extract CHESS_CLOCK_PRESETS (pure data) into draft-timer.ts as the
  canonical source of truth; DraftSpeedPicker.tsx now spreads those
  values into CHESS_PRESETS rather than duplicating the numbers
- getInitialDraftSpeed moved to draft-timer.ts and rewritten to use
  CHESS_CLOCK_PRESETS.find() — no more hardcoded bankSec/incrSec values
  in three separate places
- parseDraftSpeed switch replaced with CHESS_CLOCK_PRESETS.find() and
  an explicit fallback comment; eliminates the silent default-handles-
  "standard" fragility called out in review
- useEffect that re-marks settings dirty now guards against non-settings
  errors (draft-order, commissioner actions) which carry a `section`
  field — previously any error actionData would spuriously set
  hasUnsavedSettingsChanges=true
- Add parseDraftSpeed and getInitialDraftSpeed test suites to
  draft-timer.test.ts, including parametrised preset coverage via
  it.each(CHESS_CLOCK_PRESETS)

https://claude.ai/code/session_01DgHNkvJXGizx41CE2tkVS1

* Fix lint: use !== null/undefined instead of != null

oxlint enforces eqeqeq; the null check in getInitialDraftSpeed used
!= which triggered two errors.

https://claude.ai/code/session_01DgHNkvJXGizx41CE2tkVS1

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-05-15 14:02:49 -07:00
..
components Extract chess clock presets to shared constant (#432) 2026-05-15 14:02:49 -07:00
contexts feat: implement middleware and context provider for Express integration 2025-10-11 20:56:00 -07:00
hooks Add electric flash + fade animation for draft picks, fixes #381 (#407) 2026-05-10 23:17:29 -07:00
lib Extract chess clock presets to shared constant (#432) 2026-05-15 14:02:49 -07:00
models Add admin user management interface with search and username editing (#431) 2026-05-15 12:07:51 -07:00
routes Extract chess clock presets to shared constant (#432) 2026-05-15 14:02:49 -07:00
services Add opt-in Discord pings to standings notifications (#429) 2026-05-15 10:06:54 -07:00
test Remove first and last name from user profiles (#399) 2026-05-09 09:18:50 -07:00
types Redesign standings page with sortable table, 7-day change, and chart repositioned (#205) 2026-03-22 11:05:13 -07:00
utils Canonical tournament layer: schema + backfill (1/2) (#365) 2026-05-01 20:13:18 -07:00
welcome Redesign to dark-mode-only with navy palette and accent colors (#13) 2026-02-20 19:26:11 -08:00
app.css Add electric flash + fade animation for draft picks, fixes #381 (#407) 2026-05-10 23:17:29 -07:00
entry.client.tsx Filter unnecessary sentry css and js errors. 2026-03-15 10:24:57 -07:00
entry.server.tsx Replace console.* with structured logger, fix no-inferrable-types (closes #98) (#199) 2026-03-21 13:41:39 -07:00
root.tsx Add admin user management interface with search and username editing (#431) 2026-05-15 12:07:51 -07:00
routes.ts Add admin user management interface with search and username editing (#431) 2026-05-15 12:07:51 -07:00