"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _react = _interopRequireDefault(require("react"));

var _backLink = _interopRequireDefault(require("../back-link"));

var _stackedPaneDisplay = _interopRequireDefault(require("../stacked-pane-display"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
 * This component handles editing of an existing trip.
 */
const SavedTripEditor = props => {
  // The props include Formik props that provide access to the current trip data (stored in props.values)
  // and to its own blur/change/submit event handlers that automate the state.
  // We forward the props to each pane so that their individual controls
  // can be wired to be managed by Formik.
  const {
    isCreating,
    onCancel,
    panes,
    values: monitoredTrip
  } = props;

  if (monitoredTrip) {
    const paneSequence = [{
      pane: panes.basics,
      props,
      title: 'Trip information'
    }, {
      pane: panes.notifications,
      props,
      title: 'Trip notifications'
    }];
    return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_backLink.default, null), /*#__PURE__*/_react.default.createElement(_stackedPaneDisplay.default, {
      onCancel: onCancel,
      paneSequence: paneSequence,
      title: isCreating ? 'Save new trip' : 'Edit saved trip'
    }));
  }

  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("h1", null, "Trip Not Found"), /*#__PURE__*/_react.default.createElement("p", null, "Sorry, the requested trip was not found."));
};

var _default = SavedTripEditor;
exports.default = _default;
module.exports = exports.default;

//# sourceMappingURL=saved-trip-editor.js