|
|
|
@ -26,14 +26,18 @@ export class RecipeService {
|
|
|
|
|
const deletedRecipe = recipes.find(recipe => recipe.id === recipeId);
|
|
|
|
|
|
|
|
|
|
if (deletedRecipe) {
|
|
|
|
|
// Remove the recipe from recipes array
|
|
|
|
|
recipes = recipes.filter(recipe => recipe.id !== recipeId);
|
|
|
|
|
localStorage.setItem(this.localStorageKey, JSON.stringify(recipes));
|
|
|
|
|
|
|
|
|
|
// Remove associated IngredientRecipe objects
|
|
|
|
|
// Supprimer les IngredientRecipe associés
|
|
|
|
|
let ingredientRecipes = this.getIngredientRecipes(recipeId);
|
|
|
|
|
ingredientRecipes = ingredientRecipes.filter(ir => ir.idRecipe !== recipeId);
|
|
|
|
|
localStorage.setItem(this.ingredientRecipeKey, JSON.stringify(ingredientRecipes));
|
|
|
|
|
|
|
|
|
|
// Mettre à jour les commandes en cours
|
|
|
|
|
let currentOrders = this.getCurrentOrders();
|
|
|
|
|
currentOrders = currentOrders.filter(order => order.id !== recipeId);
|
|
|
|
|
localStorage.setItem(this.currentOrdersKey, JSON.stringify(currentOrders));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|