"use strict";

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

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

var _reactRouterDom = require("react-router-dom");

var _ = require("..");

var _classnames = _interopRequireDefault(require("classnames"));

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

var labelForStatus = function labelForStatus(status) {
  switch (status) {
    case 'incomplete':
      return 'Missing information';

    case 'complete':
      return 'Complete';

    case 'attentionNeeded':
      return 'Attention needed';

    case 'exempt':
      return '';
  }
};

function Step(_ref) {
  var name = _ref.name,
      status = _ref.status,
      editPath = _ref.editPath,
      Summary = _ref.Summary,
      Form = _ref.Form,
      props = _ref.props,
      _ref$headerLevel = _ref.headerLevel,
      headerLevel = _ref$headerLevel === void 0 ? 'h2' : _ref$headerLevel,
      _ref$type = _ref.type,
      type = _ref$type === void 0 ? 'normal' : _ref$type,
      EditComponent = _ref.EditComponent;
  var Heading = headerLevel;
  return /*#__PURE__*/_react.default.createElement("li", {
    className: (0, _classnames.default)('oec-step-list__step', "oec-step-list__step--".concat(status), {
      embedded: type === 'embedded'
    })
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: "oec-step-list__step__content"
  }, /*#__PURE__*/_react.default.createElement(Heading, {
    className: "oec-step-list__step__title"
  }, name), Summary && status !== 'notStarted' && status !== 'active' && /*#__PURE__*/_react.default.createElement("div", {
    className: "oec-step-list__step__summary"
  }, /*#__PURE__*/_react.default.createElement(Summary, props)), status === 'active' && /*#__PURE__*/_react.default.createElement("div", {
    className: "oec-step-list__step__form"
  }, /*#__PURE__*/_react.default.createElement(Form, props))), status !== 'exempt' && /*#__PURE__*/_react.default.createElement("div", {
    className: "oec-step-list__step__actions"
  }, status !== 'notStarted' && status !== 'active' && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
    className: "oec-step-list__step__status-text"
  }, /*#__PURE__*/_react.default.createElement(_.InlineIcon, {
    icon: status,
    provideScreenReaderFallback: false
  }), labelForStatus(status)), editPath && /*#__PURE__*/_react.default.createElement(_reactRouterDom.Link, {
    to: editPath,
    className: "usa-link"
  }, "Edit", /*#__PURE__*/_react.default.createElement("span", {
    className: "usa-sr-only"
  }, " ", name.toLowerCase())), EditComponent && /*#__PURE__*/_react.default.createElement(EditComponent, props))));
}