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