|
@@ -1018,6 +1018,17 @@ class RecipeIngredient{
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/*
|
|
|
|
|
+Recipe Object
|
|
|
|
|
+id = database id of recipe
|
|
|
|
|
+name = name of recipe
|
|
|
|
|
+price = price of recipe in cents
|
|
|
|
|
+ingredients = [{
|
|
|
|
|
+ ingredient: Ingredient Object,
|
|
|
|
|
+ quantity: quantity of the ingredient within the recipe (stored as base unit, i.e grams)
|
|
|
|
|
+}]
|
|
|
|
|
+parent = merchant that it belongs to
|
|
|
|
|
+*/
|
|
|
class Recipe{
|
|
class Recipe{
|
|
|
constructor(id, name, price, ingredients, parent){
|
|
constructor(id, name, price, ingredients, parent){
|
|
|
if(price < 0){
|
|
if(price < 0){
|
|
@@ -2858,7 +2869,7 @@ let newRecipe = {
|
|
|
if(merchant.ingredients[j].ingredient.id === inputs[i].children[1].children[0].value){
|
|
if(merchant.ingredients[j].ingredient.id === inputs[i].children[1].children[0].value){
|
|
|
newRecipe.ingredients.push({
|
|
newRecipe.ingredients.push({
|
|
|
ingredient: inputs[i].children[1].children[0].value,
|
|
ingredient: inputs[i].children[1].children[0].value,
|
|
|
- quantity: controller.convertToMain(merchant.ingredients[j].ingredient.unit, inputs[i].children[2].children[0].value)
|
|
|
|
|
|
|
+ quantity: merchant.ingredients[j].convertToBase(inputs[i].children[2].children[0].value)
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
break;
|
|
break;
|
|
@@ -2881,16 +2892,29 @@ let newRecipe = {
|
|
|
if(typeof(response) === "string"){
|
|
if(typeof(response) === "string"){
|
|
|
banner.createError(response);
|
|
banner.createError(response);
|
|
|
}else{
|
|
}else{
|
|
|
- const recipe = new Recipe(
|
|
|
|
|
|
|
+ let ingredients = [];
|
|
|
|
|
+ for(let i = 0; i < response.ingredients.length; i++){
|
|
|
|
|
+ for(let j = 0; j < merchant.ingredients.length; j++){
|
|
|
|
|
+ if(merchant.ingredients[j].ingredient.id === response.ingredients[i].ingredient){
|
|
|
|
|
+ ingredients.push({
|
|
|
|
|
+ ingredient: merchant.ingredients[j].ingredient,
|
|
|
|
|
+ quantity: response.ingredients[i].quantity
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ merchant.addRecipe(new Recipe(
|
|
|
response._id,
|
|
response._id,
|
|
|
response.name,
|
|
response.name,
|
|
|
response.price,
|
|
response.price,
|
|
|
- response.ingredients,
|
|
|
|
|
- merchant,
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- merchant.addRecipe(recipe);
|
|
|
|
|
- banner.createNotification("RECIPE CREATED");
|
|
|
|
|
|
|
+ ingredients,
|
|
|
|
|
+ merchant
|
|
|
|
|
+ ));
|
|
|
|
|
+
|
|
|
|
|
+ controller.openStrand("recipeBook");
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
.catch((err)=>{
|
|
.catch((err)=>{
|