diff --git a/src/app/ingredients/ingredients.component.ts b/src/app/ingredients/ingredients.component.ts index 660c32d..5039b0e 100644 --- a/src/app/ingredients/ingredients.component.ts +++ b/src/app/ingredients/ingredients.component.ts @@ -48,5 +48,6 @@ export class IngredientsComponent { delete(ingredient: Ingredient): void { this.recipes.deleteIngredient(ingredient); + this.dataSource.data = this.recipes.getAllIngredients(); } } diff --git a/src/app/recipe-add/recipe-add.component.ts b/src/app/recipe-add/recipe-add.component.ts index 9e23cb2..a1cbf87 100644 --- a/src/app/recipe-add/recipe-add.component.ts +++ b/src/app/recipe-add/recipe-add.component.ts @@ -54,6 +54,7 @@ export class RecipeAddComponent { name: recipe.name, description: recipe.description, }); + this.ingredientEntries = recipe.ingredients; } get recipeId() { return this.#recipeId; @@ -84,7 +85,6 @@ export class RecipeAddComponent { onAddIngredient(): void { const value = this.createForm.value; - console.log(value); if (!value.selectedIngredient) { return; @@ -95,7 +95,6 @@ export class RecipeAddComponent { } this.ingredientEntries.push({ idIngredient: id, - idRecipe: -1, quantity: 1, }); } diff --git a/src/app/recipe.service.ts b/src/app/recipe.service.ts index 77b2f51..6a28ff7 100644 --- a/src/app/recipe.service.ts +++ b/src/app/recipe.service.ts @@ -12,8 +12,8 @@ export class RecipeService { description: 'La meilleure recette de pâte à crêpes', image: '', ingredients: [ - { idIngredient: 1, idRecipe: 0, quantity: 10 }, - { idIngredient: 2, idRecipe: 0, quantity: 15 }, + { idIngredient: 1, quantity: 10 }, + { idIngredient: 2, quantity: 15 }, ], }, { id: 1, name: 'crepe2', description: 'La meilleure recette de pâte à crêpes', image: '', ingredients: [] }, diff --git a/src/cookbook/type.ts b/src/cookbook/type.ts index 3003ec5..a7141a4 100644 --- a/src/cookbook/type.ts +++ b/src/cookbook/type.ts @@ -13,7 +13,6 @@ export type Recipe = { export type IngredientEntry = { idIngredient: number; - idRecipe: number; quantity: number; };