You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.5 KiB
47 lines
1.5 KiB
function handleConsultationForm(formElement) {
|
|
if (!formElement) return;
|
|
|
|
const formData = new FormData(formElement);
|
|
const submitButton = formElement.querySelector('.button');
|
|
|
|
if (submitButton) {
|
|
submitButton.disabled = true;
|
|
submitButton.classList.add('is-loading');
|
|
}
|
|
|
|
fetch('/ajax/local/consultation.php', {
|
|
method: 'POST',
|
|
body: formData
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
showCartToast("Заявка успешно отправлена", 3000, 'success');
|
|
formElement.reset();
|
|
} else {
|
|
showCartToast("Ошибка при отправке заявки", 3000, 'error');
|
|
}
|
|
})
|
|
.catch(error => {
|
|
showCartToast("Произошла ошибка при отправке", 3000, 'error');
|
|
})
|
|
.finally(() => {
|
|
if (submitButton) {
|
|
submitButton.disabled = false;
|
|
submitButton.classList.remove('is-loading');
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
document.querySelectorAll('.accordion__title').forEach(title => {
|
|
title.addEventListener('click', function() {
|
|
this.closest('.js-accordion').classList.toggle('active');
|
|
});
|
|
});
|
|
|
|
|
|
$('[data-product]').on('click', function(){
|
|
$('.cart-popup__wrapper').removeClass('.cart-popup__wrapper--hidden')
|
|
$('#fast_product').val($(this).data('product'))
|
|
}) |