import documentReady from '@assets/js/documentReady';
import FixedContentOnScroll from '../../fixed-content';
import seeKitProducts from '../../see-kit-products';

documentReady(() => {
  new FixedContentOnScroll(document.querySelector('.js-fixed-on-top'), {
    discountTop: [document.querySelector('.js-header__main')],
  });
  seeKitProducts();

  const reorderButton = document.querySelectorAll('.js-product-reorder');
  if (reorderButton.length > 0) {
    reorderButton.forEach(item => {
      item.addEventListener('click', event => {
        event.preventDefault();
        const id = item.dataset.productId;
        const qty = item.dataset.productQty;
        const size = item.dataset.productSize;
        const specification = item.dataset.productSpecification;

        if (size != '' || specification != '') {
          const grid = {
            size_id: size,
            specification_id: specification,
          };
          window.addToCart(id, qty, 10, grid, true);
        } else {
          window.addToCart(id, qty);
        }
      });
    });
  }
});
