diff --git a/packages/components-faraday/src/components/Dashboard/DashboardCard.js b/packages/components-faraday/src/components/Dashboard/DashboardCard.js index 33acb19dd43e8157ffdfdd4c658c6fac5a087a0f..efaf65a366cf4088f86b9223026be39aadc3819d 100644 --- a/packages/components-faraday/src/components/Dashboard/DashboardCard.js +++ b/packages/components-faraday/src/components/Dashboard/DashboardCard.js @@ -64,6 +64,8 @@ const DashboardCard = ({ </LeftDetails> <RightDetails flex={2}> <Decision + collectionId={project.id} + fragmentId={version.id} heRecommendation={heRecommendation} modalKey={`decide-${version.id}`} /> diff --git a/packages/components-faraday/src/components/MakeDecision/Decision.js b/packages/components-faraday/src/components/MakeDecision/Decision.js index bdd6e7ba1c6595e7d7ce4d20a69fd3ab7a49f98c..1dfa521c40d39a3ba56154419ad922c2e70bdb92 100644 --- a/packages/components-faraday/src/components/MakeDecision/Decision.js +++ b/packages/components-faraday/src/components/MakeDecision/Decision.js @@ -28,11 +28,19 @@ export default compose( modalComponent: ModalComponent, })), withHandlers({ - showDecisionModal: ({ showModal, hideModal, heRecommendation }) => () => { + showDecisionModal: ({ + showModal, + hideModal, + fragmentId, + collectionId, + heRecommendation, + }) => () => { showModal({ type: 'decision', hideModal, heRecommendation, + fragmentId, + collectionId, }) }, }), diff --git a/packages/components-faraday/src/components/MakeDecision/DecisionForm.js b/packages/components-faraday/src/components/MakeDecision/DecisionForm.js index ecf851988cde1c788a90ab91a14c9cb8a869fa0d..c3b6c6d6f3eacb18fcbba3d2ccd13c4d0a3b9255 100644 --- a/packages/components-faraday/src/components/MakeDecision/DecisionForm.js +++ b/packages/components-faraday/src/components/MakeDecision/DecisionForm.js @@ -1,12 +1,14 @@ import React from 'react' import { get } from 'lodash' import { connect } from 'react-redux' +import { actions } from 'pubsweet-client' import styled, { css } from 'styled-components' import { reduxForm, formValueSelector } from 'redux-form' import { compose, setDisplayName, withProps } from 'recompose' import { th, Icon, Button, RadioGroup, ValidatedField } from '@pubsweet/ui' import { FormItems } from '../UIComponents' +import { createRecommendation } from '../../redux/recommendations' const { Row, @@ -23,7 +25,7 @@ const Form = RootContainer.withComponent(FormContainer) const decisionOptions = [ { label: 'Publish', value: 'publish' }, { label: 'Reject', value: 'reject' }, - { label: 'Return to Handling Editor', value: 'returnToHE' }, + { label: 'Return to Handling Editor', value: 'return-to-handling-editor' }, ] const DecisionForm = ({ @@ -63,7 +65,7 @@ const DecisionForm = ({ /> </RowItem> </Row> - {decision === 'returnToHE' && ( + {decision === 'return-to-handling-editor' && ( <Row> <RowItem vertical> <Label>Comments for Handling Editor</Label> @@ -104,9 +106,12 @@ const subtitleParser = t => { const selector = formValueSelector('eicDecision') export default compose( setDisplayName('DecisionForm'), - connect(state => ({ - decision: selector(state, 'decision'), - })), + connect( + state => ({ + decision: selector(state, 'decision'), + }), + { createRecommendation, getCollections: actions.getCollections }, + ), withProps(({ heRecommendation: { recommendation = '', comments = [] } }) => ({ heRecommendation: { reason: subtitleParser(recommendation), @@ -115,8 +120,34 @@ export default compose( })), reduxForm({ form: 'eicDecision', - onSubmit: (values, dispatch, props) => { - // console.log('decision form', values, props) + onSubmit: ( + { decision, messageToHE }, + dispatch, + { + showModal, + fragmentId, + collectionId, + getCollections, + createRecommendation, + }, + ) => { + const recommendation = { + recommendation: decision, + recommendationType: 'editorRecommendation', + comments: [ + { + public: false, + content: messageToHE, + }, + ], + } + createRecommendation(collectionId, fragmentId, recommendation).then(r => { + getCollections() + showModal({ + title: 'Decision submitted', + cancelText: 'OK', + }) + }) }, }), )(DecisionForm)