Forráskód Böngészése

Return recipe to backlog when removed from day schedule

Tatiana Inama 7 éve
szülő
commit
2cef6c892d
1 módosított fájl, 3 hozzáadás és 1 törlés
  1. 3 1
      recipes/src/containers/Planner/reducers.ts

+ 3 - 1
recipes/src/containers/Planner/reducers.ts

@@ -60,6 +60,7 @@ const PlannerReducer = (
         backlog: state.backlog.filter(recipe => recipe._id !== action.recipe._id)
       }
     case 'REMOVE_MEAL':
+      const meal = state.planner[action.day][action.meal];
       return {
         ...state,
         planner: {
@@ -68,7 +69,8 @@ const PlannerReducer = (
             ...state.planner[action.day],
             [action.meal]: undefined
           }
-        }
+        },
+        backlog: meal ? state.backlog.concat([meal]) : state.backlog
       }
     default:
       return state