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

61 lines
1.4 KiB
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;
}
}
2021-05-13 01:30:34 +03:00
export function optionsReducer(state = initialState.options, action) {
switch (action.type) {
case types.LOAD_FORWARD_OPTIONS_STARTED:
return {
...state,
[action.id]: { loading: true, loaded: false }
};
case types.LOAD_FORWARD_OPTIONS_SUCCESS:
return {
...state,
[action.id]: {
...action.payload,
loading: false,
loaded: true
}
};
default:
return state;
}
}