Skip to content
Snippets Groups Projects
StepTwo.js 4.17 KiB
Newer Older
import React, { Fragment } from 'react'
import { get } from 'lodash'
import { Field } from 'redux-form'
import { Tooltip } from 'react-tippy'
import styled from 'styled-components'
import { required } from 'xpub-validators'
import {
  IconButton,
  WizardAuthors,
} from 'pubsweet-component-faraday-ui'
import { H2, Menu, YesOrNo, TextField, ValidatedField } from '@pubsweet/ui'

import { Empty } from './'

const StepTwo = ({
  version,
  project,
  hasConflicts,
  authorsError,
    <Row alignItems="center" mb={1}>
      <H2>2. Manuscript & Author Details</H2>
    </Row>
    <Row mb={3}>
      <Text align="center" secondary>
        Please provide the details of all the authors of this manuscript, in the
        order that they appear on the manuscript. Your details have been
        prefilled as the submitting author.
      <Item data-test-id="submission-title" flex={3} mr={1} vertical>
        <Label required>MANUSCRIPT TITLE</Label>
        <ValidatedField
          component={TextField}
          name="metadata.title"
          validate={[required]}
        />
      <ItemOverrideAlert data-test-id="submission-type" vertical>
        <Label required>MANUSCRIPT TYPE</Label>
          component={input => (
            <Menu
              options={manuscriptTypes}
              {...input}
              placeholder="Please select"
            />
          )}
          name="metadata.type"
          validate={[required]}
        />
      </ItemOverrideAlert>
    <RowOverrideAlert mb={2}>
      <Item data-test-id="submission-abstract" vertical>
        <Label required>ABSTRACT</Label>
          component={Textarea}
          minHeight={15}
          name="metadata.abstract"
          validate={[required]}
        />
    </RowOverrideAlert>
    <Field component={Empty} name="authors" />
    <WizardAuthors
      addAuthor={addAuthor}
      authors={get(version, 'authors', [])}
      changeForm={changeForm}
      error={authorsError}
      project={project}
      version={version}
    />

    <Row alignItems="center" justify="flex-start" mt={2}>
      <Item>
        <Label required>Is there a potential conflict of interest?</Label>
        <Tooltip
          arrow
          data-test="submission-tooltip"
          html={<ConflictsTooltip />}
          interactive
          position="bottom"
          trigger="click"
        >
          <IconButton icon="help-circle" primary />
        </Tooltip>
    <Row alignItems="center" justify="flex-start" mb={1}>
      <Field
        component={({ input }) => <YesOrNo {...input} />}
        name="conflicts.hasConflicts"
      />
    {hasConflicts && (
      <Row alignItems="center" justify="flex-start">
        <Item data-test="submission-conflicts-text" vertical>
          <Label required>Conflict of interest details</Label>
            name="conflicts.message"
            validate={[required]}
          />

const ConflictsTooltip = () => (
  <TooltipText>
    When an author, editor, or reviewer has a financial/personal interest or
    belief that could affect his/her objectivity, or inappropriately influence
    his/her actions, a potential conflict of interest exists.
    <MoreInfoLink
      href="https://www.hindawi.com/editors/coi/"
      rel="noopener noreferrer"
      target="_blank"
    >
      More info
    </MoreInfoLink>
  </TooltipText>
)

// #region styled-components
const RowOverrideAlert = styled(Row)`
  div[role='alert'] {
    margin-top: 0;
  }
`

const ItemOverrideAlert = styled(Item)`
  div[role='alert'] {
const TooltipText = styled.span`
  display: inline-block;
  font-family: "'Myriad Pro'";
  font-size: 14px;
`

const MoreInfoLink = styled.a`
  color: #586971;
  margin-left: 4px;