"use strict";

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

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

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

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

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

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

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

var _templateObject, _templateObject2;

var DiscountCode = function DiscountCode(_ref) {
  var data = _ref.data;

  var _usePrice = (0, _lib.usePrice)({
    price: (data == null ? void 0 : data.discountedAmount) || undefined // TODO: remove any after sdk update

  }),
      price = _usePrice.price;

  var _useCheckoutDiscountC = (0, _lib.useCheckoutDiscountCode)(),
      handleDiscountCodeRemove = _useCheckoutDiscountC.handleDiscountCodeRemove;

  var code = data.discountCode.resource.code;
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(CodeCon, null, "#", code, /*#__PURE__*/_react["default"].createElement("span", {
    className: "d-flex align-items-center justify-content-center"
  }, /*#__PURE__*/_react["default"].createElement(_Common.IconClose, {
    onClick: function onClick() {
      return handleDiscountCodeRemove({
        code: code
      });
    },
    className: "pl-2"
  }))), /*#__PURE__*/_react["default"].createElement(PriceCon, null, /*#__PURE__*/_react["default"].createElement(_Common.Price, {
    currency: price.currency,
    size: "tiny",
    price: -price.value
  })));
};

exports.DiscountCode = DiscountCode;

var CodeCon = _styledComponents["default"].div.attrs({
  className: 'd-flex align-items-center justify-content-start pr-4'
})(_templateObject || (_templateObject = (0, _taggedTemplateLiteralLoose2["default"])(["\n  line-height: 1;\n  font-weight: bold;\n\n  & svg {\n    width: 1.6rem;\n    cursor: pointer;\n    color: ", ";\n\n    &:hover {\n      color: ", ";\n    }\n  }\n"])), function (_ref2) {
  var theme = _ref2.theme;
  return theme.palette.hint;
}, function (_ref3) {
  var theme = _ref3.theme;
  return theme.palette.primary;
});

var PriceCon = _styledComponents["default"].div.attrs({
  className: 'd-flex align-items-center justify-content-end'
})(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteralLoose2["default"])(["\n  height: auto;\n  font-weight: bold;\n\n  & * {\n    font-size: 1.6rem !important;\n  }\n"])));
//# sourceMappingURL=index.js.map