Skip to content

feat: add table type filter to reports table view - #2066

Merged
CodeWithCJ merged 2 commits into
CodeWithCJ:mainfrom
dalekirkwood:feat/reports-table-type-filter
Aug 10, 2026
Merged

feat: add table type filter to reports table view#2066
CodeWithCJ merged 2 commits into
CodeWithCJ:mainfrom
dalekirkwood:feat/reports-table-type-filter

Conversation

@dalekirkwood

@dalekirkwood dalekirkwood commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Description

What problem does this PR solve?
The Reports table view stacks all tables (Food Diary, Exercise, Body Measurements, + custom categories) vertically at once. With large datasets this is overwhelming and hard to navigate.

How did you implement the solution?
Added a Select dropdown to ReportsTables that lets users pick one table at a time. State is lifted to the Reports parent so the filter persists across date range changes.

Linked Issue: Closes #2084

How to Test

  1. Go to Reports → Table tab
  2. Use the "Show table" dropdown to select a single table type
  3. Verify only that table renders
  4. Change the date range — verify the filter selection persists
  5. Select "All tables" to return to the default view

PR Type

  • Issue (bug fix)
  • New Feature
  • Refactor
  • Documentation

Checklist

All PRs:

  • [MANDATORY - ALL] Integrity & License: I certify this is my own work, free of malicious code, and I agree to the License terms.

New features only:

Frontend changes (SparkyFitnessFrontend/):

  • [MANDATORY for Frontend changes] Quality: I have run pnpm run validate and it passes.
  • [MANDATORY for Frontend changes] Translations: I have only updated the English (en) translation file.

Notes for Reviewers

  • Default is "All tables" (preserves existing behavior)
  • Exported TableFilterValue type shared between parent and child
  • Uses existing t(key, Default) i18n fallback pattern — no locale file changes needed
  • 7/7 tests passing

- Add Select dropdown to ReportsTables showing one table at a time
- Options: All tables (default), Food Diary, Exercise Entries, Body
  Measurements, + dynamic custom measurement categories
- Lift selectedTable state to Reports.tsx parent so filter persists
  across data refetches (date range changes)
- Export TableFilterValue type shared between parent and child
- Add 2 filter tests with stateful wrapper
@github-actions github-actions Bot added enhancement New feature or request frontend labels Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

PR Validation Results

Change Detection

  • 🖥️ Frontend changes detected

✅ All checks passed. Thank you!

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Reports now provides a selector for food, exercise, body measurements, all tables, and custom measurement categories. ReportsTables conditionally renders matching cards. Tests cover default, standard-table, and custom-category filtering.

Changes

Reports table filtering

Layer / File(s) Summary
Selection contract and page wiring
SparkyFitnessFrontend/src/pages/Reports/Reports.tsx, SparkyFitnessFrontend/src/pages/Reports/ReportsTables.tsx
ReportsTables defines TableFilterValue, receives selection props, and uses state initialized to 'all'.
Table selector and conditional card rendering
SparkyFitnessFrontend/src/pages/Reports/ReportsTables.tsx
A selector supports standard tables and custom measurement categories. Report cards render according to the selected value while retaining existing table behavior.
Filter interaction tests
SparkyFitnessFrontend/src/tests/components/ReportsTables.test.tsx
Tests use stateful selection and verify default rendering, Body Measurements filtering, and Heart Rate custom-category filtering.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Reports
  participant ReportsTables
  participant ReportCards
  User->>ReportsTables: select a report table
  ReportsTables->>Reports: call onSelectedTableChange
  Reports->>ReportsTables: update selectedTable
  ReportsTables->>ReportCards: render matching report cards
  ReportCards-->>User: display selected table
Loading

Possibly related PRs

Suggested reviewers: apedley

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the problem, implementation, testing, issue, type, and frontend checks, but omits the mandatory UI checklist and screenshots. Add the UI changes checklist and attach Before/After screenshots, or explain why the mandatory screenshot requirement does not apply.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly states that the Reports table view gains a table-type filter, which matches the primary change.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
SparkyFitnessFrontend/src/tests/components/ReportsTables.test.tsx (1)

73-99: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover the custom-category filter path.

Every render passes empty customCategories and customMeasurementsData. Add a test with one custom category and one measurement. Verify that selecting category:${category.id} hides standard cards and renders only that category card.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@SparkyFitnessFrontend/src/tests/components/ReportsTables.test.tsx` around
lines 73 - 99, Add a ReportsTables test using renderTable with one custom
category and matching measurement data, then select the category:${category.id}
filter through the rendered UI. Assert that standard cards are hidden and only
the selected custom-category card is rendered, covering the custom-category
filtering path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@SparkyFitnessFrontend/src/pages/Reports/ReportsTables.tsx`:
- Around line 390-402: Add an accessible translated name to the SelectTrigger in
the table type filter by supplying an aria-label via the existing
useTranslation() t(...) mechanism, using a key and fallback that clearly
describe selecting the table. Keep the current selectedTable value and
onSelectedTableChange behavior unchanged.

---

Nitpick comments:
In `@SparkyFitnessFrontend/src/tests/components/ReportsTables.test.tsx`:
- Around line 73-99: Add a ReportsTables test using renderTable with one custom
category and matching measurement data, then select the category:${category.id}
filter through the rendered UI. Assert that standard cards are hidden and only
the selected custom-category card is rendered, covering the custom-category
filtering path.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1b8cc63f-8c48-46f9-adfa-ef57a5c96308

📥 Commits

Reviewing files that changed from the base of the PR and between cb2c3cb and d2004ab.

📒 Files selected for processing (3)
  • SparkyFitnessFrontend/src/pages/Reports/Reports.tsx
  • SparkyFitnessFrontend/src/pages/Reports/ReportsTables.tsx
  • SparkyFitnessFrontend/src/tests/components/ReportsTables.test.tsx

Comment thread SparkyFitnessFrontend/src/pages/Reports/ReportsTables.tsx
- Add translated aria-label to SelectTrigger for accessibility
- Add test verifying custom-category filter hides standard tables
  and renders only the selected category card

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@SparkyFitnessFrontend/src/tests/components/ReportsTables.test.tsx`:
- Around line 177-233: Extend the test around the customCategory and
customMeasurement fixtures with a second custom category and corresponding
measurement. Pass both through ReportsTables, select Heart Rate as before, then
assert the second category’s table heading is absent while the Heart Rate table
remains present.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0f8a6cb1-a16a-450e-8b2e-907199cb1eed

📥 Commits

Reviewing files that changed from the base of the PR and between d2004ab and fd06d4a.

📒 Files selected for processing (2)
  • SparkyFitnessFrontend/src/pages/Reports/ReportsTables.tsx
  • SparkyFitnessFrontend/src/tests/components/ReportsTables.test.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • SparkyFitnessFrontend/src/pages/Reports/ReportsTables.tsx

Comment thread SparkyFitnessFrontend/src/tests/components/ReportsTables.test.tsx
@CodeWithCJ
CodeWithCJ merged commit 3b8e97a into CodeWithCJ:main Aug 10, 2026
10 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Filter to show one table at a time in Reports table view

2 participants