Last active
April 11, 2016 08:32
-
-
Save iamdey/9c186dc6865668626d00775963f79bd1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const SignListByIdReducer = (state = { }, action) => { | |
switch (action.type) { | |
case actions.SUBMIT_EMAIL: | |
return Object.assign({}, state, { | |
[action.id]: { | |
id: action.id, | |
email: action.email, | |
list: action.list, | |
loading: true, | |
errors: [], | |
} | |
}); | |
case actions.EMAIL_ADDED: | |
console.log('EMAIL_ADDED', state, action); | |
return Object.assign({}, state, { | |
[action.id]: Object.assign({}, state[action.id], { | |
loading: false, | |
errors: [], | |
}), | |
}); | |
case actions.FAIL_TO_ADD: | |
return Object.assign({}, state, { | |
[action.id]: Object.assign({}, state[action.id], { | |
loading: false, | |
errors: action.errors, | |
}), | |
}); | |
default: | |
return state; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment