Guest User

Untitled

a guest
Apr 24th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. import {
  2. REQUEST_REP_SEARCH,
  3. SUCCESS_REP_SEARCH,
  4. RESET_DATA,
  5. SHOW_ALERT,
  6. } from '../actions/searchReps';
  7.  
  8. const intitalState = {
  9. showLoading: false,
  10. repsFound: [],
  11. showAlert: false,
  12. };
  13.  
  14. export default (state = intitalState, action) => {
  15. switch (action.type) {
  16. case SHOW_ALERT: {
  17. return {
  18. ...state,
  19. showLoading: false,
  20. showAlert: true,
  21. };
  22. }
  23. case RESET_DATA: {
  24. return {
  25. ...state,
  26. showLoading: false,
  27. repsFound: [],
  28. showAlert: false,
  29. };
  30. }
  31. case REQUEST_REP_SEARCH: {
  32. return {
  33. ...state,
  34. repsFound: [],
  35. showLoading: true,
  36. showAlert: false,
  37. };
  38. }
  39. case SUCCESS_REP_SEARCH:
  40. return {
  41. ...state,
  42. repsFound: action.repsFound,
  43. showLoading: false,
  44. showAlert: false,
  45. };
  46.  
  47. default:
  48. return state;
  49. }
  50. };
Add Comment
Please, Sign In to add comment