'use strict';

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

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _reactIntl = require('react-intl');

var _cspaceLayout = require('cspace-layout');

var _LoginFormContainer = require('../../containers/login/LoginFormContainer');

var _LoginFormContainer2 = _interopRequireDefault(_LoginFormContainer);

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

const formId = 'loginModal.loginForm';

const renderButtonBar = () => null;

const messages = (0, _reactIntl.defineMessages)({
  title: {
    'id': 'loginModal.title',
    'defaultMessage': 'Sign In'
  }
});

const propTypes = {
  isOpen: _propTypes2.default.bool,
  onCloseButtonClick: _propTypes2.default.func,
  onSuccess: _propTypes2.default.func
};

function LoginModal(props) {
  const isOpen = props.isOpen,
        onCloseButtonClick = props.onCloseButtonClick,
        onSuccess = props.onSuccess;


  if (!isOpen) {
    return null;
  }

  return _react2.default.createElement(
    _cspaceLayout.Modal,
    {
      isOpen: isOpen,
      title: _react2.default.createElement(
        'h1',
        null,
        _react2.default.createElement(_reactIntl.FormattedMessage, messages.title)
      ),
      closeButtonClassName: 'material-icons',
      closeButtonLabel: 'close',
      renderButtonBar: renderButtonBar,
      onCloseButtonClick: onCloseButtonClick
    },
    _react2.default.createElement(_LoginFormContainer2.default, {
      formId: formId,
      isExpired: true,
      showForgotLink: false,
      showHeader: false,
      onSuccess: onSuccess
    })
  );
}

LoginModal.modalName = 'LoginModal';
LoginModal.propTypes = propTypes;