summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTucker Evans <tuckerevans24@gmail.com>2019-12-08 16:41:39 -0500
committerTucker Evans <tuckerevans24@gmail.com>2019-12-08 16:41:39 -0500
commitbb1ecccbf324c59097a828a862a10201f76d02a9 (patch)
treedc824955d468ef88c46ee3f4712165c3c7feb581
parent99287dff749f7c6fa050b597115270496738d77c (diff)
Add recipe is now sent to backend from add form
-rw-r--r--recipeBuddy/src/app/add-recipe/add-recipe.component.ts27
1 files changed, 20 insertions, 7 deletions
diff --git a/recipeBuddy/src/app/add-recipe/add-recipe.component.ts b/recipeBuddy/src/app/add-recipe/add-recipe.component.ts
index 50ea1cd..bc88eb7 100644
--- a/recipeBuddy/src/app/add-recipe/add-recipe.component.ts
+++ b/recipeBuddy/src/app/add-recipe/add-recipe.component.ts
@@ -91,17 +91,23 @@ export class AddRecipeComponent {
var i;
for (i = 0; i < formData.ingredients.length; i++) {
ingredients.push(new Ingredient(formData.ingredients[0].ingrName,
- formData.ingredients[0].amount,
+ parseFloat(formData.ingredients[0].amount),
formData.ingredients[0].unit,
""
));
+ if (isNaN(ingredients[ingredients.length - 1].amount)) {
+ ingredients[ingredients.length - 1].amount = 0;
+ }
}
var steps = []
for (i = 0; i < formData.ingredients.length; i++) {
steps.push(new Step(formData.steps[0].instruct,
- formData.steps[0].timer
+ parseInt(formData.steps[0].timer)
));
+ if (isNaN(steps[steps.length - 1].timer)) {
+ steps[steps.length - 1].timer = 0;
+ }
}
var recipe = new Recipe (0, //id
@@ -109,13 +115,20 @@ export class AddRecipeComponent {
formData.desc, //description
ingredients, //ingredients
steps, //steps
- formData.servingSize, //servingSize
- formData.cookTime, //cookTime
+ parseFloat(formData.servingSize), //servingSize
+ parseInt(formData.cookTime), //cookTime
0, //timesCooked
0, //rating
- formData.tags, //tags
- formData.photos //photos
+ formData.tags.split(','), //tags
+ formData.photos.split(',') //photos
);
- console.log(JSON.stringify(recipe))
+ if (isNaN(recipe.servingSize)) {
+ recipe.servingSize = 0;
+ }
+
+ if (isNaN(recipe.cookTime)) {
+ recipe.cookTime = 0;
+ }
+ this.restService.createRecipe(recipe).subscribe()
}
}