Skip to content
Snippets Groups Projects
SignUpStep0.js 3.69 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'
  ItemOverrideAlert,
} 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"
        <Item mr={1} vertical>
          <Label required>Title</Label>
            component={input => (
              <Menu
                {...input}
                options={get(journal, 'title', [])}
                placeholder="Please select"
              />
            )}
        <ItemOverrideAlert ml={1} vertical>
          <Label required>Country</Label>
          <ValidatedField
            component={input => (
              <Menu
                {...input}
                options={countryList}
                placeholder="Please select"
              />
            )}
            name="country"
            validate={[requiredValidator]}
          />
        </ItemOverrideAlert>

      <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 account and
          allowing you to use the services available via the platform. Please
          read our{' '}
          <ActionLink to="https://www.hindawi.com/privacy/">
            Privacy Policy{' '}
          </ActionLink>{' '}
          for further information.

      <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)