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