"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.mapStateToProps = exports.DisplayTabs = exports.DisplayComponent = exports.Display = void 0;
var _react = _interopRequireWildcard(require("react"));
var _store = require("../redux/store");
var _recompose = require("recompose");
var _bundleCommon = require("@kineticdata/bundle-common");
var _PageTitle = require("./shared/PageTitle");
var _router = require("@reach/router");
var _CheckIn = require("./CheckIn");
var _Feedback = require("./Feedback");
var _Overhead = require("./Overhead");
var _react2 = require("@kineticdata/react");
var DisplayTabs = exports.DisplayTabs = function DisplayTabs(_ref) {
  var techBarId = _ref.techBarId,
    _ref$checkInClassName = _ref.checkInClassName,
    checkInClassName = _ref$checkInClassName === void 0 ? '' : _ref$checkInClassName,
    _ref$feedbackClassNam = _ref.feedbackClassName,
    feedbackClassName = _ref$feedbackClassNam === void 0 ? '' : _ref$feedbackClassNam,
    onClick = _ref.onClick;
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "display-tabs"
  }, /*#__PURE__*/_react["default"].createElement(_router.Link, {
    to: "../checkin?crosslink",
    replace: true,
    className: "display-tab-link ".concat(checkInClassName),
    onClick: onClick
  }, /*#__PURE__*/_react["default"].createElement("span", null, /*#__PURE__*/_react["default"].createElement(_react2.I18n, null, "Check In"))), /*#__PURE__*/_react["default"].createElement(_router.Link, {
    to: "../feedback?crosslink",
    replace: true,
    className: "display-tab-link ".concat(feedbackClassName),
    onClick: onClick
  }, /*#__PURE__*/_react["default"].createElement("span", null, /*#__PURE__*/_react["default"].createElement(_react2.I18n, null, "Feedback"))));
};
var DisplayComponent = exports.DisplayComponent = function DisplayComponent(_ref2) {
  var navigate = _ref2.navigate,
    _ref2$location = _ref2.location,
    search = _ref2$location.search,
    pathname = _ref2$location.pathname,
    kapp = _ref2.kapp,
    techBar = _ref2.techBar,
    mode = _ref2.mode,
    hasTechBarDisplayRole = _ref2.hasTechBarDisplayRole;
  return !hasTechBarDisplayRole ? /*#__PURE__*/_react["default"].createElement(_bundleCommon.ErrorUnauthorized, null) : /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, /*#__PURE__*/_react["default"].createElement(_PageTitle.PageTitle, null), /*#__PURE__*/_react["default"].createElement("div", {
    className: "page-container"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "page-panel page-panel--display"
  }, techBar && /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
    className: "location-title"
  }, /*#__PURE__*/_react["default"].createElement("span", {
    className: "fa fa-fw fa-map-marker"
  }), /*#__PURE__*/_react["default"].createElement(_react2.I18n, null, techBar.values['Name'])), mode ? /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, mode === 'checkin' && /*#__PURE__*/_react["default"].createElement(_CheckIn.CheckIn, {
    techBar: techBar,
    crosslink: search.includes('crosslink') || pathname.includes('crosslink')
  }), mode === 'feedback' && /*#__PURE__*/_react["default"].createElement(_Feedback.Feedback, {
    techBar: techBar,
    crosslink: search.includes('crosslink') || pathname.includes('crosslink')
  }), mode === 'overhead' && /*#__PURE__*/_react["default"].createElement(_Overhead.Overhead, {
    techBar: techBar
  })) : /*#__PURE__*/_react["default"].createElement("section", {
    className: "tech-bar-display tech-bar-display--checkin"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "full-screen-container"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "header bg-dark"
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "body"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "row"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "col-3"
  }, /*#__PURE__*/_react["default"].createElement("button", {
    className: "btn btn-outline-dark btn-block",
    onClick: function onClick() {
      return navigate('checkin', {
        replace: true
      });
    }
  }, /*#__PURE__*/_react["default"].createElement(_react2.I18n, null, "Check In"))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "col-3"
  }, /*#__PURE__*/_react["default"].createElement("button", {
    className: "btn btn-outline-dark btn-block",
    onClick: function onClick() {
      return navigate('feedback', {
        replace: true
      });
    }
  }, /*#__PURE__*/_react["default"].createElement(_react2.I18n, null, "Feedback"))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "col-3"
  }, /*#__PURE__*/_react["default"].createElement("button", {
    className: "btn btn-outline-dark btn-block",
    onClick: function onClick() {
      return navigate('checkin?crosslink', {
        replace: true
      });
    }
  }, /*#__PURE__*/_react["default"].createElement(_react2.I18n, null, "Check In"), " / ", /*#__PURE__*/_react["default"].createElement(_react2.I18n, null, "Feedback"))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "col-3"
  }, /*#__PURE__*/_react["default"].createElement("button", {
    className: "btn btn-outline-dark btn-block",
    onClick: function onClick() {
      return navigate('overhead', {
        replace: true
      });
    }
  }, /*#__PURE__*/_react["default"].createElement(_react2.I18n, null, "Overhead")))))))), !techBar && /*#__PURE__*/_react["default"].createElement(_bundleCommon.ErrorNotFound, null))));
};
var mapStateToProps = exports.mapStateToProps = function mapStateToProps(state, props) {
  var techBar = state.techBarApp.schedulers.find(function (scheduler) {
    return scheduler.values['Id'] === props.techBarId;
  });
  return {
    kapp: (0, _bundleCommon.selectCurrentKapp)(state),
    techBar: techBar,
    hasTechBarDisplayRole: techBar && _bundleCommon.Utils.isMemberOf(state.app.profile, "Role::Tech Bar Display::".concat(techBar.values['Name']))
  };
};
var Display = exports.Display = (0, _recompose.compose)((0, _store.connect)(mapStateToProps))(DisplayComponent);