Skip to content
Snippets Groups Projects
Commit ee4f999c authored by Bogdan Cochior's avatar Bogdan Cochior
Browse files

fix(admin): fix undefined object and user role edit

parent 909ca913
No related branches found
No related tags found
1 merge request!14Sprint #15
......@@ -7,7 +7,7 @@ export const isHEToManuscript = (state, collectionId) => {
return get(collection, 'handlingEditor.id') === currentUserId
}
export const canMakeRecommendation = (state, collection, fragment) => {
export const canMakeRecommendation = (state, collection, fragment = {}) => {
if (fragment.id !== last(collection.fragments)) return false
const isHE = isHEToManuscript(state, collection.id)
return isHE && get(collection, 'status') === 'reviewCompleted'
......@@ -58,7 +58,7 @@ export const getHERecommendation = (state, collectionId, fragmentId) => {
}
const cantMakeDecisionStatuses = ['rejected', 'published', 'draft']
export const canMakeDecision = (state, collection, fragment) => {
export const canMakeDecision = (state, collection, fragment = {}) => {
if (fragment.id !== last(collection.fragments)) return false
const status = get(collection, 'status')
......
......@@ -35,6 +35,12 @@ export const setAdmin = values => {
}
export const parseUpdateUser = values => {
const parsedValues = {
...values,
editorInChief: values.editorInChief || false,
handlingEditor: values.handlingEditor || false,
admin: values.admin || false,
}
const valuesToSave = [
'admin',
'firstName',
......@@ -48,7 +54,7 @@ export const parseUpdateUser = values => {
'username',
]
return pick(values, valuesToSave)
return pick(parsedValues, valuesToSave)
}
export const handleFormError = error => {
......@@ -71,7 +77,6 @@ const toggleUserStatus = user => {
newState = false
newUsername = `invalid***${username}`
} else {
newState = true
newUsername = replace(username, 'invalid***', '')
}
......
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