38 lines
978 B
JavaScript
38 lines
978 B
JavaScript
|
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;
|
||
|
}
|
||
|
}
|