This commit is contained in:
mgabdev
2020-04-01 23:17:21 -04:00
parent 1a33759e19
commit 80d41b8d94
50 changed files with 1771 additions and 610 deletions

View File

@@ -2,32 +2,32 @@ import {
GROUP_FETCH_SUCCESS,
GROUP_FETCH_FAIL,
GROUPS_FETCH_SUCCESS,
} from '../actions/groups';
import { GROUP_UPDATE_SUCCESS } from '../actions/group_editor';
import { Map as ImmutableMap, fromJS } from 'immutable';
} from '../actions/groups'
import { GROUP_UPDATE_SUCCESS } from '../actions/group_editor'
import { Map as ImmutableMap, fromJS } from 'immutable'
const initialState = ImmutableMap();
const initialState = ImmutableMap()
const normalizeGroup = (state, group) => state.set(group.id, fromJS(group));
const normalizeGroup = (state, group) => state.set(group.id, fromJS(group))
const normalizeGroups = (state, groups) => {
groups.forEach(group => {
state = normalizeGroup(state, group);
});
state = normalizeGroup(state, group)
})
return state;
};
return state
}
export default function groups(state = initialState, action) {
switch(action.type) {
case GROUP_FETCH_SUCCESS:
case GROUP_UPDATE_SUCCESS:
return normalizeGroup(state, action.group);
return normalizeGroup(state, action.group)
case GROUPS_FETCH_SUCCESS:
return normalizeGroups(state, action.groups);
return normalizeGroups(state, action.groups)
case GROUP_FETCH_FAIL:
return state.set(action.id, false);
return state.set(action.id, false)
default:
return state;
return state
}
};
}