diff --git a/src/app/home/home.component.html b/src/app/home/home.component.html
index f85c800..4a852a8 100644
--- a/src/app/home/home.component.html
+++ b/src/app/home/home.component.html
@@ -1,5 +1,11 @@
Projet Recipe
+
Commandes en cours
+
+ -
+ {{ recipe.name }}
+
+
Bienvenue sur Recipe
diff --git a/src/app/home/home.component.ts b/src/app/home/home.component.ts
index deb69c4..afcc3ff 100644
--- a/src/app/home/home.component.ts
+++ b/src/app/home/home.component.ts
@@ -1,12 +1,22 @@
-import { Component } from '@angular/core';
+import { Component, OnInit } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { Recipe } from '../models/recipe';
+import { RecipeService } from '../services/recipe.service';
@Component({
selector: 'app-home',
standalone: true,
- imports: [],
+ imports: [CommonModule],
templateUrl: './home.component.html',
styleUrl: './home.component.scss'
})
-export class HomeComponent {
+export class HomeComponent implements OnInit {
+ currentOrders: Recipe[] = [];
+ constructor(private recipeService: RecipeService) {}
+
+ ngOnInit(): void {
+ // Charger les commandes en cours depuis le service
+ this.currentOrders = this.recipeService.getCurrentOrders();
+ }
}
diff --git a/src/app/recipe-list/recipe-list.component.html b/src/app/recipe-list/recipe-list.component.html
index 7ee5e93..1373591 100644
--- a/src/app/recipe-list/recipe-list.component.html
+++ b/src/app/recipe-list/recipe-list.component.html
@@ -42,6 +42,9 @@
Show |
+
diff --git a/src/app/recipe-list/recipe-list.component.ts b/src/app/recipe-list/recipe-list.component.ts
index af2769b..08e4da0 100644
--- a/src/app/recipe-list/recipe-list.component.ts
+++ b/src/app/recipe-list/recipe-list.component.ts
@@ -52,4 +52,8 @@ export class RecipeListComponent implements OnInit {
this.recipes = this.recipeService.getRecipes();
this.dataSource.data = this.recipes;
}
+
+ onOrderRecipe(recipe: Recipe): void {
+ this.recipeService.orderRecipe(recipe);
+ }
}
diff --git a/src/app/services/recipe.service.ts b/src/app/services/recipe.service.ts
index 5f164b9..55c562e 100644
--- a/src/app/services/recipe.service.ts
+++ b/src/app/services/recipe.service.ts
@@ -8,6 +8,7 @@ import { IngredientRecipe } from '../models/ingredient-recipe';
export class RecipeService {
private localStorageKey = 'recipes';
private ingredientRecipeKey = 'ingredientRecipes';
+ private currentOrdersKey = 'currentOrders';
getRecipes(): Recipe[] {
const recipesJson = localStorage.getItem(this.localStorageKey);
@@ -55,4 +56,15 @@ export class RecipeService {
);
return ingredientRecipe ? ingredientRecipe.quantity : 0;
}
+
+ orderRecipe(recipe: Recipe): void {
+ let currentOrders: Recipe[] = JSON.parse(localStorage.getItem(this.currentOrdersKey) || '[]');
+ currentOrders.push(recipe);
+ localStorage.setItem(this.currentOrdersKey, JSON.stringify(currentOrders));
+ }
+
+ getCurrentOrders(): Recipe[] {
+ const currentOrdersJson = localStorage.getItem(this.currentOrdersKey);
+ return currentOrdersJson ? JSON.parse(currentOrdersJson) : [];
+ }
}
|