Commit 91af56a0 authored by Alf Eaton's avatar Alf Eaton
Browse files

Merge branch 'object-spread' into 'master'

Use spread operator instead of Object.assign

See merge request !75
parents a4b62ef2 c7473f76
Pipeline #1846 passed with stage
in 3 minutes and 43 seconds
......@@ -10,23 +10,26 @@ export default function (state = {
}, action) {
switch (action.type) {
case GET_CURRENT_USER_REQUEST:
return Object.assign({}, state, {
return {
...state,
isFetching: true,
isAuthenticated: false
})
}
case GET_CURRENT_USER_SUCCESS:
return Object.assign({}, state, {
return {
...state,
isFetching: false,
isAuthenticated: true,
user: action.user
})
}
case GET_CURRENT_USER_FAILURE:
return Object.assign({}, state, {
return {
...state,
isFetching: false,
isAuthenticated: false
})
}
case LOGOUT_SUCCESS:
return {
......
......@@ -8,14 +8,16 @@ export default function (state = {
}, action) {
switch (action.type) {
case FILE_UPLOAD_SUCCESS:
return Object.assign({}, state, {
return {
...state,
isFetching: false,
file: action.file
})
}
case FILE_UPLOAD_REQUEST:
return Object.assign({}, state, {
return {
...state,
isFetching: true
})
}
default:
return state
}
......
......@@ -16,7 +16,7 @@ const updatedUsers = (users, data) => {
if (index === -1) {
users.push(data)
} else {
users[index] = Object.assign(users[index], data)
users[index] = {...users[index], ...data}
}
return users
......@@ -29,32 +29,37 @@ export default (state = {
}, action) => {
switch (action.type) {
case GET_USERS_REQUEST:
return Object.assign({}, state, {
return {
...state,
isFetching: true
})
}
case GET_USERS_SUCCESS:
return Object.assign({}, state, {
return {
...state,
isFetching: false,
users: action.users
})
}
case GET_USER_SUCCESS:
return Object.assign({}, state, {
return {
...state,
isFetching: false,
users: updatedUsers(state.users, action.user)
})
}
case UPDATE_USER_REQUEST:
return Object.assign({}, state, {
return {
...state,
isFetching: true
})
}
case UPDATE_USER_SUCCESS:
return Object.assign({}, state, {
return {
...state,
isFetching: false,
users: updatedUsers(state.users, action.user)
})
}
case LOGOUT_SUCCESS:
return {
......
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