"use strict";

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

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

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

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

var _UpdateProductPrice = require("../UpdateProductPrice");

var _SizeSelector = require("../SizeSelector");

var VariantsLoader = function VariantsLoader(_ref) {
  var slug = _ref.slug,
      updatePrice = _ref.updatePrice,
      priceState = _ref.priceState,
      openSelectSizeModal = _ref.openSelectSizeModal,
      handleClose = _ref.handleClose,
      variantId = _ref.variantId;

  var _productsApi$useProdu = _lib.productsApi.useProduct(slug),
      data = _productsApi$useProdu.data,
      isLoading = _productsApi$useProdu.isLoading;

  if (!data || isLoading) return null;
  return /*#__PURE__*/_react["default"].createElement(_lib.ProductProvider, {
    product: data
  }, /*#__PURE__*/_react["default"].createElement(_SizeSelector.SizeSelector, {
    defaultVariantId: data.masterVariantId,
    openSelectSizeModal: openSelectSizeModal,
    handleClose: handleClose,
    variantId: variantId
  }), /*#__PURE__*/_react["default"].createElement(_UpdateProductPrice.UpdateProductPrice, {
    priceState: priceState,
    updatePrice: updatePrice
  }));
};

exports.VariantsLoader = VariantsLoader;
//# sourceMappingURL=index.js.map