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

feat(report): hide form when report is submitted

parent 1a8f4924
No related branches found
No related tags found
1 merge request!8Sprint #10
import React, { Fragment } from 'react'
import { head } from 'lodash'
import { th } from '@pubsweet/ui'
import { connect } from 'react-redux'
import styled from 'styled-components'
import { compose, withHandlers, lifecycle } from 'recompose'
import { compose, withHandlers, lifecycle, withProps } from 'recompose'
import { ReviewerBreakdown } from 'pubsweet-components-faraday/src/components/Invitations'
import ReviewersDetailsList from 'pubsweet-components-faraday/src/components/Reviewers/ReviewersDetailsList'
import ReviewerReportForm from 'pubsweet-component-manuscript/src/components/ReviewerReportForm'
......@@ -39,6 +40,7 @@ const ReviewsAndReports = ({
recommendations = [],
isReviewer,
currentUserIs,
report,
}) => (
<Fragment>
{currentUserIs('staff') && (
......@@ -60,11 +62,18 @@ const ReviewsAndReports = ({
{isReviewer && (
<Root id="review-report">
<Expandable label="Your Report" startExpanded>
<ReviewerReportForm
project={project}
recommendations={recommendations}
version={version}
/>
{report ? (
<div>
You have a submitted report with recommendation{' '}
{report.recommendation}
</div>
) : (
<ReviewerReportForm
project={project}
recommendations={recommendations}
version={version}
/>
)}
</Expandable>
</Root>
)}
......@@ -86,6 +95,9 @@ export default compose(
getCollectionReviewers(project.id)
},
}),
withProps(({ recommendations = [] }) => ({
report: head(recommendations.filter(r => r.submittedOn)),
})),
lifecycle({
componentDidMount() {
const { getReviewers } = this.props
......
......@@ -5,6 +5,7 @@ import { create, update } from 'pubsweet-client/src/helpers/api'
const REQUEST = 'recommendations/REQUEST'
const ERROR = 'recommendations/ERROR'
const GET_FRAGMENT_SUCCESS = 'GET_FRAGMENT_SUCCESS'
const GET_RECOMMENDATIONS_SUCCESS = 'recommendations/GET_SUCCESS'
const CREATE_RECOMMENDATION_SUCCESS = 'recommendations/CREATE_SUCCESS'
const UPDATE_RECOMMENDATION_SUCCESS = 'recommendations/UPDATE_SUCCESS'
......@@ -117,6 +118,13 @@ export default (state = initialState, action = {}) => {
fetching: false,
error: action.error,
}
case GET_FRAGMENT_SUCCESS:
return {
...state,
fetching: false,
error: null,
recommendations: get(action, 'fragment.recommendations'),
}
case GET_RECOMMENDATIONS_SUCCESS:
return {
...state,
......
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