Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

reducer.js 1012B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import {
  2. ReducerRegistry
  3. } from '../base/redux';
  4. import {
  5. CANCEL_FEEDBACK,
  6. SUBMIT_FEEDBACK_ERROR,
  7. SUBMIT_FEEDBACK_SUCCESS
  8. } from './actionTypes';
  9. const DEFAULT_STATE = {
  10. message: '',
  11. // The sentinel value -1 is used to denote no rating has been set and to
  12. // preserve pre-redux behavior.
  13. score: -1,
  14. submitted: false
  15. };
  16. /**
  17. * Reduces the Redux actions of the feature features/feedback.
  18. */
  19. ReducerRegistry.register(
  20. 'features/feedback',
  21. (state = DEFAULT_STATE, action) => {
  22. switch (action.type) {
  23. case CANCEL_FEEDBACK: {
  24. return {
  25. ...state,
  26. message: action.message,
  27. score: action.score
  28. };
  29. }
  30. case SUBMIT_FEEDBACK_ERROR:
  31. case SUBMIT_FEEDBACK_SUCCESS: {
  32. return {
  33. ...state,
  34. message: '',
  35. score: -1,
  36. submitted: true
  37. };
  38. }
  39. }
  40. return state;
  41. });