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

feat(eic-decision): send decision as eic

parent edeb9d78
No related branches found
No related tags found
1 merge request!10Sprint #12
...@@ -64,6 +64,8 @@ const DashboardCard = ({ ...@@ -64,6 +64,8 @@ const DashboardCard = ({
</LeftDetails> </LeftDetails>
<RightDetails flex={2}> <RightDetails flex={2}>
<Decision <Decision
collectionId={project.id}
fragmentId={version.id}
heRecommendation={heRecommendation} heRecommendation={heRecommendation}
modalKey={`decide-${version.id}`} modalKey={`decide-${version.id}`}
/> />
......
...@@ -28,11 +28,19 @@ export default compose( ...@@ -28,11 +28,19 @@ export default compose(
modalComponent: ModalComponent, modalComponent: ModalComponent,
})), })),
withHandlers({ withHandlers({
showDecisionModal: ({ showModal, hideModal, heRecommendation }) => () => { showDecisionModal: ({
showModal,
hideModal,
fragmentId,
collectionId,
heRecommendation,
}) => () => {
showModal({ showModal({
type: 'decision', type: 'decision',
hideModal, hideModal,
heRecommendation, heRecommendation,
fragmentId,
collectionId,
}) })
}, },
}), }),
......
import React from 'react' import React from 'react'
import { get } from 'lodash' import { get } from 'lodash'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { actions } from 'pubsweet-client'
import styled, { css } from 'styled-components' import styled, { css } from 'styled-components'
import { reduxForm, formValueSelector } from 'redux-form' import { reduxForm, formValueSelector } from 'redux-form'
import { compose, setDisplayName, withProps } from 'recompose' import { compose, setDisplayName, withProps } from 'recompose'
import { th, Icon, Button, RadioGroup, ValidatedField } from '@pubsweet/ui' import { th, Icon, Button, RadioGroup, ValidatedField } from '@pubsweet/ui'
import { FormItems } from '../UIComponents' import { FormItems } from '../UIComponents'
import { createRecommendation } from '../../redux/recommendations'
const { const {
Row, Row,
...@@ -23,7 +25,7 @@ const Form = RootContainer.withComponent(FormContainer) ...@@ -23,7 +25,7 @@ const Form = RootContainer.withComponent(FormContainer)
const decisionOptions = [ const decisionOptions = [
{ label: 'Publish', value: 'publish' }, { label: 'Publish', value: 'publish' },
{ label: 'Reject', value: 'reject' }, { label: 'Reject', value: 'reject' },
{ label: 'Return to Handling Editor', value: 'returnToHE' }, { label: 'Return to Handling Editor', value: 'return-to-handling-editor' },
] ]
const DecisionForm = ({ const DecisionForm = ({
...@@ -63,7 +65,7 @@ const DecisionForm = ({ ...@@ -63,7 +65,7 @@ const DecisionForm = ({
/> />
</RowItem> </RowItem>
</Row> </Row>
{decision === 'returnToHE' && ( {decision === 'return-to-handling-editor' && (
<Row> <Row>
<RowItem vertical> <RowItem vertical>
<Label>Comments for Handling Editor</Label> <Label>Comments for Handling Editor</Label>
...@@ -104,9 +106,12 @@ const subtitleParser = t => { ...@@ -104,9 +106,12 @@ const subtitleParser = t => {
const selector = formValueSelector('eicDecision') const selector = formValueSelector('eicDecision')
export default compose( export default compose(
setDisplayName('DecisionForm'), setDisplayName('DecisionForm'),
connect(state => ({ connect(
decision: selector(state, 'decision'), state => ({
})), decision: selector(state, 'decision'),
}),
{ createRecommendation, getCollections: actions.getCollections },
),
withProps(({ heRecommendation: { recommendation = '', comments = [] } }) => ({ withProps(({ heRecommendation: { recommendation = '', comments = [] } }) => ({
heRecommendation: { heRecommendation: {
reason: subtitleParser(recommendation), reason: subtitleParser(recommendation),
...@@ -115,8 +120,34 @@ export default compose( ...@@ -115,8 +120,34 @@ export default compose(
})), })),
reduxForm({ reduxForm({
form: 'eicDecision', form: 'eicDecision',
onSubmit: (values, dispatch, props) => { onSubmit: (
// console.log('decision form', values, props) { 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) )(DecisionForm)
......
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