You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334353637
  1. import createReducer from "../../utils/createReducer";
  2. import {
  3. RESET_USER_STATE,
  4. SET_USER,
  5. SET_USER_ERROR,
  6. } from "../../actions/user/userActionConstants";
  7. const initialState = {
  8. user: {},
  9. };
  10. export default createReducer(
  11. {
  12. [SET_USER]: setUser,
  13. [SET_USER_ERROR]: setUserError,
  14. [RESET_USER_STATE]: resetUser,
  15. },
  16. initialState
  17. );
  18. function setUser(state, action) {
  19. return {
  20. ...state,
  21. user: action.payload,
  22. };
  23. }
  24. function setUserError(state, action) {
  25. return {
  26. ...state,
  27. errorMessage: action.payload,
  28. };
  29. }
  30. function resetUser() {
  31. return initialState;
  32. }