"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.SettingsNavigation = exports.SettingsComponent = exports.Settings = void 0;
var _react = _interopRequireDefault(require("react"));
var _router = require("@reach/router");
var _store = require("../../redux/store");
var _recompose = require("recompose");
var _bundleCommon = require("@kineticdata/bundle-common");
var _PageTitle = require("../shared/PageTitle");
var _SchedulerSettings = require("./SchedulerSettings");
var _TechBarMetrics = require("./TechBarMetrics");
var _TechBarSettings = require("./TechBarSettings");
var _TechBar = require("./tech-bar/TechBar");
var _TechBarSettingsForm = require("./tech-bar/TechBarSettingsForm");
var _AppointmentForm = require("./tech-bar/AppointmentForm");
var _react2 = require("@kineticdata/react");
var SettingsComponent = exports.SettingsComponent = function SettingsComponent(_ref) {
  var kappSlug = _ref.kappSlug,
    hasSettingsAccess = _ref.hasSettingsAccess;
  return hasSettingsAccess ? /*#__PURE__*/_react["default"].createElement(_router.Router, null, /*#__PURE__*/_react["default"].createElement(_TechBarMetrics.TechBarMetrics, {
    path: "metrics/:mode"
  }), /*#__PURE__*/_react["default"].createElement(_TechBarMetrics.TechBarMetrics, {
    path: "metrics"
  }), /*#__PURE__*/_react["default"].createElement(_AppointmentForm.AppointmentForm, {
    path: "general/:techBarId/appointment/:id"
  }), /*#__PURE__*/_react["default"].createElement(_TechBarSettingsForm.TechBarSettingsForm, {
    path: "general/:techBarId/edit"
  }), /*#__PURE__*/_react["default"].createElement(_TechBar.TechBar, {
    path: "general/:techBarId"
  }), /*#__PURE__*/_react["default"].createElement(_TechBarSettings.TechBarSettings, {
    path: "general"
  }), /*#__PURE__*/_react["default"].createElement(_SchedulerSettings.SchedulerSettings, {
    path: "schedulers/*"
  }), /*#__PURE__*/_react["default"].createElement(SettingsNavigation, {
    "default": true
  })) : /*#__PURE__*/_react["default"].createElement(_bundleCommon.ErrorUnauthorized, null);
};
var mapStateToProps = function mapStateToProps(state, props) {
  return {
    kappSlug: state.app.kappSlug,
    hasSettingsAccess: (0, _bundleCommon.selectHasRoleSchedulerAgent)(state.app.profile) || (0, _bundleCommon.selectHasRoleSchedulerManager)(state.app.profile) || (0, _bundleCommon.selectHasRoleSchedulerAdmin)(state.app.profile)
  };
};
var mapDispatchToProps = {};
var Settings = exports.Settings = (0, _recompose.compose)((0, _store.connect)(mapStateToProps, mapDispatchToProps))(SettingsComponent);
var SettingsCard = function SettingsCard(_ref2) {
  var path = _ref2.path,
    icon = _ref2.icon,
    name = _ref2.name,
    description = _ref2.description;
  return /*#__PURE__*/_react["default"].createElement(_bundleCommon.Card, {
    to: path,
    color: "light",
    components: {
      Link: _router.Link
    },
    bar: true,
    barColor: "dark",
    barSize: "xs"
  }, /*#__PURE__*/_react["default"].createElement(_bundleCommon.CardCol, null, /*#__PURE__*/_react["default"].createElement(_bundleCommon.CardRow, {
    type: "title"
  }, /*#__PURE__*/_react["default"].createElement("span", {
    className: "fa fa-".concat((icon || 'cog').replace(/^fa-/i, ''), " fa-fw fa-rounded bg-dark")
  }), /*#__PURE__*/_react["default"].createElement("span", null, /*#__PURE__*/_react["default"].createElement(_react2.I18n, null, name))), /*#__PURE__*/_react["default"].createElement(_bundleCommon.CardRow, {
    className: "text-muted"
  }, description)));
};
var SettingsNavigationComponent = function SettingsNavigationComponent(_ref3) {
  var kapp = _ref3.kapp,
    hasManagerAccess = _ref3.hasManagerAccess;
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "page-container"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "page-panel"
  }, /*#__PURE__*/_react["default"].createElement(_PageTitle.PageTitle, {
    settings: true,
    breadcrumbs: [{
      label: 'Home',
      to: '/'
    }],
    title: "".concat(kapp.name, " Settings")
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "cards cards--seconds"
  }, /*#__PURE__*/_react["default"].createElement(SettingsCard, {
    name: "Metrics",
    path: "metrics",
    icon: "fa-bar-chart",
    description: "View metrics for the Tech Bars."
  }), /*#__PURE__*/_react["default"].createElement(SettingsCard, {
    name: "Tech Bars",
    path: "general",
    icon: "fa-gear",
    description: "View and modify Tech Bar settings."
  }), hasManagerAccess && /*#__PURE__*/_react["default"].createElement(SettingsCard, {
    name: "Schedulers",
    path: "schedulers",
    icon: "fa-calendar",
    description: "View and modify scheduler settings, including event types and availability."
  }))));
};
var mapStateToPropsNav = function mapStateToPropsNav(state) {
  return {
    kapp: state.app.kapp,
    hasManagerAccess: (0, _bundleCommon.selectHasRoleSchedulerManager)(state.app.profile) || (0, _bundleCommon.selectHasRoleSchedulerAdmin)(state.app.profile)
  };
};
var SettingsNavigation = exports.SettingsNavigation = (0, _recompose.compose)((0, _store.connect)(mapStateToPropsNav))(SettingsNavigationComponent);