canape/frontend/js/reducers/polochon.js
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

31 lines
859 B
JavaScript

import { List, Map, fromJS } from "immutable";
const defaultState = Map({
loadingPublic: false,
loadingManaged: false,
public: List(),
managed: List(),
});
const handlers = {
PUBLIC_POLOCHON_LIST_FETCH_PENDING: (state) =>
state.set("loadingPublic", true),
PUBLIC_POLOCHON_LIST_FETCH_FULFILLED: (state, action) => {
return state.merge({
loadingPublic: false,
public: List(fromJS(action.payload.response.data)),
});
},
MANAGED_POLOCHON_LIST_FETCH_PENDING: (state) =>
state.set("loadingManaged", true),
MANAGED_POLOCHON_LIST_FETCH_FULFILLED: (state, action) => {
return state.merge({
loadingManaged: false,
managed: List(fromJS(action.payload.response.data)),
});
},
};
export default (state = defaultState, action) =>
handlers[action.type] ? handlers[action.type](state, action) : state;