Newer
Older
import { Flex, Box } from 'grid-styled'
import { Button, Heading, H1, Checkbox } from '@pubsweet/ui'
import ValidatedField from '../../ui/atoms/ValidatedField'
import { emptyPerson } from './AuthorDetailsSchema'
import ProgressBar from '../ProgressBar'
class AuthorDetails extends React.Component {
this.openCorrespondentForm = this.openCorrespondentForm.bind(this)
this.closeCorrespondentForm = this.closeCorrespondentForm.bind(this)
this.handleNotCorrespondingAuthor = this.handleNotCorrespondingAuthor.bind(
this,
)
}
get isAssigned() {
return this.props.values.submissionMeta.displayCorrespondent
openCorrespondentForm() {
this.props.setFieldValue('submissionMeta.displayCorrespondent', true)
}
closeCorrespondentForm() {
this.props.setFieldValue('submissionMeta.correspondent', emptyPerson)
this.props.setFieldValue('submissionMeta.displayCorrespondent', false)
this.props.setFieldTouched('submissionMeta.correspondent', false)
handleNotCorrespondingAuthor() {
if (!this.isAssigned) {
const { handleSubmit, values /* errors */ } = this.props
<form noValidate onSubmit={handleSubmit}>
<ProgressBar currentStep={0} />
<H1>Are you handling this submission?</H1>
<ValidatedField
label="First name"
name="submissionMeta.author.firstName"
/>
<ValidatedField
label="Last name"
name="submissionMeta.author.lastName"
/>
</Box>
</Flex>
<Flex>
<Box width={1 / 2}>
<ValidatedField
label="Email (correspondence)"
name="submissionMeta.author.email"
<ValidatedField
label="Institution"
name="submissionMeta.author.institution"
/>
</Box>
</Flex>
<Flex>
<Box width={1}>
<Checkbox
checked={this.isAssigned}
label="I am not the corresponding author"
name="cbNotCorrespondingAuthor"
onChange={this.handleNotCorrespondingAuthor}
/>
<Flex>
<Box width={1}>
<AssigneeForm />
</Box>
</Flex>
)}
<Flex>
<Box width={1}>
<Button data-test-id="next" primary type="submit">
Next
</Button>
</Box>
</Flex>
</form>
)
}
}
const CorrespondentForm = ({ handleClose }) => (
<Heading level={3}>Assignee for correspondence</Heading>
<Flex>
<Box width={1 / 2}>
<ValidatedField
label="First name"
name="submissionMeta.correspondent.firstName"
/>
<ValidatedField
label="Last name"
name="submissionMeta.correspondent.lastName"
/>
</Box>
</Flex>
<Flex>
<Box width={1 / 2}>
<ValidatedField
label="Email"
name="submissionMeta.correspondent.email"
/>
<ValidatedField label="Institution" name="assignee.institution" />
export default AuthorDetails