"use strict";

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

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

var _propTypes = _interopRequireDefault(require("prop-types"));

var _reactRouterDom = require("react-router-dom");

var _reactstrap = require("reactstrap");

var _react2 = require("@coreui/react");

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

function _extends() { _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; }; return _extends.apply(this, arguments); }

function BackendHeader(_ref) {
  var props = _extends({}, _ref);

  // eslint-disable-next-line
  var notificationItems = props.notificationItems,
      navMenuItems = props.navMenuItems;
  return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_react2.AppSidebarToggler, {
    className: "d-lg-none",
    display: "md",
    mobile: true
  }), _react.default.createElement(_react2.AppNavbarBrand, {
    full: props.fullAppLogo,
    minimized: props.miniAppLogo
  }), _react.default.createElement(_react2.AppSidebarToggler, {
    className: "d-md-down-none",
    display: "lg"
  }), _react.default.createElement(_reactstrap.Nav, {
    className: "d-md-down-none",
    navbar: true
  }, navMenuItems && navMenuItems.length > 0 && navMenuItems.map(function (item, index) {
    return _react.default.createElement(_reactstrap.NavItem, {
      className: "px-3",
      key: index
    }, _react.default.createElement(_reactRouterDom.NavLink, {
      to: item.link,
      className: "nav-link"
    }, item.text));
  })), _react.default.createElement(_reactstrap.Nav, {
    className: "ml-auto",
    navbar: true
  }, _react.default.createElement(_reactstrap.UncontrolledDropdown, {
    nav: true,
    direction: "down"
  }, _react.default.createElement(_reactstrap.DropdownToggle, {
    nav: true
  }, _react.default.createElement("i", {
    className: "icon-bell"
  }), _react.default.createElement(_reactstrap.Badge, {
    pill: true,
    color: "danger"
  }, props.notificationItems.length)), _react.default.createElement(_reactstrap.DropdownMenu, null, _react.default.createElement(_reactstrap.DropdownItem, {
    header: true,
    tag: "div",
    className: "text-center"
  }, _react.default.createElement("strong", null, "You have ", props.notificationItems.length, " notifications")), notificationItems && notificationItems.length > 0 ? notificationItems.map(function (value, index) {
    return _react.default.createElement(_reactstrap.DropdownItem, {
      key: index
    }, _react.default.createElement("i", {
      className: "fa fa-circle-o"
    }), " ", value.text);
  }) : _react.default.createElement(_reactstrap.DropdownItem, null, props.textNoNotification))), _react.default.createElement(_reactstrap.UncontrolledDropdown, {
    nav: true,
    direction: "down"
  }, _react.default.createElement(_reactstrap.DropdownToggle, {
    nav: true
  }, _react.default.createElement("img", {
    src: props.userAvatarUri,
    className: "img-avatar",
    alt: "img-avatar"
  }), _react.default.createElement("span", {
    className: "name"
  }, props.userName)), _react.default.createElement(_reactstrap.DropdownMenu, {
    right: true
  }, _react.default.createElement(_reactstrap.DropdownItem, {
    header: true,
    tag: "div",
    className: "text-center"
  }, _react.default.createElement("strong", null, "Account")), _react.default.createElement(_reactstrap.DropdownItem, {
    onClick: function onClick(e) {
      return props.onLogout && props.onLogout(e);
    }
  }, _react.default.createElement("i", {
    className: "fa fa-lock"
  }), props.textLogout)))));
}

BackendHeader.propTypes = {
  fullAppLogo: _propTypes.default.object,
  miniAppLogo: _propTypes.default.object,
  userName: _propTypes.default.string.isRequired,
  userAvatarUri: _propTypes.default.string,
  onLogout: _propTypes.default.func.isRequired,
  textLogout: _propTypes.default.string,
  textNoNotification: _propTypes.default.string,
  notificationItems: _propTypes.default.array,
  navMenuItems: _propTypes.default.array
};
BackendHeader.defaultProps = {
  fullAppLogo: {
    src: require('../../assets/images/no-logo.png'),
    height: 25,
    alt: "app-logo"
  },
  miniAppLogo: {
    src: require('../../assets/images/no-logo-mini.png'),
    height: 30,
    alt: "app-logo"
  },
  userName: 'None',
  userAvatarUri: require('../../assets/images/blank-avatar.png'),
  textLogout: 'Logout',
  textNoNotification: 'No Notification',
  notificationItems: [],
  navMenuItems: []
};
var _default = BackendHeader;
exports.default = _default;