Commit 1f556f20 authored by Yannis Barlas's avatar Yannis Barlas

fix(editor panel): show external reviewer info in editor panel

parent 3a89a1c6
...@@ -3,10 +3,11 @@ ...@@ -3,10 +3,11 @@
import React from 'react' import React from 'react'
import { adopt } from 'react-adopt' import { adopt } from 'react-adopt'
import { withRouter } from 'react-router-dom' import { withRouter } from 'react-router-dom'
import { get } from 'lodash' import { get, union } from 'lodash'
import { import {
getArticleForEditor, getArticleForEditor,
getExternalTeamsForManuscript,
getReviewsForArticle, getReviewsForArticle,
getTeamsForArticle, getTeamsForArticle,
manuscriptMetadataUpdate, manuscriptMetadataUpdate,
...@@ -24,6 +25,7 @@ import { ...@@ -24,6 +25,7 @@ import {
const mapper = { const mapper = {
getArticleForEditor: props => getArticleForEditor(props), getArticleForEditor: props => getArticleForEditor(props),
getExternalTeamsForManuscript: props => getExternalTeamsForManuscript(props),
getReviewsForArticle: props => getReviewsForArticle(props), getReviewsForArticle: props => getReviewsForArticle(props),
getTeamsForArticle: props => getTeamsForArticle(props), getTeamsForArticle: props => getTeamsForArticle(props),
manuscriptMetadataUpdate, manuscriptMetadataUpdate,
...@@ -33,39 +35,51 @@ const mapper = { ...@@ -33,39 +35,51 @@ const mapper = {
const mapProps = args => { const mapProps = args => {
const teams = get(args.getTeamsForArticle, 'data.teamsForArticle') const teams = get(args.getTeamsForArticle, 'data.teamsForArticle')
const externalTeams = get(
const invited = get( args.getExternalTeamsForManuscript,
getReviewersTeamByType(teams, 'reviewersInvited'), 'data.getExternalTeamsForManuscript',
'members.length',
) )
const accepted = get( const getTeamMembers = type =>
getReviewersTeamByType(teams, 'reviewersAccepted'), get(getReviewersTeamByType(teams, type), 'members')
'members.length',
)
const rejected = get( const getExternalTeamMembers = type =>
getReviewersTeamByType(teams, 'reviewersRejected'), get(getReviewersTeamByType(externalTeams, type), 'members')
'members.length',
) const reviewersTeam = getTeamMembers('reviewers')
const invitedReviewers = getTeamMembers('reviewersInvited')
const acceptedReviewers = getTeamMembers('reviewersAccepted')
const rejectedReviewers = getTeamMembers('reviewersRejected')
const reviewersTeam = get( const externalReviewersTeam = getExternalTeamMembers('externalReviewers')
getReviewersTeamByType(teams, 'reviewers'), const externalReviewersInvited = getExternalTeamMembers(
'members', 'externalReviewersInvited',
) )
const externalReviewersAccepted = getExternalTeamMembers(
'externalReviewersAccepted',
)
const externalReviewersRejected = getExternalTeamMembers(
'externalReviewersRejected',
)
const invitedCount = union(invitedReviewers, externalReviewersInvited).length
const acceptedCount = union(acceptedReviewers, externalReviewersAccepted)
.length
const rejectedCount = union(rejectedReviewers, externalReviewersRejected)
.length
return { return {
article: args.getArticleForEditor.data.manuscript, article: args.getArticleForEditor.data.manuscript,
editor: getEditor(args.getTeamsForArticle.data.teamsForArticle), editor: getEditor(args.getTeamsForArticle.data.teamsForArticle),
editorSuggestedReviewers: reviewersTeam, editorSuggestedReviewers: union(reviewersTeam, externalReviewersTeam),
loading: loading:
args.getTeamsForArticle.loading || args.getTeamsForArticle.loading ||
args.getArticleForEditor.loading || args.getArticleForEditor.loading ||
args.getReviewsForArticle.loading, args.getReviewsForArticle.loading,
reviewerCounts: { reviewerCounts: {
accepted, accepted: acceptedCount,
invited, invited: invitedCount,
rejected, rejected: rejectedCount,
}, },
reviews: get(args.getReviewsForArticle, 'data.reviewsForArticle'), reviews: get(args.getReviewsForArticle, 'data.reviewsForArticle'),
scienceOfficer: getScienceOfficer( scienceOfficer: getScienceOfficer(
......
...@@ -44,7 +44,7 @@ const ScienceOfficerSection = props => { ...@@ -44,7 +44,7 @@ const ScienceOfficerSection = props => {
<div> <div>
{editorSuggestedReviewers.map( {editorSuggestedReviewers.map(
(reviewer, i) => (reviewer, i) =>
`${reviewer.username}${ `${reviewer.name || reviewer.username}${
i === editorSuggestedReviewers.length - 1 ? '' : ', ' i === editorSuggestedReviewers.length - 1 ? '' : ', '
}`, }`,
)} )}
......
Markdown is supported
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