Skip to content

Conversation

@ChrisUlicny
Copy link
Contributor

Proposed Changes

  • Added filter buttons in the body weight chart component to allow users to display entries based on specified time ranges: All, Last Year, Last 6 Months, Last Month, and Last Week.
  • Enhanced user experience by visually indicating the active filter button and ensuring consistent styling with the project theme.
  • Implemented state management to update the displayed entries dynamically based on the selected filter.
  • Added tests for the implemented functionality.

Related Issue

  • Resolves issue #1696 from wger

Please check that the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)

variant={currentFilter === '' ? 'contained' : 'outlined'}
sx={{ fontFamily: theme.typography.fontFamily }}
>
All
Copy link
Member

Choose a reason for hiding this comment

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

can you make the labels translatable? Just add them to public/locales/en/translation.json and then you can just use them with {t('key')}. Just add them to the root, these could potentially be also used soemwhere else in the application

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course! I've updated the code based on your feedback.

export const getWeights = async (): Promise<WeightEntry[]> => {
const url = makeUrl(WEIGHT_PATH, { query: { ordering: '-date', limit: 900 } });
export const getWeights = async (filter: FilterType = ''): Promise<WeightEntry[]> => {
const url = makeUrl(WEIGHT_PATH, { query: { ordering: '-date', limit: 900, filter } });
Copy link
Member

Choose a reason for hiding this comment

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

sorry I forgot one more! The backend doesn't currently understand the filter parameter, but we can calculate the date based on it and pass it like this 'date_gte': <iso-date-string>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have also modified the backend to support the filter and linked the pull request to the issue, alongside this one. Would you prefer the solution I provided, or would you like me to adjust it according to your suggestion and leave the backend unchanged?

Copy link
Member

Choose a reason for hiding this comment

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

I saw that after I wrote this 😄. I think putting the specific date is better since it's more explicit and we don't need a special syntax for that (you'll need to pull master for this BTW)

@coveralls
Copy link
Collaborator

coveralls commented Nov 7, 2024

Coverage Status

coverage: 76.7% (+0.1%) from 76.593%
when pulling e549286 on ChrisUlicny:feature/body-weight-chart-filter-1696
into 19f0be7 on wger-project:master.

@rolandgeider
Copy link
Member

awesome, thank you!

@rolandgeider rolandgeider merged commit 5b88e9f into wger-project:master Nov 9, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants