Created
August 8, 2019 15:33
-
-
Save TheeBryanWhite/c8e7900bd09b9e1d2cee6a44cb6816dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ROOT REDUCER | |
function rootReducer(state = initialState, action) { | |
switch (action.type) { | |
case STORE_EXERCISE: | |
return Object.assign({}, state, { | |
workoutToSave: state.workoutToSave.map((workout, index) => { | |
if (index === action.payload.index) { | |
return {exercise: action.payload.exercise}; | |
} else { | |
return {exercise: { id: action.payload.exercise.id}}; | |
} | |
}) | |
}); | |
break; | |
default: | |
return state; | |
} | |
} | |
// THE ACTION | |
// Nothing funky | |
export const storeExerciseData = (exercise) => { | |
return { | |
type: STORE_EXERCISE, | |
payload: exercise | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment