31 lines
754 B
JavaScript
Raw Normal View History

2019-12-18 18:13:24 +01:00
import { fromJS } from 'immutable';
const initialState = fromJS({
initialWebhook: {},
modifiedWebhook: {},
shouldRefetchData: false,
});
const reducer = (state, action) => {
switch (action.type) {
case 'GET_DATA_SUCCEEDED':
return state
.update('initialWebhook', () => fromJS(action.data))
.update('modifiedWebhook', () => fromJS(action.data))
.update('shouldRefetchData', () => false);
2020-01-02 09:55:26 +01:00
case 'ON_CHANGE':
return state.updateIn(
['modifiedWebhook', ...action.keys],
() => action.value
);
case 'SET_ERRORS': {
return state.update('formErrors', () => fromJS(action.errors));
}
2019-12-18 18:13:24 +01:00
default:
return state;
}
};
export default reducer;
export { initialState };