Переглянути джерело

Add recipe name to shopping cart items

Tatiana Inama 7 роки тому
батько
коміт
635092313d

+ 16 - 8
recipes/src/containers/ShoppingCart/reducers.ts

@@ -15,7 +15,8 @@ const initialState: ShoppingCartState = {
         unit: 'g',
         _original: '4 6oz Chicken Breast',
         suggestions: [],
-        recipeId: '5d37045aef8ef87af296cba7'
+        recipeId: '5d37045aef8ef87af296cba7',
+        recipeName: 'Sunday Night Chicken Parm'
       },
       {
         name: 'eggs',
@@ -23,7 +24,8 @@ const initialState: ShoppingCartState = {
         unit: '',
         _original: '2 Eggs',
         suggestions: [],
-        recipeId: '5d37045aef8ef87af296cba7'
+        recipeId: '5d37045aef8ef87af296cba7',
+        recipeName: 'Sunday Night Chicken Parm'
       },
       {
         name: 'freshly grated parm',
@@ -31,7 +33,8 @@ const initialState: ShoppingCartState = {
         unit: '',
         _original: 'Freshly Grated Parm',
         suggestions: [],
-        recipeId: '5d37045aef8ef87af296cba7'
+        recipeId: '5d37045aef8ef87af296cba7',
+        recipeName: 'Sunday Night Chicken Parm'
       },
       {
         name: 'bread crumbs',
@@ -54,7 +57,8 @@ const initialState: ShoppingCartState = {
             measure: 2
           }
         ],
-        recipeId: '5d37045aef8ef87af296cba7'
+        recipeId: '5d37045aef8ef87af296cba7',
+        recipeName: 'Sunday Night Chicken Parm'
       },
       {
         name: 'salt and pepper, to taste',
@@ -62,21 +66,24 @@ const initialState: ShoppingCartState = {
         unit: '',
         _original: 'Salt and Pepper, to taste',
         suggestions: [],
-        recipeId: '5d37045aef8ef87af296cba7'
+        recipeId: '5d37045aef8ef87af296cba7',
+        recipeName: 'Sunday Night Chicken Parm'
       },
       {
         name: 'light olive oil for shallow frying',
         quantity: 0,
         unit: '',
         _original: 'Light Olive Oil for shallow Frying',
-        recipeId: '5d37045aef8ef87af296cba7'
+        recipeId: '5d37045aef8ef87af296cba7',
+        recipeName: 'Sunday Night Chicken Parm'
       },
       {
         name: 'olive oil',
         quantity: 3,
         unit: 'tbsp',
         _original: '3 Tbsp of Olive Oil',
-        recipeId: '5d37045aef8ef87af296cba7'
+        recipeId: '5d37045aef8ef87af296cba7',
+        recipeName: 'Sunday Night Chicken Parm'
       },
     ],
     recipesId: [
@@ -90,7 +97,8 @@ const getIngredients = (recipe: DBRecipe): ShoppingItem[] => {
       ...ingredients,
       ...subRecipe.ingredients.map(ingredient => ({
         ...ingredient,
-        recipeId: recipe._id
+        recipeId: recipe._id,
+        recipeName: recipe.name
       })),
     ]
   }, [] as ShoppingItem[])

+ 1 - 0
recipes/src/types/shopping-cart.ts

@@ -2,6 +2,7 @@ import Recipe, { Ingredient } from './recipes';
 
 interface ShoppingItem extends Ingredient {
   recipeId: string,
+  recipeName?: string
 }
 
 export default ShoppingItem;