Skip to content

Instantly share code, notes, and snippets.

@intojs
Last active February 21, 2021 20:04
Show Gist options
  • Save intojs/e569ff63e86abd0854c2be1f443d72cf to your computer and use it in GitHub Desktop.
Save intojs/e569ff63e86abd0854c2be1f443d72cf to your computer and use it in GitHub Desktop.
const newsletterFormReducer = (state, action) => {
const { type, payload } = action;
switch (type) {
case actionTypes.SET_NEWSLETTERS_OPTIONS:
return {
...state,
isLoading: payload.newsletterOptions.length === 0,
fields: {
...state.fields,
newsletter: {
...state.fields.newsletter,
options: payload.newsletterOptions,
},
},
};
case actionTypes.CHANGE_FIELD:
return withValidation(state, payload.field, payload.value);
default:
return state;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment