summaryrefslogtreecommitdiff
path: root/recipeBuddy
diff options
context:
space:
mode:
Diffstat (limited to 'recipeBuddy')
-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))
+ }
}