Commit 0c0ab55e authored by Jure's avatar Jure
Browse files

Merge branch 'fix-team-delete' into 'master'

Fix teams reducer for delete action

See merge request !127
parents 6482f315 ef1b9169
Pipeline #3076 canceled with stage
......@@ -9,7 +9,7 @@ import {
import clone from 'lodash/clone'
import findIndex from 'lodash/findIndex'
import difference from 'lodash/difference'
import differenceBy from 'lodash/differenceBy'
import unionBy from 'lodash/unionBy'
export default function(state = [], action) {
......@@ -26,11 +26,6 @@ export default function(state = [], action) {
return teams
}
function removeTeams() {
const todel = action.teams || [action.team]
return difference(state, todel)
}
switch (action.type) {
case CREATE_TEAM_SUCCESS:
case UPDATE_TEAM_SUCCESS:
......@@ -38,7 +33,7 @@ export default function(state = [], action) {
case GET_TEAMS_SUCCESS:
return clone(action.teams)
case DELETE_TEAM_SUCCESS:
return removeTeams()
return differenceBy(state, [action.team], 'id')
case LOGOUT_SUCCESS:
return []
case GET_COLLECTION_TEAMS_SUCCESS:
......
......@@ -39,7 +39,7 @@ describe('teams reducers', () => {
it('deleteTeam success', () => {
const actual = reducer(mockstate, {
type: T.DELETE_TEAM_SUCCESS,
team: mockteam,
team: { ...mockteam },
})
expect(actual).toEqual([])
})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment