const WEBHOOK_URL = "https://002-001-5dd6e535-4d1c-46bc-9bd9-42ad4bc5f082.odoo4projects.com/webhook/c76e6b4e-af2f460d0ffc8e3";
function createModal() {
const modal = document.createElement("div");
modal.id = "buyNowModal";
modal.style.position = "fixed";
modal.style.top = "0";
modal.style.left = "0";
modal.style.width = "100%";
modal.style.height = "100%";
modal.style.backgroundColor = "rgba(0,0,0,0.6)";
modal.style.display = "none";
modal.style.justifyContent = "center";
modal.style.alignItems = "center";
modal.style.zIndex = "1000";
modal.innerHTML = `
×
Order Details
Thank you for your submission! 🎉
`;
document.body.appendChild(modal);
document.getElementById("closeModal").onclick = () => { modal.style.display = "none"; };
document.getElementById("closeConfirmation").onclick = () => {
document.getElementById("confirmation").style.display = "none";
modal.style.display = "none";
};
modal.onclick = (e) => { if (e.target === modal) modal.style.display = "none"; };
return modal;
}
function openModal() {
document.getElementById("buyNowModal").style.display = "flex";
}
function handleFormSubmit() {
const form = document.getElementById("buyForm");
const confirmation = document.getElementById("confirmation");
form.addEventListener("submit", async (e) => {
e.preventDefault();
const data = {};
new FormData(form).forEach((value, key) => (data[key] = value));
try {
const res = await fetch(WEBHOOK_URL, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(data)
});
if (res.ok) {
form.style.display = "none";
confirmation.style.display = "block";
form.reset();
} else {
alert("Failed to submit form.");
}
} catch (err) {
console.error(err);
alert("Error submitting form.");
}
});
}
function attachButtons() {
// Select all or