You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implements Phase 6 - Kitchen Inventory Management - Add functionality to substitute ingredient button. Also implement a backend endpoint to update the ingredient.
Implements the substitute ingredient modal that allows users to replace unavailable ingredients with available alternatives from the inventory. Clicking the "Substitute" button on any unavailable ingredient opens a popup with a searchable dropdown of available inventory items, a quantity input field, and confirm/cancel actions. On confirming, the ingredient is updated both in the UI and in the database via the backend API.
Related PRs (if any):
This frontend PR is related to the backend PR in the HGNRest repository on branch shravan-substitute-ingredient-backend.
This PR builds on top of PR #4996 (View Recipe Details) and PR #4879 (Recipes Landing Page).
Main changes explained:
Create file SubstituteIngredientModal.jsx for introducing the substitute ingredient popup component with searchable dropdown of inventory items (name, category, quantity available), quantity input, error handling, and API integration
Create file SubstituteIngredientModal.module.css for all modal styling using CSS modules with earth-tone palette, dark mode support, responsive breakpoints, and error message display
Update file ViewRecipe.jsx for tracking ingredients in local state, wiring the Substitute button to open the modal, handling confirmed substitutions via API response, and notifying the parent component of updates
Update file RecipesLandingPage.jsx for fetching recipes from the backend API instead of mock data, with fallback to mock data if API is unavailable, and handling recipe updates after substitution
Update file RecipeCard.jsx for supporting both MongoDB _id and mock data id fields
Update file routes.jsx for adding the Recipes route with KIProtectedRoute
How to test:
Check into branch shravan-substitute-ingredient
Do npm install and npm run start:local to run this PR locally
Start the backend (HGNRest) on branch shravan-substitute-ingredient-backend with npm start
Clear site data/cache
Log in as admin user
Navigate to Kitchen & Inventory portal > go to /kitchenandinventory/recipes
Verify the recipes landing page loads with 3 recipe cards fetched from the API
Click "View Recipe" on "Garden Vegetable Soup"
Scroll to the Ingredients section and find "Black Pepper" marked as "Not Available"
Click the "Substitute" button on Black Pepper
Verify the modal opens showing "Replacing: Black Pepper - To taste"
Click the dropdown and verify the searchable list of inventory items appears (try searching "pepper" or "dairy")
Select "White Pepper" from the dropdown and enter "2g" as the quantity
Click "Confirm Substitute"
Verify Black Pepper is replaced with "White Pepper" showing "2g" and the badge changes to "Available"
Close the recipe panel and reopen it to verify the substitution persists
Test the same flow on "Herb Roasted Chicken" with "Breadcrumbs" or "Parmesan Cheese"
Test responsive design by resizing browser to tablet and mobile widths
Screenshots or videos of changes:
Light mode
Dark Mode
Before Substitution
After Substituition
Substituiton
Note:
The inventory dropdown currently uses mock inventory data. It will be updated to fetch from a real inventory endpoint once that collection is available. The backend endpoint PUT /api/kitchenandinventory/recipes/:recipeId/substitute is fully functional and persists changes to MongoDB Atlas. If the backend is not running, the landing page falls back to mock data and substitutions update locally only. The Substitute and Reorder buttons only appear on ingredients where isAvailable is false and isOnsite is false. All styling uses CSS Modules as required by the project guidelines.
Shravan-neelamsetty
changed the title
feat: implement substitute ingredient modal with backend API integration
Shravan: implement substitute ingredient modal with backend API integration
Apr 18, 2026
The reason will be displayed to describe this comment to others. Learn more.
Reviewed PR #5167 by Shravan. Checked out both the frontend and corresponding backend branch locally and tested the substitute ingredient flow on the recipes page. Verified that the recipes load correctly, substitution updates the ingredient in the UI, and changes persist after reopening the recipe. Confirmed the modal-based substitution flow works for other ingredients as expected. Functionality behaves as intended. Approving.
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
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.
Description
Implements Phase 6 - Kitchen Inventory Management - Add functionality to substitute ingredient button. Also implement a backend endpoint to update the ingredient.
Implements the substitute ingredient modal that allows users to replace unavailable ingredients with available alternatives from the inventory. Clicking the "Substitute" button on any unavailable ingredient opens a popup with a searchable dropdown of available inventory items, a quantity input field, and confirm/cancel actions. On confirming, the ingredient is updated both in the UI and in the database via the backend API.
Related PRs (if any):
This frontend PR is related to the backend PR in the HGNRest repository on branch
shravan-substitute-ingredient-backend.This PR builds on top of PR #4996 (View Recipe Details) and PR #4879 (Recipes Landing Page).
Main changes explained:
SubstituteIngredientModal.jsxfor introducing the substitute ingredient popup component with searchable dropdown of inventory items (name, category, quantity available), quantity input, error handling, and API integrationSubstituteIngredientModal.module.cssfor all modal styling using CSS modules with earth-tone palette, dark mode support, responsive breakpoints, and error message displayViewRecipe.jsxfor tracking ingredients in local state, wiring the Substitute button to open the modal, handling confirmed substitutions via API response, and notifying the parent component of updatesRecipesLandingPage.jsxfor fetching recipes from the backend API instead of mock data, with fallback to mock data if API is unavailable, and handling recipe updates after substitutionRecipeCard.jsxfor supporting both MongoDB_idand mock dataidfieldsroutes.jsxfor adding the Recipes route with KIProtectedRouteHow to test:
shravan-substitute-ingredientnpm installandnpm run start:localto run this PR locallyshravan-substitute-ingredient-backendwithnpm start/kitchenandinventory/recipesScreenshots or videos of changes:
Light mode
Dark Mode
Before Substitution
After Substituition
Substituiton
Note:
The inventory dropdown currently uses mock inventory data. It will be updated to fetch from a real inventory endpoint once that collection is available. The backend endpoint
PUT /api/kitchenandinventory/recipes/:recipeId/substituteis fully functional and persists changes to MongoDB Atlas. If the backend is not running, the landing page falls back to mock data and substitutions update locally only. The Substitute and Reorder buttons only appear on ingredients whereisAvailableis false andisOnsiteis false. All styling uses CSS Modules as required by the project guidelines.