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

feat(reviews): add details on EiC review card

parent af18c4e4
No related branches found
No related tags found
1 merge request!10Sprint #12
...@@ -56,6 +56,7 @@ module.exports = models => async (req, res) => { ...@@ -56,6 +56,7 @@ module.exports = models => async (req, res) => {
respondedOn, respondedOn,
email: user.email, email: user.email,
status, status,
userId: user.id,
invitationId: id, invitationId: id,
} }
}) })
......
import React, { Fragment } from 'react' import React, { Fragment } from 'react'
import moment from 'moment' import moment from 'moment'
import { get } from 'lodash' import { get, isEmpty } from 'lodash'
import { th } from '@pubsweet/ui' import { th } from '@pubsweet/ui'
import { compose } from 'recompose' import { compose } from 'recompose'
import { withJournal } from 'xpub-journal' import { withJournal } from 'xpub-journal'
...@@ -9,8 +9,13 @@ import { FileItem } from 'pubsweet-components-faraday/src/components/Files' ...@@ -9,8 +9,13 @@ import { FileItem } from 'pubsweet-components-faraday/src/components/Files'
import ShowMore from './ShowMore' import ShowMore from './ShowMore'
const ReviewReportCard = ({ report = {}, journal: { recommendations } }) => { const ReviewReportCard = ({
const { submittedOn, comments } = report report = {},
journal: { recommendations },
i = 0,
}) => {
const hasReviewer = !isEmpty(get(report, 'user'))
const { submittedOn, comments, user } = report
const submittedDate = moment(submittedOn).format('DD.MM.YYYY') const submittedDate = moment(submittedOn).format('DD.MM.YYYY')
const publicComment = comments.find(c => c.public) const publicComment = comments.find(c => c.public)
const privateComment = comments.find(c => !c.public) const privateComment = comments.find(c => !c.public)
...@@ -20,15 +25,25 @@ const ReviewReportCard = ({ report = {}, journal: { recommendations } }) => { ...@@ -20,15 +25,25 @@ const ReviewReportCard = ({ report = {}, journal: { recommendations } }) => {
) )
return ( return (
<Root> <Root hasReviewer={hasReviewer}>
{hasReviewer && (
<Row>
<Text>
<b>Reviewer {i}</b>
<Underline>{user.name}</Underline>
<span>{user.email}</span>
</Text>
{submittedDate && <Text>{submittedDate}</Text>}
</Row>
)}
<Row> <Row>
<Label>Recommendation</Label> <Label>Recommendation</Label>
{submittedDate && <Text>{submittedDate}</Text>} {submittedDate && !hasReviewer && <Text>{submittedDate}</Text>}
</Row> </Row>
<Row> <Row>
<Text>{recommendationLabel}</Text> <Text>{recommendationLabel}</Text>
</Row> </Row>
{publicComment.content && ( {get(publicComment, 'content') && (
<Fragment> <Fragment>
<Spacing /> <Spacing />
<Row left> <Row left>
...@@ -40,7 +55,7 @@ const ReviewReportCard = ({ report = {}, journal: { recommendations } }) => { ...@@ -40,7 +55,7 @@ const ReviewReportCard = ({ report = {}, journal: { recommendations } }) => {
</Fragment> </Fragment>
)} )}
{publicComment.files && {get(publicComment, 'files') &&
!!publicComment.files.length && ( !!publicComment.files.length && (
<Fragment> <Fragment>
<Spacing /> <Spacing />
...@@ -55,7 +70,7 @@ const ReviewReportCard = ({ report = {}, journal: { recommendations } }) => { ...@@ -55,7 +70,7 @@ const ReviewReportCard = ({ report = {}, journal: { recommendations } }) => {
</Fragment> </Fragment>
)} )}
{privateComment.content && ( {get(privateComment, 'content') && (
<Fragment> <Fragment>
<Spacing /> <Spacing />
<Row left> <Row left>
...@@ -78,16 +93,29 @@ const defaultText = css` ...@@ -78,16 +93,29 @@ const defaultText = css`
font-family: ${th('fontReading')}; font-family: ${th('fontReading')};
font-size: ${th('fontSizeBaseSmall')}; font-size: ${th('fontSizeBaseSmall')};
` `
const cardStyle = css`
margin: 0 auto calc(${th('subGridUnit')}*3);
border: ${th('borderDefault')};
padding: calc(${th('subGridUnit')}*2);
`
const Root = styled.div` const Root = styled.div`
display: flex; display: flex;
flex-direction: column; flex-direction: column;
margin: auto; margin: auto;
[role='listbox'] { border: none;
min-width: 280px; padding: 0;
} ${({ hasReviewer }) => (hasReviewer ? cardStyle : null)};
` `
const Text = styled.div` const Text = styled.div`
${defaultText}; ${defaultText};
span {
margin-left: calc(${th('subGridUnit')}*3);
}
`
const Underline = styled.span`
text-decoration: underline;
` `
const Label = styled.div` const Label = styled.div`
${defaultText}; ${defaultText};
......
...@@ -19,7 +19,7 @@ import { selectRecommendations } from 'pubsweet-components-faraday/src/redux/rec ...@@ -19,7 +19,7 @@ import { selectRecommendations } from 'pubsweet-components-faraday/src/redux/rec
import Tabs from '../molecules/Tabs' import Tabs from '../molecules/Tabs'
import Expandable from '../molecules/Expandable' import Expandable from '../molecules/Expandable'
const getTabSections = (collectionId, reviewers) => [ const getTabSections = (collectionId, reviewers, recommendations = []) => [
{ {
key: 1, key: 1,
label: 'Reviewers Details', label: 'Reviewers Details',
...@@ -30,7 +30,17 @@ const getTabSections = (collectionId, reviewers) => [ ...@@ -30,7 +30,17 @@ const getTabSections = (collectionId, reviewers) => [
{ {
key: 2, key: 2,
label: 'Reviewer Reports', label: 'Reviewer Reports',
content: <div>Reviewer Reports Content</div>, content: (
<Fragment>
{recommendations.length ? (
recommendations.map((r, index) => (
<ReviewReportCard i={index + 1} key={r.id} report={r} />
))
) : (
<div>No reports submitted yet.</div>
)}
</Fragment>
),
}, },
] ]
...@@ -43,6 +53,7 @@ const ReviewsAndReports = ({ ...@@ -43,6 +53,7 @@ const ReviewsAndReports = ({
currentUserIs, currentUserIs,
report, report,
review = {}, review = {},
mappedRecommendations,
}) => ( }) => (
<Fragment> <Fragment>
{currentUserIs('staff') && ( {currentUserIs('staff') && (
...@@ -56,7 +67,11 @@ const ReviewsAndReports = ({ ...@@ -56,7 +67,11 @@ const ReviewsAndReports = ({
> >
<Tabs <Tabs
activeKey={1} activeKey={1}
sections={getTabSections(project.id, reviewers)} sections={getTabSections(
project.id,
reviewers,
mappedRecommendations(),
)}
/> />
</Expandable> </Expandable>
</Root> </Root>
...@@ -93,6 +108,11 @@ export default compose( ...@@ -93,6 +108,11 @@ export default compose(
getReviewers: ({ project, getCollectionReviewers }) => () => { getReviewers: ({ project, getCollectionReviewers }) => () => {
getCollectionReviewers(project.id) getCollectionReviewers(project.id)
}, },
mappedRecommendations: ({ recommendations, reviewers }) => () =>
recommendations.map(r => ({
...r,
user: reviewers.find(user => user.userId === r.userId),
})),
}), }),
withProps(({ recommendations = [] }) => ({ withProps(({ recommendations = [] }) => ({
report: head(recommendations.filter(r => r.submittedOn)), report: head(recommendations.filter(r => r.submittedOn)),
......
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