reverse-proxy-frontend/src/features/session/reducers.js

38 lines
978 B
JavaScript
Raw Normal View History

2020-05-14 02:06:14 +03:00
import * as types from "./actionTypes";
import initialState from "../../redux/reducers/initialState";
export function sessionsReducer(state = initialState.sessions, action) {
switch (action.type) {
case types.LOAD_SERVER_SESSIONS_STARTED:
return Object.assign([], { loading: true, loaded: false });
case types.LOAD_SERVER_SESSIONS_SUCCESS:
return Object.assign(action.payload, { loading: false, loaded: true });
default:
return state;
}
}
export function forwardsReducer(state = initialState.forwards, action) {
switch (action.type) {
case types.LOAD_SESSION_FORWARDS_STARTED:
return {
...state,
[action.id]: Object.assign([], { loading: true, loaded: false })
};
case types.LOAD_SESSION_FORWARDS_SUCCESS:
return {
...state,
[action.id]: Object.assign(action.payload, {
loading: false,
loaded: true
})
};
default:
return state;
}
}