Created
February 20, 2019 09:22
-
-
Save charisschomba/c2feb2f6e04b90b3d6052778021aa84b 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
import { | |
REGISTER_USER, | |
REGISTER_ERROR, | |
REGISTER_SUCCESS, | |
} from '../../../constants/users'; | |
const initialState = { | |
status: false, | |
success: false, | |
isRegistering: false, | |
}; | |
const reducer = (state = initialState, action) => { | |
switch (action.type) { | |
case REGISTER_USER: { | |
return { ...state, isRegistering: true, status: false }; | |
} | |
case REGISTER_SUCCESS: { | |
return { | |
...state, | |
user: action.payload, | |
status: false, | |
success: true, | |
isRegistering: false, | |
}; | |
} | |
case REGISTER_ERROR: { | |
return { | |
...state, | |
errors: action.payload, | |
isRegistering: false, | |
status: true, | |
}; | |
} | |
default: | |
return state; | |
} | |
}; | |
export default reducer; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment