stitch-ui
Version:
50 lines (40 loc) • 1.16 kB
JavaScript
import { createReducer } from "redux-act";
import { List } from "immutable";
import * as actions from "./actions";
export default createReducer(
{
[actions.initLogs]: state => ({
...state,
entries: new List(),
loadingLogs: false,
error: null
}),
[actions.loadLogsActions.req]: state => ({ ...state, loadingLogs: true }),
[actions.loadLogsActions.fail]: (state, { error }) => ({
...state,
error,
loadingLogs: false
}),
[actions.loadLogsActions.rcv]: (state, { payload }) => ({
...state,
error: null,
loadingLogs: false,
entries: payload
}),
[actions.setBefore]: (state, before) => ({ ...state, before }),
[actions.setAfter]: (state, after) => ({ ...state, after }),
[actions.setErrorsOnly]: (state, errorsOnly) => ({ ...state, errorsOnly }),
[actions.setUserId]: (state, userId) => ({ ...state, userId }),
[actions.setCoId]: (state, coId) => ({ ...state, coId })
},
{
entries: new List(),
errorsOnly: false,
before: null,
after: null,
userId: "",
coId: "",
loadingLogs: false,
error: null
}
);