Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export default (state = {}, action) => {
- switch (action.type) {
- // LOGIN => got login response => turn off loading state, put errors in state
- case 'LOGIN':
- return {
- ...state,
- inProgress: false,
- errors: action.error ? action.payload.errors : null
- };
- // ASYNC_START => made http request => set loading state
- case 'ASYNC_START':
- if (action.subtype === 'LOGIN' || action.subtype === 'REGISTER') {
- return { ...state, inProgress: true };
- }
- break;
- // UPDATE_FIELD_AUTH => new value in form field => update value in state
- case 'UPDATE_FIELD_AUTH':
- return { ...state, [action.key]: action.value };
- default:
- return state;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment