fleet/frontend/components/EmailTokenRedirect/EmailTokenRedirect.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

47 lines
1.1 KiB
JavaScript

import React, { Component } from "react";
import PropTypes from "prop-types";
import { connect } from "react-redux";
import helpers from "components/EmailTokenRedirect/helpers";
import userInterface from "interfaces/user";
export class EmailTokenRedirect extends Component {
static propTypes = {
dispatch: PropTypes.func.isRequired,
token: PropTypes.string.isRequired,
user: userInterface,
};
componentWillMount() {
const { dispatch, token, user } = this.props;
return helpers.confirmEmailChange(dispatch, token, user);
}
componentWillReceiveProps(nextProps) {
const { dispatch, token: newToken, user: newUser } = nextProps;
const { token: oldToken, user: oldUser } = this.props;
const missingProps = !oldToken || !oldUser;
if (missingProps) {
return helpers.confirmEmailChange(dispatch, newToken, newUser);
}
return false;
}
render() {
return <div />;
}
}
const mapStateToProps = (state, { params }) => {
const { token } = params;
const { user } = state.auth;
return { token, user };
};
export default connect(mapStateToProps)(EmailTokenRedirect);