import React from 'react';
import PropTypes from 'prop-types';
import Provider from '../provider';
import style from './style.css';
const PromoCode = (props, context) => {
  const {
    promoCodeDescription,
    promoCodeError,
    onValidate,
    handlePromoCodeChange
  } = props;
  const {
    translate
  } = context;
  return /*#__PURE__*/React.createElement("div", {
    className: style.promoCode
  }, /*#__PURE__*/React.createElement("div", {
    className: style.promoCodeInputAndButton
  }, /*#__PURE__*/React.createElement("input", {
    type: "text",
    placeholder: translate('zuora_discount_code'),
    className: `
            ${style.promoCodeInput}
            ${promoCodeError && style.promoCodeButtonOnError}
            ${promoCodeDescription && style.promoCodeButtonOnSuccess}
          `,
    onChange: handlePromoCodeChange
  }), /*#__PURE__*/React.createElement("button", {
    type: "submit",
    onClick: onValidate,
    className: style.promoCodeButton
  }, translate('zuora_discount_code_submit'))), promoCodeDescription ? /*#__PURE__*/React.createElement("div", {
    className: style.promoCodeDescription
  }, "-", promoCodeDescription) : null, promoCodeError ? /*#__PURE__*/React.createElement("div", {
    className: style.promoCodeError
  }, "-", promoCodeError) : null);
};
PromoCode.contextTypes = {
  translate: Provider.childContextTypes.translate
};
PromoCode.propTypes = process.env.NODE_ENV !== "production" ? {
  promoCodeDescription: PropTypes.string,
  promoCodeError: PropTypes.string,
  onValidate: PropTypes.func.isRequired,
  handlePromoCodeChange: PropTypes.func.isRequired
} : {};
export default PromoCode;
//# sourceMappingURL=index.js.map