"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.mapStateToProps = exports.AppointmentFormComponent = exports.AppointmentForm = void 0;
var _react = _interopRequireDefault(require("react"));
var _store = require("../../../redux/store");
var _recompose = require("recompose");
var _bundleCommon = require("@kineticdata/bundle-common");
var _PageTitle = require("../../shared/PageTitle");
var _react2 = require("@kineticdata/react");
var AppointmentFormComponent = exports.AppointmentFormComponent = function AppointmentFormComponent(_ref) {
  var id = _ref.id,
    kapp = _ref.kapp,
    techBar = _ref.techBar;
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "page-container"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "page-panel"
  }, /*#__PURE__*/_react["default"].createElement(_PageTitle.PageTitle, {
    parts: ['Appointment Details', techBar.values['Name']],
    settings: true,
    breadcrumbs: [{
      label: 'Home',
      to: '/'
    }, {
      label: "".concat(kapp.name, " Settings"),
      to: '../../../..'
    }, {
      label: 'Tech Bars',
      to: '../../..'
    }, techBar && {
      label: techBar.values['Name'],
      to: '../..'
    }],
    title: "Appointment Details"
  }), techBar ? /*#__PURE__*/_react["default"].createElement("div", {
    className: "content-wrapper form-unstyled"
  }, /*#__PURE__*/_react["default"].createElement(_react2.I18n, {
    context: "kapps.".concat(kapp.slug, ".forms.appointment")
  }, /*#__PURE__*/_react["default"].createElement(_react2.CoreForm, {
    submission: id,
    review: true
  }))) : /*#__PURE__*/_react["default"].createElement(_bundleCommon.ErrorNotFound, null)));
};
var mapStateToProps = exports.mapStateToProps = function mapStateToProps(state, props) {
  var isSchedulerAdmin = (0, _bundleCommon.selectHasRoleSchedulerAdmin)(state.app.profile);
  var techBar = state.techBarApp.schedulers.find(function (scheduler) {
    return scheduler.id === props.techBarId && (isSchedulerAdmin || _bundleCommon.Utils.isMemberOf(state.app.profile, "Role::Scheduler::".concat(scheduler.values['Name'])) || _bundleCommon.Utils.isMemberOf(state.app.profile, "Scheduler::".concat(scheduler.values['Name'])));
  });
  return {
    kapp: state.app.kapp,
    techBar: techBar
  };
};
var AppointmentForm = exports.AppointmentForm = (0, _recompose.compose)((0, _store.connect)(mapStateToProps))(AppointmentFormComponent);