"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = ResetPasswordPage;
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _reactIntl = require("react-intl");
var _get = _interopRequireDefault(require("lodash/get"));
var _qs = _interopRequireDefault(require("qs"));
var _PasswordResetFormContainer = _interopRequireDefault(require("../../containers/user/PasswordResetFormContainer"));
var _PasswordResetRequestFormContainer = _interopRequireDefault(require("../../containers/user/PasswordResetRequestFormContainer"));
var _ResetPasswordPage = _interopRequireDefault(require("../../../styles/cspace-ui/ResetPasswordPage.css"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const messages = (0, _reactIntl.defineMessages)({
  title: {
    "id": "resetPasswordPage.title",
    "defaultMessage": "Reset Password"
  }
});
const propTypes = {
  location: _propTypes.default.shape({
    search: _propTypes.default.string,
    state: _propTypes.default.object
  }).isRequired
};
function ResetPasswordPage(props) {
  const {
    location
  } = props;
  const query = _qs.default.parse(location.search, {
    ignoreQueryPrefix: true
  });
  const {
    token
  } = query;
  const form = token ? /*#__PURE__*/_react.default.createElement(_PasswordResetFormContainer.default, {
    token: token
  }) : /*#__PURE__*/_react.default.createElement(_PasswordResetRequestFormContainer.default, {
    email: (0, _get.default)(location, ['state', 'username'])
  });
  return /*#__PURE__*/_react.default.createElement("div", {
    className: _ResetPasswordPage.default.common
  }, /*#__PURE__*/_react.default.createElement("h1", null, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, messages.title)), form);
}
ResetPasswordPage.propTypes = propTypes;