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.

userReducer.js 754B

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