diff --git a/packages/component-faraday-ui/src/manuscriptDetails/HandlingEditorAnswer.js b/packages/component-faraday-ui/src/manuscriptDetails/HandlingEditorAnswer.js index 15dda7a9f27e32963d615c62684d3506f175a7ba..b35630fb209118e1123edb9f55335db3555a381f 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/HandlingEditorAnswer.js +++ b/packages/component-faraday-ui/src/manuscriptDetails/HandlingEditorAnswer.js @@ -1,6 +1,6 @@ import React from 'react' -import { get, has } from 'lodash' import { reduxForm } from 'redux-form' +import { get, has, capitalize } from 'lodash' import { compose, withProps } from 'recompose' import { Button, RadioGroup, ValidatedField } from '@pubsweet/ui' @@ -13,6 +13,7 @@ import { OpenModal, ContextualBox, RowOverrideAlert, + withFetching, } from '../' const options = [ @@ -22,6 +23,8 @@ const options = [ const HandlingEditorAnswer = ({ disabled, + decision, + isFetching, handleSubmit, shouldShowComments, }) => ( @@ -56,8 +59,11 @@ const HandlingEditorAnswer = ({ <Row justify="flex-end" mb={1} pr={1}> <OpenModal + cancelText="Close" + confirmText={decision} + isFetching={isFetching} onConfirm={modalProps => handleSubmit()(modalProps)} - title="Are you sure?" + title={`${decision} this invitation?`} > {showModal => ( <Button disabled={disabled} onClick={showModal} primary size="medium"> @@ -70,14 +76,16 @@ const HandlingEditorAnswer = ({ ) export default compose( + withFetching, withProps(({ formValues }) => ({ disabled: !has(formValues, 'decision'), + decision: capitalize(get(formValues, 'decision')), shouldShowComments: get(formValues, 'decision', 'agree') === 'decline', })), reduxForm({ form: 'he-answer-invitation', - onSubmit: (values, dispatch, { onResponse }) => modalProps => { - onResponse(values, modalProps) + onSubmit: (values, dispatch, { onResponse, setFetching }) => modalProps => { + onResponse(values, { ...modalProps, setFetching }) }, }), )(HandlingEditorAnswer) diff --git a/packages/component-faraday-ui/src/manuscriptDetails/HandlingEditorAnswer.md b/packages/component-faraday-ui/src/manuscriptDetails/HandlingEditorAnswer.md index 444b043f6f286420517e7fac6bf3014a7b94bb75..fed5d02bf8525c9fe5f7cd0e374c5385c7727332 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/HandlingEditorAnswer.md +++ b/packages/component-faraday-ui/src/manuscriptDetails/HandlingEditorAnswer.md @@ -3,13 +3,12 @@ Handling Editor answer invitation. ```js const formValues = { decision: 'decline', -}; +} -<HandlingEditorAnswer +;<HandlingEditorAnswer formValues={formValues} - onResponse={(values, modalProps) => { - console.log('se da surmit', values, modalProps) - modalProps.setModalError('bine coite') + onResponse={(values, { setFetching }) => { + setFetching(true) }} /> ```