"use strict";

exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _provider = _interopRequireDefault(require("../provider"));
var _style = _interopRequireDefault(require("./style.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const PromoCode = (props, context) => {
  const {
    promoCodeDescription,
    promoCodeError,
    onValidate,
    handlePromoCodeChange
  } = props;
  const {
    translate
  } = context;
  return /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.promoCode
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.promoCodeInputAndButton
  }, /*#__PURE__*/_react.default.createElement("input", {
    type: "text",
    placeholder: translate('zuora_discount_code'),
    className: `
            ${_style.default.promoCodeInput}
            ${promoCodeError && _style.default.promoCodeButtonOnError}
            ${promoCodeDescription && _style.default.promoCodeButtonOnSuccess}
          `,
    onChange: handlePromoCodeChange
  }), /*#__PURE__*/_react.default.createElement("button", {
    type: "submit",
    onClick: onValidate,
    className: _style.default.promoCodeButton
  }, translate('zuora_discount_code_submit'))), promoCodeDescription ? /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.promoCodeDescription
  }, "-", promoCodeDescription) : null, promoCodeError ? /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.promoCodeError
  }, "-", promoCodeError) : null);
};
PromoCode.contextTypes = {
  translate: _provider.default.childContextTypes.translate
};
PromoCode.propTypes = process.env.NODE_ENV !== "production" ? {
  promoCodeDescription: _propTypes.default.string,
  promoCodeError: _propTypes.default.string,
  onValidate: _propTypes.default.func.isRequired,
  handlePromoCodeChange: _propTypes.default.func.isRequired
} : {};
var _default = exports.default = PromoCode;
//# sourceMappingURL=index.js.map