Skip to content
Snippets Groups Projects
Commit 6be38c77 authored by Alexandru Munteanu's avatar Alexandru Munteanu
Browse files

feat(manusript-details): show make recommendation only when required

parent 0bcc0598
No related branches found
No related tags found
1 merge request!10Sprint #12
import React from 'react'
import { th, Icon } from '@pubsweet/ui'
import { get } from 'lodash'
import { connect } from 'react-redux'
import styled from 'styled-components'
import { th, Icon } from '@pubsweet/ui'
import { compose, withProps } from 'recompose'
import ZipFiles from 'pubsweet-components-faraday/src/components/Files/ZipFiles'
import { Recommendation } from 'pubsweet-components-faraday/src/components/MakeRecommendation'
import { MakeDecision } from './'
const SideBarActions = ({ project, version, currentUserIs }) => (
const SideBarActions = ({
project,
version,
currentUserIs,
canMakeRecommendation,
}) => (
<Root>
{currentUserIs('adminEiC') && <MakeDecision />}
{currentUserIs('isHE') && (
{canMakeRecommendation && (
<Recommendation
collectionId={project.id}
fragmentId={version.id}
......@@ -28,7 +36,27 @@ const SideBarActions = ({ project, version, currentUserIs }) => (
</Root>
)
export default SideBarActions
const isHEToManuscript = (state, collectionId) => {
const currentUserId = get(state, 'currentUser.user.id')
const collections = get(state, 'collections') || []
const collection = collections.find(c => c.id === collectionId) || {}
const collectionInvitations = get(collection, 'invitations') || []
const userInvitation = collectionInvitations.find(
i => i.role === 'handlingEditor' && i.userId === currentUserId,
)
return userInvitation ? userInvitation.isAccepted : false
}
export default compose(
connect((state, { project }) => ({
isHEToManuscript: isHEToManuscript(state, project.id),
})),
withProps(({ isHEToManuscript, project }) => ({
canMakeRecommendation:
isHEToManuscript && get(project, 'status') === 'reviewCompleted',
})),
)(SideBarActions)
// #region styled-components
const Root = styled.div`
......
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