ds
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const WEBHOOK_URL = "https://002-001-5dd6e535-4d1c-46bc-9bd9-42ad4bc5f082.odoo4projects.com/webhook/c76e6b4e-af2f-4bc3-9875-6460d0ffc8e3";
|
||||
|
||||
|
||||
function createModal() {
|
||||
const modal = document.createElement("div");
|
||||
modal.id = "buyNowModal";
|
||||
@@ -94,8 +95,12 @@ function createModal() {
|
||||
`;
|
||||
|
||||
document.body.appendChild(modal);
|
||||
|
||||
// Close modal
|
||||
document.getElementById("closeModal").onclick = () => { modal.style.display = "none"; };
|
||||
document.getElementById("closeConfirmation").onclick = () => { document.getElementById("confirmation").style.display = "none"; };
|
||||
modal.onclick = (e) => { if (e.target === modal) modal.style.display = "none"; };
|
||||
|
||||
return modal;
|
||||
}
|
||||
|
||||
@@ -117,21 +122,22 @@ 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")
|
||||
|
||||
if (!form) {
|
||||
console.error("Form not found!");
|
||||
return;
|
||||
}
|
||||
|
||||
form.addEventListener("submit", async (e) => {
|
||||
console.log("handler");
|
||||
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" },
|
||||
@@ -139,8 +145,6 @@ console.log("c")
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
console.log("ASS")
|
||||
|
||||
confirmation.style.display = "block";
|
||||
form.reset();
|
||||
document.getElementById("buyNowModal").style.display = "none";
|
||||
|
||||
Reference in New Issue
Block a user