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.

reducer.js 988B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // @flow
  2. import { ReducerRegistry } from '../base/redux';
  3. import {
  4. SET_GOOGLE_API_PROFILE,
  5. SET_GOOGLE_API_STATE
  6. } from './actionTypes';
  7. import { GOOGLE_API_STATES } from './constants';
  8. /**
  9. * The default state is the Google API needs loading.
  10. *
  11. * @type {{googleAPIState: number}}
  12. */
  13. const DEFAULT_STATE = {
  14. googleAPIState: GOOGLE_API_STATES.NEEDS_LOADING,
  15. profileEmail: ''
  16. };
  17. /**
  18. * Reduces the Redux actions of the feature features/google-api.
  19. */
  20. ReducerRegistry.register('features/google-api',
  21. (state = DEFAULT_STATE, action) => {
  22. switch (action.type) {
  23. case SET_GOOGLE_API_STATE:
  24. return {
  25. ...state,
  26. googleAPIState: action.googleAPIState,
  27. googleResponse: action.googleResponse
  28. };
  29. case SET_GOOGLE_API_PROFILE:
  30. return {
  31. ...state,
  32. profileEmail: action.profileEmail
  33. };
  34. }
  35. return state;
  36. });