import React, { Fragment } from 'react';
import { connect } from '../../../redux/store';
import { compose } from 'recompose';
import { Utils, ErrorNotFound, selectHasRoleSchedulerAdmin } from '@kineticdata/bundle-common';
import { PageTitle } from '../../shared/PageTitle';
import { Link } from '@reach/router';
import { CoreForm, I18n } from '@kineticdata/react';
export var AppointmentFormComponent = function AppointmentFormComponent(_ref) {
  var id = _ref.id,
      kapp = _ref.kapp,
      techBar = _ref.techBar;
  return techBar ? /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(PageTitle, {
    parts: ['Appointment Details', techBar.values['Name']],
    settings: true
  }), /*#__PURE__*/React.createElement("div", {
    className: "page-container"
  }, /*#__PURE__*/React.createElement("div", {
    className: "page-panel page-panel--white"
  }, /*#__PURE__*/React.createElement("div", {
    className: "page-title"
  }, /*#__PURE__*/React.createElement("div", {
    role: "navigation",
    "aria-label": "breadcrumbs",
    className: "page-title__breadcrumbs"
  }, /*#__PURE__*/React.createElement("span", {
    className: "breadcrumb-item"
  }, /*#__PURE__*/React.createElement(Link, {
    to: "../../../../../"
  }, /*#__PURE__*/React.createElement(I18n, null, "tech bar"))), ' ', /*#__PURE__*/React.createElement("span", {
    "aria-hidden": "true"
  }, "/ "), /*#__PURE__*/React.createElement("span", {
    className: "breadcrumb-item"
  }, /*#__PURE__*/React.createElement(Link, {
    to: "../../../../"
  }, /*#__PURE__*/React.createElement(I18n, null, "settings"))), ' ', /*#__PURE__*/React.createElement("span", {
    "aria-hidden": "true"
  }, "/ "), /*#__PURE__*/React.createElement("span", {
    className: "breadcrumb-item"
  }, /*#__PURE__*/React.createElement(Link, {
    to: "../../../"
  }, /*#__PURE__*/React.createElement(I18n, null, "tech bars"))), ' ', /*#__PURE__*/React.createElement("span", {
    "aria-hidden": "true"
  }, "/ "), /*#__PURE__*/React.createElement("span", {
    className: "breadcrumb-item"
  }, /*#__PURE__*/React.createElement(Link, {
    to: "../../"
  }, /*#__PURE__*/React.createElement(I18n, null, techBar.values['Name']))), ' ', /*#__PURE__*/React.createElement("span", {
    "aria-hidden": "true"
  }, "/ "), /*#__PURE__*/React.createElement("h1", null, /*#__PURE__*/React.createElement(I18n, null, "Appointment Details")))), /*#__PURE__*/React.createElement("div", {
    className: "content-wrapper form-unstyled"
  }, /*#__PURE__*/React.createElement(I18n, {
    context: "kapps.".concat(kapp.slug, ".forms.appointment")
  }, /*#__PURE__*/React.createElement(CoreForm, {
    submission: id,
    review: true
  })))))) : /*#__PURE__*/React.createElement(ErrorNotFound, null);
};
export var mapStateToProps = function mapStateToProps(state, props) {
  var isSchedulerAdmin = selectHasRoleSchedulerAdmin(state.app.profile);
  var techBar = state.techBarApp.schedulers.find(function (scheduler) {
    return scheduler.id === props.techBarId && (isSchedulerAdmin || Utils.isMemberOf(state.app.profile, "Role::Scheduler::".concat(scheduler.values['Name'])) || Utils.isMemberOf(state.app.profile, "Scheduler::".concat(scheduler.values['Name'])));
  });
  return {
    kapp: state.app.kapp,
    techBar: techBar
  };
};
export var AppointmentForm = compose(connect(mapStateToProps))(AppointmentFormComponent);