changeUser.js 922 B

1234567891011121314151617181920212223242526272829303132333435
  1. import * as actionTypes from '../../../constants/admin';
  2. import initialState from '../../initialState';
  3. export default function changeUserReducer(state = initialState.changeUser, { type, payload }) {
  4. switch (type) {
  5. case actionTypes.CHANGE_USERS_REQUEST: {
  6. return {
  7. ...state,
  8. isFetching: false,
  9. payload
  10. }
  11. }
  12. case actionTypes.CHANGE_USERS_REQUEST_SUCCESS: {
  13. const { data:{user} } = payload;
  14. return {
  15. ...state,
  16. isFetching: true,
  17. data:user
  18. }
  19. }
  20. case actionTypes.CHANGE_USERS_REQUEST_FAILURE: {
  21. const { error } = payload;
  22. return {
  23. ...state,
  24. isFetching: false,
  25. error
  26. }
  27. }
  28. default: {
  29. return state;
  30. }
  31. }
  32. }