"use strict";

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

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

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

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

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

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

var _Icons = require("../Icons");

var _templateObject, _templateObject2, _templateObject3;

var PromoCodeList = function PromoCodeList() {
  var _useCheckoutDiscountC = (0, _lib.useCheckoutDiscountCode)(),
      handleDiscountCodeRemove = _useCheckoutDiscountC.handleDiscountCodeRemove,
      appliedCodes = _useCheckoutDiscountC.appliedCodes;

  var removeCode = function removeCode(code) {
    return function () {
      handleDiscountCodeRemove({
        code: code
      });
    };
  };

  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, (appliedCodes == null ? void 0 : appliedCodes.map(function (data) {
    var code = data.discountCode.resource.code;
    return /*#__PURE__*/_react["default"].createElement(PromoCodeCard, {
      key: "Code__" + data.discountCode.resourceId
    }, /*#__PURE__*/_react["default"].createElement(Code, null, "#", code), /*#__PURE__*/_react["default"].createElement(RemoveContainer, {
      onClick: removeCode(code)
    }, /*#__PURE__*/_react["default"].createElement(_Icons.IconClose, null)));
  })) || null);
};

exports.PromoCodeList = PromoCodeList;

var Code = _styledComponents["default"].span(_templateObject || (_templateObject = (0, _taggedTemplateLiteralLoose2["default"])(["\n  font-size: 1.4rem;\n"])));

var RemoveContainer = _styledComponents["default"].button.attrs({
  type: 'button',
  className: 'p-0'
})(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteralLoose2["default"])(["\n  background: 0 !important;\n  width: 1rem !important;\n  min-height: 1.4rem !important;\n  height: 1rem !important;\n  line-height: 1 !important;\n\n  & svg {\n    width: 1rem;\n    height: 1rem;\n    fill: ", ";\n  }\n"])), function (_ref) {
  var theme = _ref.theme;
  return theme.palette.secondary;
});

var PromoCodeCard = _styledComponents["default"].div.attrs({
  className: 'mb-3'
})(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteralLoose2["default"])(["\n  padding: 0.6rem 1.2rem;\n  background: ", ";\n  color: ", ";\n  border-radius: 0.3rem;\n\n  display: flex;\n  justify-content: space-between;\n  align-items: center;\n"])), function (_ref2) {
  var theme = _ref2.theme;
  return theme.palette.primary;
}, function (_ref3) {
  var theme = _ref3.theme;
  return theme.palette.secondary;
});
//# sourceMappingURL=index.js.map