Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
import React, { Fragment } from 'react'
import { reduxForm } from 'redux-form'
import styled from 'styled-components'
import { th } from '@pubsweet/ui-toolkit'
import { required } from 'xpub-validators'
import { compose, withHandlers, withStateHandlers } from 'recompose'
import { withModal } from 'pubsweet-component-modal/src/components'
import { Button, FilePicker, Menu, ValidatedField } from '@pubsweet/ui'
import {
Row,
Item,
Label,
FileItem,
Textarea,
ActionLink,
MultiAction,
ContextualBox,
ItemOverrideAlert,
withFetching,
} from 'pubsweet-component-faraday-ui/src'
const options = [
{ value: 'a', label: 'a' },
{ value: 'b', label: 'b' },
{ value: 'c', label: 'c' },
{ value: 'd', label: 'd' },
]
const testFiles = [
{
id:
'8dca903a-05b9-45ab-89b9-9cb99a9a29c6/02db6c5e-2938-45ac-a5ee-67ae63919bb2',
name: 'Supplementary File 1.jpg',
size: 59621,
originalName: 'Supplementary File 1.jpg',
},
{
id:
'8dca903a-05b9-45ab-89b9-9cb99a9a29c6/5e69e3d9-7f9d-4e8d-b649-6e6a45658d75',
name: 'Supplementary File 2.docx',
size: 476862,
originalName: 'Supplementary File 2.docx',
},
]
const ReviewerReportForm = ({
file,
addFile,
expanded,
toggleMenu,
handleSubmit,
}) => (
<ContextualBox label="Your report" startExpanded>
<Root>
<Row>
<ItemOverrideAlert vertical>
<Label required>Recommendation</Label>
<ValidatedField
component={input => <Menu {...input} options={options} />}
name="recommendation"
validate={[required]}
/>
</ItemOverrideAlert>
</Row>
<Row alignItems="center" justify="space-between" mt={1}>
<Item>
<Label required>Your report</Label>
<FilePicker onUpload={addFile}>
<ActionLink icon="plus">UPLOAD FILE</ActionLink>
</FilePicker>
</Item>
<Item justify="flex-end">
<ActionLink to="https://about.hindawi.com/authors/peer-review-at-hindawi/">
Hindawi Reviewer Guidelines
</ActionLink>
</Item>
</Row>
<Row mb={1}>
<ItemOverrideAlert vertical>
<ValidatedField
component={Textarea}
name="message"
validate={[required]}
/>
</ItemOverrideAlert>
</Row>
<Row justify="flex-start">
<Item flex={0}>
<FileItem item={file} />
</Item>
</Row>
<Row alignItems="center">
{expanded ? (
<Fragment>
<Item>
<Label>Confidential note for the Editorial Team</Label>
</Item>
<Item justify="flex-end">
<ActionLink icon="x" onClick={toggleMenu}>
Remove
</ActionLink>
</Item>
</Fragment>
) : (
<Item>
<ActionLink onClick={toggleMenu}>
Add Confidential note for the Editorial Team
</ActionLink>
</Item>
)}
</Row>
{expanded && (
<Row>
<ItemOverrideAlert pr={2} vertical>
<ValidatedField component={Textarea} name="note" />
</ItemOverrideAlert>
</Row>
)}
<Row justify="flex-end" mt={2}>
<Button onClick={handleSubmit} primary size="medium">
Submit report
</Button>
</Row>
</Root>
</ContextualBox>
)
export default compose(
withFetching,
withModal(() => ({
modalComponent: MultiAction,
})),
withStateHandlers(
{ expanded: false, file: testFiles[0] },
{
toggleMenu: ({ expanded }) => () => ({ expanded: !expanded }),
},
),
withHandlers({
addFile: () => file => {},
}),
reduxForm({
form: 'reviewer-report',
onSubmit: (
values,
dispatch,
{ showModal, setFetching, onSubmitReport },
) => {
showModal({
title: 'Ready to Submit your Report?',
subtitle: `Once submitted, the report can't be modified.`,
onConfirm: modalProps =>
onSubmitReport(values, { ...modalProps, setFetching }),
confirmText: 'Submit report',
cancelText: 'Not yet',
})
},
}),
)(ReviewerReportForm)
// #region styles
const Root = styled.div`
background-color: ${th('colorBackgroundHue2')};
padding: calc(${th('gridUnit')} * 2);
`
// #endregion