Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
...@@ -9,7 +9,7 @@ import { ...@@ -9,7 +9,7 @@ import {
import clone from 'lodash/clone' import clone from 'lodash/clone'
import findIndex from 'lodash/findIndex' import findIndex from 'lodash/findIndex'
import difference from 'lodash/difference' import differenceBy from 'lodash/differenceBy'
import unionBy from 'lodash/unionBy' import unionBy from 'lodash/unionBy'
export default function(state = [], action) { export default function(state = [], action) {
...@@ -26,11 +26,6 @@ export default function(state = [], action) { ...@@ -26,11 +26,6 @@ export default function(state = [], action) {
return teams return teams
} }
function removeTeams() {
const todel = action.teams || [action.team]
return difference(state, todel)
}
switch (action.type) { switch (action.type) {
case CREATE_TEAM_SUCCESS: case CREATE_TEAM_SUCCESS:
case UPDATE_TEAM_SUCCESS: case UPDATE_TEAM_SUCCESS:
...@@ -38,7 +33,7 @@ export default function(state = [], action) { ...@@ -38,7 +33,7 @@ export default function(state = [], action) {
case GET_TEAMS_SUCCESS: case GET_TEAMS_SUCCESS:
return clone(action.teams) return clone(action.teams)
case DELETE_TEAM_SUCCESS: case DELETE_TEAM_SUCCESS:
return removeTeams() return differenceBy(state, [action.team], 'id')
case LOGOUT_SUCCESS: case LOGOUT_SUCCESS:
return [] return []
case GET_COLLECTION_TEAMS_SUCCESS: case GET_COLLECTION_TEAMS_SUCCESS:
......
...@@ -39,7 +39,7 @@ describe('teams reducers', () => { ...@@ -39,7 +39,7 @@ describe('teams reducers', () => {
it('deleteTeam success', () => { it('deleteTeam success', () => {
const actual = reducer(mockstate, { const actual = reducer(mockstate, {
type: T.DELETE_TEAM_SUCCESS, type: T.DELETE_TEAM_SUCCESS,
team: mockteam, team: { ...mockteam },
}) })
expect(actual).toEqual([]) expect(actual).toEqual([])
}) })
......
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