fix: apply code review findings — bugs, conventions, perf, security#134
Merged
Conversation
Bugs
- Report.jsx: prefill now correctly maps weekday and sessionType to filter
chips (they were silently discarded before)
- db.js: fetchGymSessionsByDate uses +02:00 offset (Oslo CEST) so the full
Norwegian calendar day is covered regardless of DST transition
- MuscleMap.jsx: image-remove button now uses Carbon Close icon instead of
literal × character; color uses var(--cds-text-inverse)
- ExerciseRowWithAutocomplete: blur setTimeout stored in ref and cancelled
on unmount to prevent setState-after-unmount warning
Convention violations
- utils.js: add getIntlLocale() export — single canonical helper for
i18n.language → IETF locale tag mapping (nb → no, etc.)
- Remove all remaining hardcoded 'no-NO' locale strings from MuscleMap,
Bibliotek, TemplatePicker; replace with getIntlLocale()
- Remove all date-fns { locale: nb } usage from Home and Report; replace
with Intl.DateTimeFormat + getIntlLocale()
- Remove local getIntlLocale() definition from History and inline locale
logic from Planlegger; import from utils instead
- Replace raw hex colors with semantic tokens: getConfidenceColor
(#42be65/#f1c21b/#da1e28 → heat-4/support-warning/support-error),
History calendar ring (#ffffff → cds-background), Bibliotek secondary
chip (#78a9ff → cds-blue-40), MusclePicker focus stroke (#0f62fe →
cds-interactive), Report frequency table (#4589ff → cds-blue-40)
- Home.jsx: remove three gradient usages (hero card, overlay div, week
bar fill) — replace with solid var(--surface-card) / var(--accent)
Performance
- Report: PERIODS and DAYS arrays wrapped in useMemo (were recreated
every render by calling t() inline)
- MuscleMap: STEP_DEFS wrapped in useMemo
- Planlegger projectedData: remove redundant calcMuscles() call; derive
primary/secondary Sets directly from allExercises (one pass vs two)
- History edit mode: library exercises cached in a useRef; subsequent
edit opens reuse the cached list instead of re-fetching
Security / robustness
- sportySync: remove full todaySessions array from GET /api/sporty-health
response; expose count only
- claudeUtils: document that rateLimitMap is per-instance and ephemeral
Docs
- CLAUDE.md: add getIntlLocale() to utils.js exports; update Report
prefill docs; correct sporty-health endpoint description
- README.md: add getIntlLocale to utils.js entry
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-island-090dfd003-134.westeurope.7.azurestaticapps.net |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes 14 findings from a full codebase review covering correctness bugs, Carbon convention violations, performance improvements, and a security tightening. No new features or schema changes.
Changes
Bugs
Report.jsxprefilluseEffect)fetchGymSessionsByDateUTC range breaks DST: changed query bounds from+00:00to+02:00(Oslo CEST, worst-case offset) so all sessions on a Norwegian calendar day are returned regardless of DST transition (db.js)×remove-image button: replaced literal×character with Carbon<Close size={16} />icon; fixedcolor: "#fff"→var(--cds-text-inverse)(MuscleMap.jsx)setTimeoutinExerciseRowWithAutocompletenow stored in auseRefand cancelled viauseEffectcleanupConvention violations
getIntlLocale()centralised: added toutils.jsas the single export; removed duplicate local definition inHistory.jsxand inline logic inPlanlegger.jsx"no-NO"purged:MuscleMap.jsx,Bibliotek.jsx,TemplatePicker.jsxnow callgetIntlLocale()viaIntl.DateTimeFormatdate-fnslocale removed:{ locale: nb }usage eliminated fromHome.jsx(formatSessionDate,formatTodayEyebrow) andReport.jsx(hover card date); replaced withIntl.DateTimeFormatgetConfidenceColor#42be65/#f1c21b/#da1e28→var(--heat-4)/var(--cds-support-warning)/var(--cds-support-error)#ffffff→var(--cds-background)#78a9ff→var(--cds-blue-40)#0f62fe→var(--cds-interactive)#4589ff→var(--cds-blue-40)Home.jsx: hero card background, decorative overlay div, and week-bar fill all replaced with solid tokensPerformance
PERIODS,DAYS(Report) andSTEP_DEFS(MuscleMap) wrapped inuseMemo— were recreating arrays witht()calls on every renderPlanlegger.jsxprojectedData: removed redundantcalcMuscles(allExercises)call; primary/secondary Sets now derived directly fromallExercises(one traversal instead of two)History.jsxedit mode: library exercises cached in auseRef; re-opening edit mode reuses the cached list instead of re-fetchingSecurity / robustness
GET /api/sporty-health: removed fulltodaySessionsarray from response body; exposes count onlyclaudeUtils.js: added comment documenting thatrateLimitMapis per-instance and ephemeral (resets on cold start, not shared across Azure Function instances)Docs
CLAUDE.md: addedgetIntlLocale()toutils.jsexports list; updated Report prefill docs; correctedsporty-healthendpoint descriptionREADME.md: addedgetIntlLocaletoutils.jsentry in project structureTest plan
cd app && npm test— all existing unit tests passGET /api/sporty-healthresponse no longer contains atodaySessionsarray (S1)🤖 Generated with Claude Code