2021-04-12 13:32:25 +00:00
|
|
|
import React, { Component } from "react";
|
|
|
|
|
import PropTypes from "prop-types";
|
2016-11-16 16:58:25 +00:00
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
import Form from "components/forms/Form";
|
|
|
|
|
import formFieldInterface from "interfaces/form_field";
|
|
|
|
|
import Button from "components/buttons/Button";
|
2022-12-16 18:32:10 +00:00
|
|
|
import InputField from "components/forms/fields/InputField";
|
2021-04-12 13:32:25 +00:00
|
|
|
import helpers from "./helpers";
|
2016-11-16 16:58:25 +00:00
|
|
|
|
2021-06-24 20:42:29 +00:00
|
|
|
const formFields = ["name", "password", "password_confirmation", "email"];
|
2016-11-16 16:58:25 +00:00
|
|
|
const { validate } = helpers;
|
|
|
|
|
|
|
|
|
|
class AdminDetails extends Component {
|
|
|
|
|
static propTypes = {
|
2016-12-01 18:57:19 +00:00
|
|
|
className: PropTypes.string,
|
|
|
|
|
currentPage: PropTypes.bool,
|
2016-11-16 16:58:25 +00:00
|
|
|
fields: PropTypes.shape({
|
2021-06-24 20:42:29 +00:00
|
|
|
name: formFieldInterface.isRequired,
|
2016-11-16 16:58:25 +00:00
|
|
|
email: formFieldInterface.isRequired,
|
|
|
|
|
password: formFieldInterface.isRequired,
|
|
|
|
|
password_confirmation: formFieldInterface.isRequired,
|
|
|
|
|
}).isRequired,
|
|
|
|
|
handleSubmit: PropTypes.func.isRequired,
|
|
|
|
|
};
|
|
|
|
|
|
2020-10-22 01:03:39 +00:00
|
|
|
componentDidUpdate(prevProps) {
|
2021-04-12 13:32:25 +00:00
|
|
|
if (
|
|
|
|
|
this.props.currentPage &&
|
|
|
|
|
this.props.currentPage !== prevProps.currentPage
|
|
|
|
|
) {
|
2020-10-22 01:03:39 +00:00
|
|
|
// Component has a transition duration of 300ms set in
|
|
|
|
|
// RegistrationForm/_styles.scss. We need to wait 300ms before
|
|
|
|
|
// calling .focus() to preserve smooth transition.
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.firstInput.input.focus();
|
|
|
|
|
}, 300);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
render() {
|
2016-12-01 18:57:19 +00:00
|
|
|
const { className, currentPage, fields, handleSubmit } = this.props;
|
2023-04-18 17:34:21 +00:00
|
|
|
const tabIndex = currentPage ? 0 : -1;
|
2016-11-16 16:58:25 +00:00
|
|
|
|
|
|
|
|
return (
|
2025-11-25 17:26:15 +00:00
|
|
|
<form
|
|
|
|
|
onSubmit={handleSubmit}
|
|
|
|
|
className={className}
|
|
|
|
|
autoComplete="off"
|
|
|
|
|
noValidate
|
|
|
|
|
>
|
2024-01-18 15:48:44 +00:00
|
|
|
<p>Additional admins can be designated within the Fleet app.</p>
|
|
|
|
|
<InputField
|
|
|
|
|
{...fields.name}
|
|
|
|
|
label="Full name"
|
|
|
|
|
tabIndex={tabIndex}
|
|
|
|
|
autofocus={currentPage}
|
|
|
|
|
ref={(input) => {
|
|
|
|
|
this.firstInput = input;
|
|
|
|
|
}}
|
|
|
|
|
inputOptions={{
|
|
|
|
|
maxLength: "80",
|
|
|
|
|
}}
|
|
|
|
|
/>
|
2025-11-25 17:26:15 +00:00
|
|
|
<InputField
|
|
|
|
|
{...fields.email}
|
|
|
|
|
label="Email"
|
|
|
|
|
tabIndex={tabIndex}
|
|
|
|
|
type="email"
|
|
|
|
|
/>
|
2024-01-18 15:48:44 +00:00
|
|
|
<InputField
|
|
|
|
|
{...fields.password}
|
|
|
|
|
label="Password"
|
|
|
|
|
type="password"
|
|
|
|
|
tabIndex={tabIndex}
|
2025-08-26 21:59:05 +00:00
|
|
|
helpText="12-48 characters, with at least 1 number (e.g. 0 - 9) and 1 symbol (e.g. &*#)."
|
2024-01-18 15:48:44 +00:00
|
|
|
/>
|
|
|
|
|
<InputField
|
|
|
|
|
{...fields.password_confirmation}
|
|
|
|
|
type="password"
|
|
|
|
|
tabIndex={tabIndex}
|
|
|
|
|
label="Confirm password"
|
|
|
|
|
/>
|
2026-02-26 17:13:53 +00:00
|
|
|
<div className="button-wrap--center">
|
|
|
|
|
<Button
|
|
|
|
|
type="submit"
|
|
|
|
|
tabIndex={tabIndex}
|
|
|
|
|
disabled={!currentPage}
|
|
|
|
|
size="wide"
|
|
|
|
|
>
|
2025-09-29 17:10:41 +00:00
|
|
|
Next
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
2017-01-11 19:27:33 +00:00
|
|
|
</form>
|
2016-11-16 16:58:25 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Form(AdminDetails, {
|
|
|
|
|
fields: formFields,
|
|
|
|
|
validate,
|
|
|
|
|
});
|