fleet/frontend/components/forms/ChangeEmailForm/ChangeEmailForm.jsx
Gabe Hernandez efb35b537a
add prettier and have it format all fleet application code (#625)
* add prettier and have it format all js code except website:
:

* trying running prettier check in CI

* fix runs on in CI

* change CI job name

* fix prettier erros and fix CI
2021-04-12 14:32:25 +01:00

61 lines
1.5 KiB
JavaScript

import React, { Component } from "react";
import PropTypes from "prop-types";
import Button from "components/buttons/Button";
import Form from "components/forms/Form";
import formFieldInterface from "interfaces/form_field";
import InputField from "components/forms/fields/InputField";
const baseClass = "change-email-form";
class ChangeEmailForm extends Component {
static propTypes = {
fields: PropTypes.shape({
password: formFieldInterface.isRequired,
}).isRequired,
handleSubmit: PropTypes.func.isRequired,
onCancel: PropTypes.func.isRequired,
};
render() {
const { fields, handleSubmit, onCancel } = this.props;
return (
<form onSubmit={handleSubmit}>
<InputField
{...fields.password}
autofocus
label="Password"
type="password"
/>
<div className={`${baseClass}__btn-wrap`}>
<Button className={`${baseClass}__btn`} type="submit" variant="brand">
Submit
</Button>
<Button
onClick={onCancel}
variant="inverse"
className={`${baseClass}__btn`}
>
Cancel
</Button>
</div>
</form>
);
}
}
export default Form(ChangeEmailForm, {
fields: ["password"],
validate: (formData) => {
if (!formData.password) {
return {
valid: false,
errors: { password: "Password must be present" },
};
}
return { valid: true, errors: {} };
},
});