소스 검색

Prevent adding of duplicate ingredients to merchant recipes

Lee Morgan 6 년 전
부모
커밋
09da3673d7
1개의 변경된 파일7개의 추가작업 그리고 0개의 파일을 삭제
  1. 7 0
      views/recipesPage/singleRecipe.js

+ 7 - 0
views/recipesPage/singleRecipe.js

@@ -79,6 +79,13 @@ let singleRecipeObj = {
             quantity: quantity
         }
         
+        for(let ingredient of recipe.ingredients){
+            if(ingredient.ingredient._id === ingredientId){
+                banner.createError("That ingredient is already in this recipe");
+                return;
+            }
+        }
+        
         axios.post("/merchant/recipes/ingredients/create", {recipeId: recipe._id, item: item})
             .then((response)=>{
                 if(typeof(response.data) === "string"){