Progress
This commit is contained in:
@@ -1,22 +1,23 @@
|
||||
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||
import { GROUPS_FETCH_SUCCESS } from '../actions/groups';
|
||||
import { Map as ImmutableMap, List as ImmutableList } from 'immutable'
|
||||
import { GROUPS_FETCH_SUCCESS } from '../actions/groups'
|
||||
|
||||
const initialState = ImmutableMap({
|
||||
new: ImmutableList(),
|
||||
featured: ImmutableList(),
|
||||
member: ImmutableList(),
|
||||
admin: ImmutableList(),
|
||||
});
|
||||
})
|
||||
|
||||
const normalizeList = (state, type, id, groups) => {
|
||||
return state.set(type, ImmutableList(groups.map(item => item.id)));
|
||||
};
|
||||
return state.set(type, ImmutableList(groups.map(item => item.id)))
|
||||
}
|
||||
|
||||
export default function groupLists(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
case GROUPS_FETCH_SUCCESS:
|
||||
return normalizeList(state, action.tab, action.id, action.groups);
|
||||
if (!action.tab) return state
|
||||
return normalizeList(state, action.tab, action.id, action.groups)
|
||||
default:
|
||||
return state;
|
||||
return state
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user