Skip to content

Instantly share code, notes, and snippets.

@iamdey
Last active April 11, 2016 08:32
Show Gist options
  • Save iamdey/9c186dc6865668626d00775963f79bd1 to your computer and use it in GitHub Desktop.
Save iamdey/9c186dc6865668626d00775963f79bd1 to your computer and use it in GitHub Desktop.
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