+
Zutaten
diff --git a/packages/frontend/src/app/modules/domain/recipe/components/recipe/recipe.component.ts b/packages/frontend/src/app/modules/domain/recipe/components/recipe/recipe.component.ts
index 9c4f73c..b1dc611 100644
--- a/packages/frontend/src/app/modules/domain/recipe/components/recipe/recipe.component.ts
+++ b/packages/frontend/src/app/modules/domain/recipe/components/recipe/recipe.component.ts
@@ -1,6 +1,8 @@
import { Component, OnInit, Input, HostBinding } from '@angular/core';
+import { BehaviorSubject, Observable } from 'rxjs';
+import { map } from 'rxjs/operators';
-import { Recipe } from '@overckd/domain';
+import { Recipe, IngredientGroup } from '@overckd/domain';
/**
* Component to display a recipe
@@ -15,6 +17,9 @@ export class RecipeComponent implements OnInit {
@Input() recipe: Recipe;
@Input() numberOfLines = 5;
+ public recipe$: BehaviorSubject
;
+ public ingredients$: Observable;
+
/**
* This is the target amount for the portion size
*/
@@ -35,7 +40,24 @@ export class RecipeComponent implements OnInit {
constructor() {}
- ngOnInit() {}
+ ngOnInit() {
+ this.recipe$ = new BehaviorSubject(this.recipe);
+
+ this.ingredients$ = this.recipe$.pipe(
+ map(recipe => {
+ const { groups } = recipe;
+ const ingredientGroups = groups
+ ? groups.map(g => ({
+ label: g.label,
+ group: g.name,
+ ingredients: g.ingredients,
+ }))
+ : [];
+
+ return [...ingredientGroups, ...recipe.ingredients];
+ }),
+ );
+ }
get primaryImage() {
return this.recipe.images[0];