"use strict";

require("core-js/modules/web.dom.iterable");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _react = _interopRequireWildcard(require("react"));

var _reactBootstrap = require("react-bootstrap");

var _reactRedux = require("react-redux");

var _styledComponents = _interopRequireDefault(require("styled-components"));

var uiActions = _interopRequireWildcard(require("../../actions/ui"));

var userActions = _interopRequireWildcard(require("../../actions/user"));

var _constants = require("../../util/constants");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

const DivSpacer = _styledComponents.default.div`
  margin-top: ${props => props.space || 2}em;
`;
/**
 * This component contains the prompt for the user to verify their email address.
 * It also contains a button that lets the user finish account setup.
 *
 * (One way to make sure the parent page fetches the latest email verification status
 * is to simply reload the page.)
 */

class VerifyEmailPane extends _react.Component {
  constructor(...args) {
    super(...args);

    _defineProperty(this, "_handleEmailVerified", () => window.location.reload());
  }

  componentDidMount() {
    const {
      emailVerified,
      routeTo
    } = this.props;

    if (emailVerified) {
      // If the user got to this screen, it is assumed they just signed up,
      // so once their email is verified, automatically go to the
      // next screen, which is the terms page.
      routeTo(_constants.CREATE_ACCOUNT_TERMS_PATH);
    }
  }

  render() {
    const {
      resendVerificationEmail
    } = this.props;
    return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("p", null, "Please check your email inbox and follow the link in the message to verify your email address before finishing your account setup."), /*#__PURE__*/_react.default.createElement("p", null, "Once you're verified, click the button below to continue."), /*#__PURE__*/_react.default.createElement(DivSpacer, null, /*#__PURE__*/_react.default.createElement(_reactBootstrap.Button, {
      bsSize: "large",
      bsStyle: "primary",
      onClick: this._handleEmailVerified
    }, "My email is verified!")), /*#__PURE__*/_react.default.createElement(DivSpacer, {
      space: 1.5
    }, /*#__PURE__*/_react.default.createElement(_reactBootstrap.Button, {
      bsStyle: "link",
      onClick: resendVerificationEmail,
      style: {
        padding: '0px'
      }
    }, "Resend verification email")));
  }

} // connect to the redux store


const mapStateToProps = () => {
  return {};
};

const mapDispatchToProps = {
  resendVerificationEmail: userActions.resendVerificationEmail,
  routeTo: uiActions.routeTo
};

var _default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(VerifyEmailPane);

exports.default = _default;
module.exports = exports.default;

//# sourceMappingURL=verify-email-pane.js