'use strict';

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

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var _propTypes2 = _interopRequireDefault(_propTypes);

var _immutable = require('immutable');

var _immutable2 = _interopRequireDefault(_immutable);

var _Header = require('../sections/Header');

var _Header2 = _interopRequireDefault(_Header);

var _Footer = require('../sections/Footer');

var _Footer2 = _interopRequireDefault(_Footer);

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

var propTypes = {
  decorated: _propTypes2.default.bool,
  history: _propTypes2.default.object,
  perms: _propTypes2.default.instanceOf(_immutable2.default.Map),
  screenName: _propTypes2.default.string,
  username: _propTypes2.default.string.isRequired,
  children: _propTypes2.default.node
};

var defaultProps = {
  decorated: true
};

function ProtectedPage(props) {
  var decorated = props.decorated,
      history = props.history,
      perms = props.perms,
      screenName = props.screenName,
      username = props.username,
      children = props.children;


  var header = decorated ? _react2.default.createElement(_Header2.default, { history: history, perms: perms, screenName: screenName || username }) : null;

  var footer = decorated ? _react2.default.createElement(_Footer2.default, null) : null;

  return _react2.default.createElement(
    'div',
    null,
    header,
    children,
    footer
  );
}

ProtectedPage.propTypes = propTypes;
ProtectedPage.defaultProps = defaultProps;