index.js 761 B

123456789101112131415161718192021222324252627282930
  1. import * as types from "../../constants/index";
  2. import initialState from '../initialState';
  3. export default function getUser(state = initialState.getUser, {type, payload: data, error }) {
  4. switch (type) {
  5. case types.USER_GET_REQUEST: {
  6. return {
  7. ...state,
  8. isFetching: true
  9. }
  10. }
  11. case types.USER_GET_REQUEST_SUCCESS: {
  12. return {
  13. ...state,
  14. isFetching: false,
  15. data
  16. }
  17. }
  18. case types.USER_GET_REQUEST_FAILURE: {
  19. return {
  20. ...state,
  21. isFetching: false,
  22. error
  23. }
  24. }
  25. default: {
  26. return state
  27. }
  28. }
  29. }