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

feat(handling-editor-response): add fetching functionality and change some wording

parent 20060352
No related branches found
No related tags found
1 merge request!43Sprint #19
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)
......@@ -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)
}}
/>
```
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