scinote-web/app/javascript/packs/shared/reducers/TeamReducers.js

20 lines
530 B
JavaScript
Raw Normal View History

2017-08-09 21:21:02 +08:00
import { SET_CURRENT_TEAM, GET_LIST_OF_TEAMS } from "../../app/action_types";
2017-08-02 23:27:05 +08:00
2017-08-09 18:46:04 +08:00
const initialState = { name: "", id: 0, current_team: true };
2017-08-08 21:44:28 +08:00
export const setCurrentTeam = (state = initialState, action) => {
2017-08-02 23:27:05 +08:00
if (action.type === SET_CURRENT_TEAM) {
return Object.assign({}, state, action.team);
2017-08-03 22:03:15 +08:00
}
return state;
};
2017-08-25 14:54:32 +08:00
export const getListOfTeams = (state = { collection: [] }, action) => {
2017-08-03 22:03:15 +08:00
if (action.type === GET_LIST_OF_TEAMS) {
2017-08-25 14:54:32 +08:00
return {
...state,
collection: action.payload
};
2017-08-02 23:27:05 +08:00
}
return state;
};