"use strict";

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

exports.__esModule = true;
exports.SizeSelector = 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 _lib = require("@sentecacommerce-theme/lib");

var _templateObject;

var SizeSelector = function SizeSelector(_ref) {
  var openSelectSizeModal = _ref.openSelectSizeModal,
      handleClose = _ref.handleClose,
      variantId = _ref.variantId;

  var _useProductState = (0, _lib.useProductState)(),
      metaData = _useProductState.metaData;

  var _useProductFunctions = (0, _lib.useProductFunctions)(),
      selectVariantById = _useProductFunctions.selectVariantById;

  _react["default"].useEffect(function () {
    selectVariantById(variantId);
  }, [variantId]);

  var _useSizesReducer = (0, _lib.useSizesReducer)(),
      state = _useSizesReducer.state,
      setSize = _useSizesReducer.setSize,
      clearSize = _useSizesReducer.clearSize;

  var onClose = function onClose() {
    handleClose();
    clearSize();
  };

  return /*#__PURE__*/_react["default"].createElement(Container, null, /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_Common.SelectSizeModal, {
    open: openSelectSizeModal,
    handleClose: onClose,
    title: metaData.name,
    stateSizeId: state.sizeId,
    setStateSizeId: setSize
  })));
};

exports.SizeSelector = SizeSelector;

var Container = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteralLoose2["default"])([""])));
//# sourceMappingURL=index.js.map