Grégoire Delattre bcadc48d5a Launch prettier with the --fix option
They've changed their default settings, this changes a lot of stuff in
our code base.
2020-04-01 17:55:34 +02:00

27 lines
786 B
JavaScript

import { Map, List, fromJS } from "immutable";
export const defaultState = Map({
fetchingModules: false,
users: List(),
stats: Map({}),
modules: Map({}),
});
const handlers = {
ADMIN_LIST_USERS_FULFILLED: (state, action) =>
state.set("users", fromJS(action.payload.response.data)),
ADMIN_GET_STATS_FULFILLED: (state, action) =>
state.set("stats", fromJS(action.payload.response.data)),
ADMIN_GET_MODULES_PENDING: (state) => state.set("fetchingModules", true),
ADMIN_GET_MODULES_FULFILLED: (state, action) =>
state.merge(
fromJS({
modules: action.payload.response.data,
fetchingModules: false,
})
),
};
export default (state = defaultState, action) =>
handlers[action.type] ? handlers[action.type](state, action) : state;