'use strict';

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

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

exports.default = ReportViewerPage;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var _ContentViewerPage = require('./ContentViewerPage');

var _ContentViewerPage2 = _interopRequireDefault(_ContentViewerPage);

var _getErrorDescription = require('../../helpers/getErrorDescription');

var _getErrorDescription2 = _interopRequireDefault(_getErrorDescription);

var _ReportViewerPage = require('../../../styles/cspace-ui/ReportViewerPage.css');

var _ReportViewerPage2 = _interopRequireDefault(_ReportViewerPage);

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

var messages = (0, _reactIntl.defineMessages)({
  error: {
    'id': 'reportViewerPage.error',
    'defaultMessage': 'Error running report: {error}'
  },
  loading: {
    'id': 'reportViewerPage.loading',
    'defaultMessage': 'Generating report\u2026'
  }
});

var renderLoading = function renderLoading() {
  return _react2.default.createElement(
    'div',
    { className: _ReportViewerPage2.default.pending },
    _react2.default.createElement(_reactIntl.FormattedMessage, messages.loading)
  );
};

var renderError = function renderError(error) {
  return _react2.default.createElement(
    'div',
    { className: _ReportViewerPage2.default.error },
    _react2.default.createElement(_reactIntl.FormattedMessage, _extends({}, messages.error, {
      values: {
        error: (0, _getErrorDescription2.default)(error)
      }
    }))
  );
};

function ReportViewerPage(props) {
  return _react2.default.createElement(_ContentViewerPage2.default, _extends({
    renderError: renderError,
    renderLoading: renderLoading
  }, props));
}