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

Merge branch 'HIN765-HIN766' into 'develop'

fix(hin-765 & hin-766): update invitations and fragment after taking actions on it

See merge request !19
parents 7e98574e 73531c3f
No related branches found
No related tags found
2 merge requests!21Sprint #16 features,!19fix(hin-765 & hin-766): update invitations and fragment after taking actions on it
...@@ -30,16 +30,14 @@ const ModalComponent = connect(state => ({ ...@@ -30,16 +30,14 @@ const ModalComponent = connect(state => ({
export default compose( export default compose(
connect(null, { connect(null, {
reviewerDecision, reviewerDecision,
getFragments: actions.getFragments, getCollection: actions.getCollection,
getCollections: actions.getCollections,
}), }),
withModal(props => ({ withModal(props => ({
modalComponent: ModalComponent, modalComponent: ModalComponent,
})), })),
withHandlers({ withHandlers({
decisionSuccess: ({ getFragments, getCollections, hideModal }) => () => { decisionSuccess: ({ project, hideModal, getCollection }) => () => {
getCollections() getCollection(project)
getFragments()
hideModal() hideModal()
}, },
}), }),
......
import React from 'react' import React from 'react'
import { get } from 'lodash'
import { th } from '@pubsweet/ui' import { th } from '@pubsweet/ui'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import styled, { css } from 'styled-components' import styled, { css } from 'styled-components'
import { compose, withHandlers } from 'recompose' import { compose, withHandlers, withProps } from 'recompose'
import { selectFragment, selectCollection } from 'xpub-selectors' import { selectFragment, selectCollection } from 'xpub-selectors'
import { selectReviewers } from 'pubsweet-components-faraday/src/redux/reviewers' import { selectReviewers } from 'pubsweet-components-faraday/src/redux/reviewers'
...@@ -30,8 +31,12 @@ export default compose( ...@@ -30,8 +31,12 @@ export default compose(
fragment: selectFragment(state, versionId), fragment: selectFragment(state, versionId),
collection: selectCollection(state, collectionId), collection: selectCollection(state, collectionId),
})), })),
withProps(({ fragment }) => ({
invitations: get(fragment, 'invitations', []),
recommendations: get(fragment, 'recommendations', []),
})),
withHandlers({ withHandlers({
getCompactReport: ({ fragment: { invitations = [] } }) => () => { getCompactReport: ({ invitations }) => () => {
const reviewerInvitations = invitations.filter(roleFilter('reviewer')) const reviewerInvitations = invitations.filter(roleFilter('reviewer'))
const accepted = reviewerInvitations.filter(acceptedInvitationFilter) const accepted = reviewerInvitations.filter(acceptedInvitationFilter)
.length .length
...@@ -41,10 +46,7 @@ export default compose( ...@@ -41,10 +46,7 @@ export default compose(
</ReviewerText> </ReviewerText>
) )
}, },
getExtendedReport: ({ getExtendedReport: ({ recommendations, reviewers = [] }) => () => {
fragment: { recommendations = [] },
reviewers = [],
}) => () => {
const mappedValues = reviewers.map(r => ({ const mappedValues = reviewers.map(r => ({
...r, ...r,
review: recommendations.find(rec => rec.userId === r.userId), review: recommendations.find(rec => rec.userId === r.userId),
......
...@@ -32,16 +32,22 @@ const InviteReviewersModal = compose( ...@@ -32,16 +32,22 @@ const InviteReviewersModal = compose(
fetchingInvite: selectFetchingInvite(state), fetchingInvite: selectFetchingInvite(state),
fetchingReviewers: selectFetchingReviewers(state), fetchingReviewers: selectFetchingReviewers(state),
}), }),
{ getCollectionReviewers, getCollections: actions.getCollections }, {
getCollectionReviewers,
getFragment: actions.getFragment,
getCollections: actions.getCollections,
},
), ),
withHandlers({ withHandlers({
getReviewers: ({ getReviewers: ({
versionId, versionId,
getFragment,
collectionId, collectionId,
setReviewers, setReviewers,
getCollectionReviewers, getCollectionReviewers,
}) => () => { }) => () => {
getCollectionReviewers(collectionId, versionId) getCollectionReviewers(collectionId, versionId)
getFragment({ id: collectionId }, { id: versionId })
}, },
closeModal: ({ getCollections, hideModal }) => () => { closeModal: ({ getCollections, hideModal }) => () => {
getCollections() getCollections()
...@@ -50,8 +56,8 @@ const InviteReviewersModal = compose( ...@@ -50,8 +56,8 @@ const InviteReviewersModal = compose(
}), }),
lifecycle({ lifecycle({
componentDidMount() { componentDidMount() {
const { getReviewers } = this.props const { getCollectionReviewers, collectionId, versionId } = this.props
getReviewers() getCollectionReviewers(collectionId, versionId)
}, },
}), }),
)( )(
......
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