export default {
  name: "theme",

  getReducer: () => {
    const initialData = {
      theme: "bg-blue-chambray",
      iconSize: "default",
    };
    return (state = initialData, { type, payload }) => {
      switch (type) {
        case "THEME_CHANGED":
        case "THEME_SET_LARGER_ICONS":
          return Object.assign({}, state, payload);
        default:
          return state;
      }
    };
  },

  doThemeSet: (theme) => ({ dispatch }) => {
    dispatch({
      type: "THEME_CHANGED",
      payload: {
        theme: theme,
      },
    });
  },

  doThemeSetLargeIcons: () => ({ dispatch }) => {
    dispatch({
      type: "THEME_SET_LARGER_ICONS",
      payload: {
        iconSize: "large",
      },
    });
  },

  selectTheme: (state) => {
    return state.theme.theme;
  },

  selectThemeIconSize: (state) => {
    return state.theme.iconSize;
  },
};
