mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
* ConfirmInviteForm * Render ConfirmInvitePage at /invites/:invite_token * Add email, pre-fill name, and handle successful submit * Fix button text
95 lines
2.3 KiB
JavaScript
95 lines
2.3 KiB
JavaScript
import React, { Component, PropTypes } from 'react';
|
|
import { connect } from 'react-redux';
|
|
import { max, noop } from 'lodash';
|
|
import { push } from 'react-router-redux';
|
|
|
|
import Breadcrumbs from 'pages/RegistrationPage/Breadcrumbs';
|
|
import paths from 'router/paths';
|
|
import RegistrationForm from 'components/forms/RegistrationForm';
|
|
import { setup } from 'redux/nodes/auth/actions';
|
|
import { showBackgroundImage } from 'redux/nodes/app/actions';
|
|
import EnsureUnauthenticated from 'components/EnsureUnauthenticated';
|
|
import Footer from 'components/Footer';
|
|
|
|
import kolideLogo from '../../../assets/images/kolide-logo-condensed.svg';
|
|
|
|
export class RegistrationPage extends Component {
|
|
static propTypes = {
|
|
dispatch: PropTypes.func.isRequired,
|
|
};
|
|
|
|
static defaultProps = {
|
|
dispatch: noop,
|
|
};
|
|
|
|
constructor (props) {
|
|
super(props);
|
|
|
|
this.state = {
|
|
page: 1,
|
|
pageProgress: 1,
|
|
};
|
|
|
|
return false;
|
|
}
|
|
|
|
componentWillMount () {
|
|
const { dispatch } = this.props;
|
|
|
|
dispatch(showBackgroundImage);
|
|
|
|
return false;
|
|
}
|
|
|
|
onNextPage = () => {
|
|
const { page, pageProgress } = this.state;
|
|
const nextPage = page + 1;
|
|
this.setState({
|
|
page: nextPage,
|
|
pageProgress: max([nextPage, pageProgress]),
|
|
});
|
|
|
|
return false;
|
|
}
|
|
|
|
onRegistrationFormSubmit = (formData) => {
|
|
const { dispatch } = this.props;
|
|
const { LOGIN } = paths;
|
|
|
|
return dispatch(setup(formData))
|
|
.then(() => { return dispatch(push(LOGIN)); })
|
|
.catch(() => { return false; });
|
|
}
|
|
|
|
onSetPage = (page) => {
|
|
const { pageProgress } = this.state;
|
|
if (page > pageProgress) {
|
|
return false;
|
|
}
|
|
|
|
this.setState({ page });
|
|
|
|
return false;
|
|
}
|
|
|
|
render () {
|
|
const { page, pageProgress } = this.state;
|
|
const { onRegistrationFormSubmit, onNextPage, onSetPage } = this;
|
|
|
|
return (
|
|
<div className="registration-page">
|
|
<img
|
|
alt="Kolide"
|
|
src={kolideLogo}
|
|
className="registration-page__logo"
|
|
/>
|
|
<Breadcrumbs onClick={onSetPage} page={page} pageProgress={pageProgress} />
|
|
<RegistrationForm page={page} onNextPage={onNextPage} onSubmit={onRegistrationFormSubmit} />
|
|
<Footer />
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
const ConnectedComponent = connect()(RegistrationPage);
|
|
export default EnsureUnauthenticated(ConnectedComponent);
|