client/components/pages/parts/call-to-action.js

"use strict";

require("core-js/modules/es.weak-map.js");
require("core-js/modules/es.object.get-own-property-descriptor.js");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
require("core-js/modules/es.array.iterator.js");
require("core-js/modules/es.object.to-string.js");
require("core-js/modules/es.string.iterator.js");
require("core-js/modules/web.dom-collections.iterator.js");
require("core-js/modules/web.url-search-params.js");
require("core-js/modules/es.array.concat.js");
require("core-js/modules/es.array.map.js");
var _camelCase2 = _interopRequireDefault(require("lodash/camelCase"));
var bootstrap = _interopRequireWildcard(require("react-bootstrap"));
var _propTypes = require("prop-types");
var _react = _interopRequireDefault(require("react"));
var _entity = require("../../../helpers/entity");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/*
 * Copyright (C) 2015  Ohm Patel
 *               2016  Sean Burke
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

var Button = bootstrap.Button,
  ButtonGroup = bootstrap.ButtonGroup;

/**
 * Renders the document and displays 'CallToAction' component.
 * @returns {ReactElement} a HTML document which displays
 * @param {object} props - Properties passed to the component.
 * the 'CallToAction' component.
 */
function CallToAction(props) {
  var seedingParameters = new URLSearchParams({
    name: props.query
  });
  function renderEntityLink(type) {
    return /*#__PURE__*/_react.default.createElement("a", {
      href: "/".concat((0, _camelCase2.default)(type), "/create?").concat(seedingParameters)
    }, /*#__PURE__*/_react.default.createElement(Button, {
      className: "padding-bottom-1 padding-sides-2 padding-top-1",
      variant: "secondary"
    }, (0, _entity.genEntityIconHTMLElement)(type, '3x', false), /*#__PURE__*/_react.default.createElement("div", {
      className: "margin-top-d4"
    }, type)));
  }
  var entityTypes = ['Author', 'Work', 'Edition', 'Series', 'Publisher'];
  return /*#__PURE__*/_react.default.createElement("div", {
    className: "text-center"
  }, /*#__PURE__*/_react.default.createElement("p", null, "Help us and click on the right entity below to create a new entry.", /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement("small", null, "Not sure what to do? Visit the ", /*#__PURE__*/_react.default.createElement("a", {
    href: "/help"
  }, "help page"), " to get started.")), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(ButtonGroup, {
    id: "searchpage-button-group"
  }, entityTypes.map(renderEntityLink))));
}
CallToAction.displayName = 'CallToAction';
CallToAction.propTypes = {
  query: _propTypes.PropTypes.string
};
CallToAction.defaultProps = {
  query: null
};
var _default = CallToAction;
exports.default = _default;
//# sourceMappingURL=call-to-action.js.map