Skip to content
Snippets Groups Projects
SignUpStep0.js 3.54 KiB
Newer Older
import React, { Fragment } from 'react'
import countrylist from 'country-list'
import { get, isUndefined } from 'lodash'
import { required as requiredValidator } from 'xpub-validators'
import { Menu, Button, Checkbox, TextField, ValidatedField } from '@pubsweet/ui'
  ActionLink,
} from 'pubsweet-component-faraday-ui'

const countries = countrylist()

const countryList = countries
  .getNames()
  .map(c => ({ value: countries.getCode(c), label: c }))

const AgreeCheckbox = ({ value, onChange }) => (
  <Row alignItems="center" justify="flex-start" mb={4} mt={3}>
    <Checkbox checked={value} onChange={onChange} value={value} />
    <Text>
      I agree with the{' '}
      <ActionLink to="https://www.hindawi.com/terms/">
        Terms of Services
      </ActionLink>{' '}
    </Text>
  </Row>
)
const Step0 = ({ journal, handleSubmit, initialValues, error }) =>
  !isUndefined(initialValues) ? (
    <Fragment>
      <Row mb={2} mt={3}>
        <Item mr={1} vertical>
          <Label required>First Name</Label>
          <ValidatedField
            component={TextField}
            name="firstName"
        </Item>
        <Item ml={1} vertical>
          <Label required>Last Name</Label>
          <ValidatedField
            component={TextField}
            name="lastName"
      <Row mb={4}>
        <Item mr={1} vertical>
          <Label required>Title</Label>
            component={input => (
              <Menu
                {...input}
                options={get(journal, 'title', [])}
                placeholder="Please select"
              />
            )}
        </Item>
        <Item ml={1} vertical>
          <Label required>Country</Label>
          <ValidatedField
            component={input => (
              <Menu
                {...input}
                options={countryList}
                placeholder="Please select"
              />
            )}
            name="country"
            validate={[requiredValidator]}
          />
        </Item>

      <Row>
        <Item vertical>
          <Label required>Affiliation</Label>
          <ValidatedField
            component={TextField}
            name="affiliation"
            validate={[requiredValidator]}
          />
        </Item>

      <ValidatedField
        component={AgreeCheckbox}
        name="agreeTC"
        validate={[requiredValidator]}
      />

          This account information will be processed by us in accordance with
          our Privacy Policy for the purpose of registering your Faraday account
          and allowing you to use the services available via the Faraday
          platform. Please read our Privacy Policy for further information.
        </Text>

      <Button mt={4} onClick={handleSubmit}>
        PROCEED TO SET EMAIL AND PASSWORD
      </Button>

      <Row mt={3}>
        <Text display="flex">
          Already have an account?
          <ActionLink internal pl={1 / 2} to="/">
            Sign in
          </ActionLink>
        </Text>
    <div>{!isUndefined(error) && 'Loading...'}</div>

export default reduxForm({
  form: 'signUpInvitation',
  destroyOnUnmount: false,
  forceUnregisterOnUnmount: true,
})(Step0)