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

fix(handlingEditor): fix invite handling editor

parent 2ac1b8df
No related branches found
No related tags found
2 merge requests!58Sprint #20 - Goal - Reviewers submit report,!48Hin 934 invite he on submitted
......@@ -174,13 +174,15 @@ export const pendingHEInvitation = (state, collectionId) =>
i.role === 'handlingEditor' &&
!i.hasAnswer,
)
.value()
const parseInvitedHE = (handlingEditor = {}, state, collectionId) => ({
...handlingEditor,
name: pendingHEInvitation(state, collectionId)
? 'Invited'
: handlingEditor.name,
})
const parseInvitedHE = (handlingEditor, state, collectionId) =>
handlingEditor && {
...handlingEditor,
name: pendingHEInvitation(state, collectionId)
? 'Invited'
: handlingEditor.name,
}
const hideCustomIdStatuses = ['draft', 'technicalChecks']
export const newestFirstParseDashboard = (state, items) =>
chain(items)
......
......@@ -99,21 +99,20 @@ export default compose(
heInvitation,
resendInvitation,
revokeInvitation,
pendingInvitation,
pendingInvitation = {},
handlingEditors = [],
currentUser: { canAssignHE, id: currentUserId },
currentUser: { permissions: { canAssignHE }, id: currentUserId },
collection: { handlingEditor },
}) => () => {
if (pendingInvitation.userId === currentUserId) {
return <Text ml={1}>Invited</Text>
}
if (pendingInvitation) {
if (pendingInvitation.userId) {
const person = chain(handlingEditors)
.filter(he => he.id === pendingInvitation.userId)
.map(he => ({ ...he, name: `${he.firstName} ${he.lastName}` }))
.first()
.value()
return (
<PersonInvitation
isFetching={isFetching}
......@@ -129,6 +128,7 @@ export default compose(
if (heInvitation) {
return <Text ml={1}>{handlingEditor.name}</Text>
}
if (canAssignHE) {
return (
<Button ml={1} onClick={inviteHE} primary size="small">
......
......@@ -23,15 +23,20 @@ export const selectHandlingEditors = state =>
.filter(editor => editor.isActive && editor.isConfirmed)
.value()
const canAssignHEStatuses = ['submitted']
export const canAssignHE = (state, collectionId = '') => {
const isEIC = currentUserIs(state, 'adminEiC')
const hasHE = chain(state)
const collection = chain(state)
.get('collections', [])
.find(c => c.id === collectionId)
.get('handlingEditor')
.value()
const hasHE = get(collection, 'handlingEditor')
return isEIC && !hasHE
return (
isEIC &&
!hasHE &&
canAssignHEStatuses.includes(get(collection, 'status', 'draft'))
)
}
const editorsRequest = () => ({ type: EDITORS_REQUEST })
......
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