Skip to content

Add vegan and vegetarian flags#1208

Merged
rolandgeider merged 4 commits intomasterfrom
feature/ingredient-dietary-filters
Mar 1, 2026
Merged

Add vegan and vegetarian flags#1208
rolandgeider merged 4 commits intomasterfrom
feature/ingredient-dietary-filters

Conversation

@rolandgeider
Copy link
Member

Proposed Changes

This pull request introduces vegan and vegetarian dietary flags to the Ingredient model, allowing users to filter and view ingredients based on dietary preferences.

(New PR because the old one was deleted)

Sam and others added 3 commits February 26, 2026 21:02
Surfaces the is_vegan and is_vegetarian fields added to the wger backend
(wger-project/wger#2218) in the meal form ingredient search UI.

- ApiIngredientType: add is_vegan / is_vegetarian nullable boolean fields
- Ingredient model: add isVegan / isVegetarian properties with fromJson mapping
- searchIngredient(): accept optional isVegan / isVegetarian filter params,
  pass as ?is_vegan=true / ?is_vegetarian=true query params to ingredientinfo API
- IngredientAutocompleter: add "Vegan only" and "Vegetarian only" toggle switches
  rendered as a row below the search input; filters re-trigger search on change
- i18n: add nutrition.filterVegan and nutrition.filterVegetarian translation keys
- Tests: update ingredient service fixture and assertions for new fields
This will be specially important if we add more options in the future or rework
the language one so that it is more flexible.
While this has technically nothing to do with the vegan flags, we can refactor the
language handling while we're at it. This should make the behaviour more transparent
to the user and could be expanded in the future if needed (manually selecting other
languages, etc.).
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds vegan and vegetarian dietary flags to the Nutrition Ingredient domain model and wires them through the ingredient search flow so the UI can filter ingredient autocompletion results by dietary preference and language scope.

Changes:

  • Extend ingredient API/types/model to include is_vegan / is_vegetarian and expose them as isVegan / isVegetarian.
  • Update ingredient search service to support a new language-filter mode and optional vegan/vegetarian query filters.
  • Add a filter popover UI (language + vegan/vegetarian toggles) to the ingredient autocompleter and update translations/tests.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/utils/consts.ts Removes an unused/obsolete API path constant.
src/types.ts Adds is_vegan / is_vegetarian fields to ApiIngredientType.
src/services/ingredient.ts Extends searchIngredient with language + dietary filter query params.
src/services/ingredient.test.ts Updates ingredient parsing test data/assertions for vegan/vegetarian flags.
src/services/index.ts Re-exports the new IngredientLanguageFilter type.
src/components/Nutrition/widgets/IngredientAutocompleter.test.tsx Adds a UI test ensuring the filter popover is shown.
src/components/Nutrition/widgets/IngredientAutcompleter.tsx Adds filter UI and passes filter params into searchIngredient.
src/components/Nutrition/models/Ingredient.ts Stores and maps vegan/vegetarian flags onto the Ingredient model.
public/locales/en/translation.json Adds English strings for language filter and vegan/vegetarian filters.
public/locales/de/translation.json Re-formats and adds German strings for language filter (but currently missing vegan/vegetarian strings).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@rolandgeider rolandgeider merged commit 4566e89 into master Mar 1, 2026
3 of 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.

Better filtering in the ingredient search

2 participants