feat: add table type filter to reports table view - #2066
Conversation
- 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
PR Validation ResultsChange Detection
✅ All checks passed. Thank you! |
📝 WalkthroughWalkthroughReports 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. ChangesReports table 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
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
SparkyFitnessFrontend/src/tests/components/ReportsTables.test.tsx (1)
73-99: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover the custom-category filter path.
Every render passes empty
customCategoriesandcustomMeasurementsData. Add a test with one custom category and one measurement. Verify that selectingcategory:${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
📒 Files selected for processing (3)
SparkyFitnessFrontend/src/pages/Reports/Reports.tsxSparkyFitnessFrontend/src/pages/Reports/ReportsTables.tsxSparkyFitnessFrontend/src/tests/components/ReportsTables.test.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
There was a problem hiding this comment.
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
📒 Files selected for processing (2)
SparkyFitnessFrontend/src/pages/Reports/ReportsTables.tsxSparkyFitnessFrontend/src/tests/components/ReportsTables.test.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- SparkyFitnessFrontend/src/pages/Reports/ReportsTables.tsx
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
PR Type
Checklist
All PRs:
New features only:
Frontend changes (
SparkyFitnessFrontend/):pnpm run validateand it passes.en) translation file.Notes for Reviewers
TableFilterValuetype shared between parent and childt(key, Default)i18n fallback pattern — no locale file changes needed