mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
efb35b537a
* 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
47 lines
1.1 KiB
JavaScript
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);
|