fleet/frontend/components/forms/RegistrationForm/AdminDetails/AdminDetails.jsx

72 lines
2.1 KiB
React
Raw Normal View History

import React, { Component, PropTypes } from 'react';
import Form from 'components/forms/Form';
import formFieldInterface from 'interfaces/form_field';
import Button from 'components/buttons/Button';
import InputFieldWithIcon from 'components/forms/fields/InputFieldWithIcon';
import helpers from './helpers';
2016-12-01 18:57:19 +00:00
const formFields = ['username', 'password', 'password_confirmation', 'email'];
const { validate } = helpers;
class AdminDetails extends Component {
static propTypes = {
2016-12-01 18:57:19 +00:00
className: PropTypes.string,
currentPage: PropTypes.bool,
fields: PropTypes.shape({
email: formFieldInterface.isRequired,
password: formFieldInterface.isRequired,
password_confirmation: formFieldInterface.isRequired,
username: formFieldInterface.isRequired,
}).isRequired,
handleSubmit: PropTypes.func.isRequired,
};
render () {
2016-12-01 18:57:19 +00:00
const { className, currentPage, fields, handleSubmit } = this.props;
const tabIndex = currentPage ? 1 : -1;
return (
<form onSubmit={handleSubmit} className={className}>
2016-12-01 18:57:19 +00:00
<div className="registration-fields">
<InputFieldWithIcon
{...fields.username}
iconName="username"
placeholder="Username"
tabIndex={tabIndex}
autofocus={currentPage}
2016-12-01 18:57:19 +00:00
/>
<InputFieldWithIcon
{...fields.password}
iconName="password"
placeholder="Password"
type="password"
tabIndex={tabIndex}
/>
<InputFieldWithIcon
{...fields.password_confirmation}
iconName="password"
placeholder="Confirm Password"
type="password"
tabIndex={tabIndex}
/>
<InputFieldWithIcon
{...fields.email}
iconName="email"
placeholder="Email"
tabIndex={tabIndex}
/>
</div>
<Button type="submit" variant="gradient" tabIndex={tabIndex} disabled={!currentPage}>
Submit
</Button>
</form>
);
}
}
export default Form(AdminDetails, {
fields: formFields,
validate,
});