vn-verdnaturachat/app/reducers/server.js

41 lines
717 B
JavaScript
Raw Normal View History

import { SERVER } from '../actions/actionsTypes';
const initialState = {
connecting: false,
connected: false,
errorMessage: '',
failure: false,
server: ''
};
export default function server(state = initialState, action) {
switch (action.type) {
case SERVER.REQUEST:
2017-11-13 12:58:35 +00:00
return {
...state,
connecting: true,
failure: false
};
case SERVER.SUCCESS:
2017-11-13 12:58:35 +00:00
return {
...state,
connecting: false,
connected: true,
failure: false
};
case SERVER.FAILURE:
2017-11-13 12:58:35 +00:00
return {
...state,
connecting: false,
connected: false,
failure: true,
errorMessage: action.err
};
case SERVER.SELECT:
return { ...state, server: action.server };
default:
return state;
}
}