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

fix(recommendation): fix recommendations authors

parent f9bb9f1d
No related branches found
No related tags found
1 merge request!10Sprint #12
......@@ -30,7 +30,7 @@ export const currentUserIs = ({ currentUser: { user } }, role) => {
export const canInviteReviewers = ({ currentUser: { user } }, project) => {
const status = get(project, 'status')
if (!status || status === 'rejected') return false
if (!status || status === 'rejected' || status === 'published') return false
const handlingEditor = get(project, 'handlingEditor')
const isAdmin = get(user, 'admin')
......
......@@ -26,14 +26,14 @@ const EditorialComment = ({
reason,
comments,
updatedOn,
handlingEditor: { name },
author: { name, role },
}) => (
<Root>
<Row>
<HeaderContainer>
<ReasonText>{reason}</ReasonText>
<CommentAuthor>{name}</CommentAuthor>
<RoleBadge>he</RoleBadge>
<RoleBadge>{role}</RoleBadge>
</HeaderContainer>
<DateParser timestamp={updatedOn}>
{t => <DefaultText>{t}</DefaultText>}
......@@ -50,10 +50,22 @@ const EditorialComment = ({
export default compose(
setDisplayName('EditorialComment'),
withProps(({ recommendation, comments = [] }) => ({
reason: parseRecommendationType(recommendation),
comments: parseRecommendationComments(comments),
})),
withProps(
({
userId,
editorInChief,
recommendation,
handlingEditor: { id: heId, name: heName },
comments = [],
}) => ({
reason: parseRecommendationType(recommendation),
comments: parseRecommendationComments(comments),
author: {
name: userId === heId ? heName : editorInChief,
role: userId === heId ? 'HE' : 'EiC',
},
}),
),
)(EditorialComment)
// #region styled-components
......@@ -84,7 +96,6 @@ const RoleBadge = styled.span`
margin-left: ${th('subGridUnit')};
padding: calc(${th('subGridUnit')} / 3);
text-align: center;
text-transform: uppercase;
`
const HeaderContainer = styled.div`
......
......@@ -7,11 +7,20 @@ import { setDisplayName, withProps, compose } from 'recompose'
import { Expandable } from '../molecules'
import { EditorialComment } from './'
const EditorialComments = ({ recommendations, handlingEditor }) => (
const EditorialComments = ({
recommendations,
handlingEditor,
editorInChief,
}) => (
<Root>
<Expandable label="Editorial comments" startExpanded>
{recommendations.map(r => (
<EditorialComment key={r.id} {...r} handlingEditor={handlingEditor} />
<EditorialComment
key={r.id}
{...r}
editorInChief={editorInChief}
handlingEditor={handlingEditor}
/>
))}
</Expandable>
</Root>
......
......@@ -59,6 +59,7 @@ const ManuscriptLayout = ({
editorialRecommendations.length > 0 && (
<EditorialComments
project={project}
editorInChief={editorInChief}
recommendations={editorialRecommendations}
/>
)}
......
......@@ -58,7 +58,7 @@ export default compose(
const Root = styled.div`
border-bottom: ${th('borderDefault')};
display: flex;
justify-content: space-between;
justify-content: flex-end;
padding: ${th('subGridUnit')};
`
......
......@@ -24,7 +24,7 @@ export const parseFormValues = ({ decision, messageToHE }) => {
recommendation: decision,
recommendationType: 'editorRecommendation',
}
return messageToHE
return decision === 'return-to-handling-editor'
? {
...recommendation,
comments: [
......
......@@ -45,7 +45,7 @@ export const selectRecommendations = state =>
get(state, 'recommendations.recommendations') || []
export const selectEditorialRecommendations = state =>
selectRecommendations(state).filter(
r => r.recommendationType === 'editorRecommendation',
r => r.recommendationType === 'editorRecommendation' && r.comments,
)
// #endregion
......
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