settings.js 731 B

1234567891011121314151617181920212223242526272829303132
  1. import {
  2. SET_DOMAIN,
  3. SET_APIKEY,
  4. DELETE_DOMAIN,
  5. SHOW_DOMAIN_INPUT,
  6. UNAUTH_USER,
  7. } from '../actions/actionTypes';
  8. const initialState = {
  9. apikey: '',
  10. customDomain: '',
  11. domainInput: true,
  12. };
  13. const settings = (state = initialState, action) => {
  14. switch (action.type) {
  15. case SET_DOMAIN:
  16. return { ...state, customDomain: action.payload, domainInput: false };
  17. case SET_APIKEY:
  18. return { ...state, apikey: action.payload };
  19. case DELETE_DOMAIN:
  20. return { ...state, customDomain: '', domainInput: true };
  21. case SHOW_DOMAIN_INPUT:
  22. return { ...state, domainInput: true };
  23. case UNAUTH_USER:
  24. return initialState;
  25. default:
  26. return state;
  27. }
  28. };
  29. export default settings;