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 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import {
  2. ReducerRegistry
  3. } from '../base/redux';
  4. import {
  5. DIAL_OUT_CANCELED,
  6. DIAL_OUT_CODES_UPDATED,
  7. DIAL_OUT_SERVICE_FAILED,
  8. PHONE_NUMBER_CHECKED
  9. } from './actionTypes';
  10. const DEFAULT_STATE = {
  11. dialOutCodes: null,
  12. error: null,
  13. isDialNumberAllowed: true
  14. };
  15. ReducerRegistry.register(
  16. 'features/dial-out',
  17. (state = DEFAULT_STATE, action) => {
  18. switch (action.type) {
  19. case DIAL_OUT_CANCELED: {
  20. // if we have already downloaded codes fill them in default state
  21. // to skip another ajax query
  22. return {
  23. ...DEFAULT_STATE,
  24. dialOutCodes: state.dialOutCodes
  25. };
  26. }
  27. case DIAL_OUT_CODES_UPDATED: {
  28. return {
  29. ...state,
  30. error: null,
  31. dialOutCodes: action.response
  32. };
  33. }
  34. case DIAL_OUT_SERVICE_FAILED: {
  35. return {
  36. ...state,
  37. error: action.error
  38. };
  39. }
  40. case PHONE_NUMBER_CHECKED: {
  41. return {
  42. ...state,
  43. error: null,
  44. isDialNumberAllowed: action.response.allow
  45. };
  46. }
  47. }
  48. return state;
  49. });