diff --git a/src/reducers/stateReducer.epochs.js b/src/reducers/stateReducer.epochs.js index 324d57c..fb0ee20 100644 --- a/src/reducers/stateReducer.epochs.js +++ b/src/reducers/stateReducer.epochs.js @@ -11,14 +11,15 @@ export type epochAction = { } export const addEpoch = (state: stateType, action: epochAction): stateType => { - const newEpoch = { ...action.value, changes: ['']}; + const newEpoch = { name: action.value.name, changes: action.value.changes || [''] }; return {...state, epochs: [...state.epochs, newEpoch]} } export const setEpoch = (state: stateType, action: epochAction): stateType => { - let mutatedEpochs = state.epochs; - const index = action.value.index - if (!index) return state; + const index = action.value.index; + if (typeof index !== 'number') return state; + + const mutatedEpochs = state.epochs; mutatedEpochs[index].name = action.value.name ? action.value.name : mutatedEpochs[index].name;