Skip to content
Snippets Groups Projects
Commit 73531c3f authored by Alexandru Munteanu's avatar Alexandru Munteanu
Browse files

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

parent d2de01c0
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 => ({
export default compose(
connect(null, {
reviewerDecision,
getFragments: actions.getFragments,
getCollections: actions.getCollections,
getCollection: actions.getCollection,
}),
withModal(props => ({
modalComponent: ModalComponent,
})),
withHandlers({
decisionSuccess: ({ getFragments, getCollections, hideModal }) => () => {
getCollections()
getFragments()
decisionSuccess: ({ project, hideModal, getCollection }) => () => {
getCollection(project)
hideModal()
},
}),
......
import React from 'react'
import { get } from 'lodash'
import { th } from '@pubsweet/ui'
import { connect } from 'react-redux'
import styled, { css } from 'styled-components'
import { compose, withHandlers } from 'recompose'
import { compose, withHandlers, withProps } from 'recompose'
import { selectFragment, selectCollection } from 'xpub-selectors'
import { selectReviewers } from 'pubsweet-components-faraday/src/redux/reviewers'
......@@ -30,8 +31,12 @@ export default compose(
fragment: selectFragment(state, versionId),
collection: selectCollection(state, collectionId),
})),
withProps(({ fragment }) => ({
invitations: get(fragment, 'invitations', []),
recommendations: get(fragment, 'recommendations', []),
})),
withHandlers({
getCompactReport: ({ fragment: { invitations = [] } }) => () => {
getCompactReport: ({ invitations }) => () => {
const reviewerInvitations = invitations.filter(roleFilter('reviewer'))
const accepted = reviewerInvitations.filter(acceptedInvitationFilter)
.length
......@@ -41,10 +46,7 @@ export default compose(
</ReviewerText>
)
},
getExtendedReport: ({
fragment: { recommendations = [] },
reviewers = [],
}) => () => {
getExtendedReport: ({ recommendations, reviewers = [] }) => () => {
const mappedValues = reviewers.map(r => ({
...r,
review: recommendations.find(rec => rec.userId === r.userId),
......
......@@ -32,16 +32,22 @@ const InviteReviewersModal = compose(
fetchingInvite: selectFetchingInvite(state),
fetchingReviewers: selectFetchingReviewers(state),
}),
{ getCollectionReviewers, getCollections: actions.getCollections },
{
getCollectionReviewers,
getFragment: actions.getFragment,
getCollections: actions.getCollections,
},
),
withHandlers({
getReviewers: ({
versionId,
getFragment,
collectionId,
setReviewers,
getCollectionReviewers,
}) => () => {
getCollectionReviewers(collectionId, versionId)
getFragment({ id: collectionId }, { id: versionId })
},
closeModal: ({ getCollections, hideModal }) => () => {
getCollections()
......@@ -50,8 +56,8 @@ const InviteReviewersModal = compose(
}),
lifecycle({
componentDidMount() {
const { getReviewers } = this.props
getReviewers()
const { getCollectionReviewers, collectionId, versionId } = this.props
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