-
-
Save rahulraghavankklm/ba31466f94b51d101094239409b6109a 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
| export const expenseFormPlugin = (state, action) => { | |
| if (action.type === '@@redux-form/CHANGE' && action.meta && action.meta.form === 'expenseForm' && action.meta.field) { | |
| if (action.meta.field === 'time' || action.meta.field === 'rate') { | |
| const time = state.values.time? parseInt(state.values.time, 10) : 0 | |
| const rate = state.values.rate ? parseInt(state.values.rate, 10): 0 | |
| const total = time * rate | |
| return { | |
| ...state, | |
| values: { | |
| ...state.values, | |
| total: total | |
| } | |
| } | |
| } | |
| } | |
| return state | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment