summaryrefslogtreecommitdiff
path: root/recipeBuddy/src/app/add-recipe
diff options
context:
space:
mode:
authorTucker Evans <tuckerevans24@gmail.com>2019-12-06 15:17:32 -0500
committerTucker Evans <tuckerevans24@gmail.com>2019-12-08 15:03:07 -0500
commit994f8ee685d9db04d575ceabee869b9e948684c2 (patch)
tree640989d4c69924602f7bf4b404419077b02536fa /recipeBuddy/src/app/add-recipe
parentaeb7bfe5c46a4bb146d0e28560c535d6e7e3ef2d (diff)
Add convert form data to Recipe Object
Diffstat (limited to 'recipeBuddy/src/app/add-recipe')
-rw-r--r--recipeBuddy/src/app/add-recipe/add-recipe.component.ts46
1 files changed, 45 insertions, 1 deletions
diff --git a/recipeBuddy/src/app/add-recipe/add-recipe.component.ts b/recipeBuddy/src/app/add-recipe/add-recipe.component.ts
index b0e5ce5..eaa45d2 100644
--- a/recipeBuddy/src/app/add-recipe/add-recipe.component.ts
+++ b/recipeBuddy/src/app/add-recipe/add-recipe.component.ts
@@ -5,6 +5,12 @@ import { FormControl } from '@angular/forms';
import { FormBuilder } from '@angular/forms';
import { FormArray } from '@angular/forms';
+import { Recipe } from '../DataModels/recipe';
+import { Ingredient } from '../DataModels/ingredient'
+import { Step } from '../DataModels/step';
+import { BackendService } from '../REST_service/backend.service';
+
+
@Component({
selector: 'app-add-recipe',
templateUrl: './add-recipe.component.html',
@@ -34,7 +40,9 @@ export class AddRecipeComponent {
tags: [''],
photos: ['']
});
- constructor(private fb: FormBuilder) { }
+ constructor(private fb: FormBuilder,
+ private restService: BackendService
+ ) { }
ngOnInit() {
}
@@ -65,4 +73,40 @@ export class AddRecipeComponent {
})
);
}
+
+ onSubmit() {
+ console.log('In Submit')
+ var formData = this.recipeForm.value;
+
+ var ingredients = []
+ var i;
+ for (i = 0; i < formData.ingredients.length; i++) {
+ ingredients.push(new Ingredient(formData.ingredients[0].ingrName,
+ formData.ingredients[0].amount,
+ formData.ingredients[0].unit,
+ ""
+ ));
+ }
+
+ var steps = []
+ for (i = 0; i < formData.ingredients.length; i++) {
+ steps.push(new Step(formData.steps[0].instruct,
+ formData.steps[0].timer
+ ));
+ }
+
+ var recipe = new Recipe (0, //id
+ formData.recipeName, //name
+ formData.desc, //description
+ ingredients, //ingredients
+ steps, //steps
+ formData.servingSize, //servingSize
+ formData.cookTime, //cookTime
+ 0, //timesCooked
+ 0, //rating
+ formData.tags, //tags
+ formData.photos //photos
+ );
+ console.log(JSON.stringify(recipe))
+ }
}