This commit is contained in:
Oliver
2025-10-03 10:35:35 -03:00
parent b3a16f81c8
commit e681478550
2 changed files with 120 additions and 2 deletions
+10 -2
View File
@@ -117,15 +117,21 @@ function openModal(productHref) {
}
function handleFormSubmit() {
console.log("handelFormSubmit")
const form = document.getElementById("buyForm");
const confirmation = document.getElementById("confirmation");
console.log("A")
form.addEventListener("submit", async (e) => {i
console.log("handler")
form.addEventListener("submit", async (e) => {
e.preventDefault();
const data = {};
new FormData(form).forEach((value, key) => (data[key] = value));
console.log("b")
try {
console.log("c")
const res = await fetch(WEBHOOK_URL, {
method: "POST",
headers: { "Content-Type": "application/json" },
@@ -133,9 +139,11 @@ function handleFormSubmit() {
});
if (res.ok) {
form.style.display = "none";
console.log("ASS")
confirmation.style.display = "block";
form.reset();
document.getElementById("buyNowModal").style.display = "none";
} else {
alert("Failed to submit form.");
}