"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports.FormBottom = void 0;

var _taggedTemplateLiteralLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteralLoose"));

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

var _styledComponents = _interopRequireDefault(require("styled-components"));

var _Common = require("../../../Common");

var _reactHookForm = require("react-hook-form");

var _checkoutVoucher = require("../../checkoutVoucher.context");

var _lib = require("@sentecacommerce-theme/lib");

var _templateObject;

var FormBottom = function FormBottom() {
  var _useVoucherForm = (0, _checkoutVoucher.useVoucherForm)(),
      formControl = _useVoucherForm.formControl,
      errors = _useVoucherForm.errors,
      handleFormSubmit = _useVoucherForm.handleFormSubmit;

  var _useCardsContext = (0, _checkoutVoucher.useCardsContext)(),
      cardId = _useCardsContext.cardId,
      customAmount = _useCardsContext.customAmount;

  var _useGlobalLabels = (0, _lib.useGlobalLabels)(),
      buttons = _useGlobalLabels.buttons; // const labels = useStrings('checkoutVoucher');


  var isActive = cardId.length !== 0 || Number(customAmount) > 0;
  return /*#__PURE__*/_react["default"].createElement(InputsWrapper, null, /*#__PURE__*/_react["default"].createElement("div", {
    className: "col-12"
  }, /*#__PURE__*/_react["default"].createElement(_reactHookForm.Controller, {
    control: formControl,
    name: "additionalInfo",
    as: /*#__PURE__*/_react["default"].createElement(_Common.TextArea, null)
  }), /*#__PURE__*/_react["default"].createElement(_Common.FormError, {
    errors: errors,
    fieldName: "additionalInfo"
  })), /*#__PURE__*/_react["default"].createElement("div", {
    className: "col-12"
  }, /*#__PURE__*/_react["default"].createElement(_Common.Button, {
    onClick: handleFormSubmit,
    variant: !isActive ? 'disabled' : 'primary',
    borderRadius: "normal",
    fullWidth: true
  }, buttons.addToBag)));
};

exports.FormBottom = FormBottom;

var InputsWrapper = _styledComponents["default"].div.attrs({
  className: 'row g-4'
})(_templateObject || (_templateObject = (0, _taggedTemplateLiteralLoose2["default"])(["\n  & textarea {\n    margin-top: 0;\n  }\n"])));
//# sourceMappingURL=index.js.map