basis-stack/basis

View on GitHub
packages/client/src/modules/core/reducers/index.js

Summary

Maintainability
A
0 mins
Test Coverage
import * as actionTypes from '../constants/actionTypes';

const getInitialState = theme => ({

  config: undefined,
  theme,
  isBusy: false
});

export default theme => (state = getInitialState(theme), action) => {

  switch (action.type) {

    case actionTypes.INITIALISE: {

      return {
        ...state,
        config: action.config
      };
    }

    case actionTypes.CHANGE_THEME: {

      return {
        ...state,
        theme: action.theme
      };
    }

    case actionTypes.TOGGLE_BUSY: {

      return {
        ...state,
        isBusy: !state.isBusy
      };
    }

    default: {
      return state;
    }
  }
};