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

documentReady(() => {
  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);
        }
      });
    });
  }
});