const SyliusCartSummary = () => {
  let timer;

  document.querySelectorAll('.sylius-quantity input[form=sylius_cart]').forEach((el) => {
    el.addEventListener('change', (e) => {
      const { form } = e.target;
      if (form) {
        clearTimeout(timer);
        timer = setTimeout(() => {
          form.classList.add('loading');
          form.submit();
        }, 500);
      }
    });
  });
};

export default SyliusCartSummary;
