"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.App = void 0;
var _react = _interopRequireDefault(require("react"));
var _router = require("@reach/router");
var _recompose = require("recompose");
var _store = require("./redux/store");
var _bundleCommon = require("@kineticdata/bundle-common");
var _react2 = require("@kineticdata/react");
var _PageTitle = require("./components/shared/PageTitle");
var _Home = require("./components/Home");
var _Past = require("./components/Past");
var _TechBars = require("./components/TechBars");
var _Display = require("./components/Display");
var _Form = require("./components/Form");
var _AppointmentForm = require("./components/AppointmentForm");
var _Settings = require("./components/settings/Settings");
var _techBarApp = require("./redux/modules/techBarApp");
var AppComponent = function AppComponent(props) {
  return props.render({
    main: props.error ? /*#__PURE__*/_react["default"].createElement(_bundleCommon.ErrorMessage, {
      title: "Unexpected Error",
      message: "Sorry, an unexpected error has occurred!"
    }) : props.loading ? /*#__PURE__*/_react["default"].createElement(_bundleCommon.LoadingMessage, null) : /*#__PURE__*/_react["default"].createElement(_react2.I18n, null, /*#__PURE__*/_react["default"].createElement("main", {
      className: "package-layout package-layout--tech-bar"
    }, /*#__PURE__*/_react["default"].createElement(_PageTitle.PageTitle, {
      parts: ['Loading...']
    }), /*#__PURE__*/_react["default"].createElement(_router.Router, null, /*#__PURE__*/_react["default"].createElement(_Settings.Settings, {
      path: "settings/*"
    }), /*#__PURE__*/_react["default"].createElement(_Home.Home, {
      path: "/"
    }), /*#__PURE__*/_react["default"].createElement(_TechBars.TechBars, {
      path: "/tech-bars"
    }), /*#__PURE__*/_react["default"].createElement(_AppointmentForm.AppointmentForm, {
      path: "/past/appointment/:techBarId/:id"
    }), /*#__PURE__*/_react["default"].createElement(_Past.Past, {
      path: "/past"
    }), /*#__PURE__*/_react["default"].createElement(_AppointmentForm.AppointmentForm, {
      path: "/appointment/:techBarId/:id"
    }), /*#__PURE__*/_react["default"].createElement(_AppointmentForm.AppointmentForm, {
      path: "/appointment/:techBarId"
    }), /*#__PURE__*/_react["default"].createElement(_AppointmentForm.AppointmentForm, {
      path: "/appointment/:id"
    }), /*#__PURE__*/_react["default"].createElement(_AppointmentForm.AppointmentForm, {
      path: "/appointment"
    }), /*#__PURE__*/_react["default"].createElement(_Form.Form, {
      path: "/forms/:formSlug/submissions/:id"
    }), /*#__PURE__*/_react["default"].createElement(_Form.Form, {
      path: "/forms/:formSlug"
    }), /*#__PURE__*/_react["default"].createElement(_Display.Display, {
      path: "/display/:techBarId/:mode"
    }), /*#__PURE__*/_react["default"].createElement(_Display.Display, {
      path: "/display/:techBarId"
    }))))
  });
};
var mapStateToProps = function mapStateToProps(state, props) {
  return {
    loading: state.techBarApp.loading,
    error: state.techBarApp.error,
    settingsBackPath: "/kapps/".concat(state.app.kappSlug)
  };
};
var mapDispatchToProps = {
  fetchAppDataRequest: _techBarApp.actions.fetchAppDataRequest
};
var enhance = (0, _recompose.compose)((0, _store.connect)(mapStateToProps, mapDispatchToProps), (0, _recompose.lifecycle)({
  componentDidMount: function componentDidMount() {
    this.props.fetchAppDataRequest();
  }
}));
var App = exports.App = enhance(AppComponent);