Skip to content

Instantly share code, notes, and snippets.

@shotaK
Created October 2, 2017 18:17
Show Gist options
  • Save shotaK/af8c5f3c348cbab2e75fcd322bc2e00c to your computer and use it in GitHub Desktop.
Save shotaK/af8c5f3c348cbab2e75fcd322bc2e00c to your computer and use it in GitHub Desktop.
export default function reducer(state=initialState, action) {
switch(action.type) {
case defs.MAKE_PAYMENT_SUCCESS:
return state.withMutations(s =>
s.set('modalOpen', false)
.set('loading', false)
.setIn(['loans', action.loan.id], Immutable.fromJS(action.loan))
)
case defs.MAKE_PAYMENT_FAILED:
return state.withMutations(s =>
s.set('modalOpen', false)
.set('loading', false)
.set('paymentError', action.error)
)
// ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment