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";
|
const WEBHOOK_URL = "https://002-001-5dd6e535-4d1c-46bc-9bd9-42ad4bc5f082.odoo4projects.com/webhook/c76e6b4e-af2f-4bc3-9875-6460d0ffc8e3";
|
||||||
|
|
||||||
|
|
||||||
function createModal() {
|
function createModal() {
|
||||||
const modal = document.createElement("div");
|
const modal = document.createElement("div");
|
||||||
modal.id = "buyNowModal";
|
modal.id = "buyNowModal";
|
||||||
@@ -94,8 +95,12 @@ function createModal() {
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
document.body.appendChild(modal);
|
document.body.appendChild(modal);
|
||||||
|
|
||||||
|
// Close modal
|
||||||
document.getElementById("closeModal").onclick = () => { modal.style.display = "none"; };
|
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"; };
|
modal.onclick = (e) => { if (e.target === modal) modal.style.display = "none"; };
|
||||||
|
|
||||||
return modal;
|
return modal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,21 +122,22 @@ function openModal(productHref) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleFormSubmit() {
|
function handleFormSubmit() {
|
||||||
console.log("handelFormSubmit")
|
|
||||||
const form = document.getElementById("buyForm");
|
const form = document.getElementById("buyForm");
|
||||||
const confirmation = document.getElementById("confirmation");
|
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();
|
e.preventDefault();
|
||||||
|
|
||||||
const data = {};
|
const data = {};
|
||||||
new FormData(form).forEach((value, key) => (data[key] = value));
|
new FormData(form).forEach((value, key) => (data[key] = value));
|
||||||
console.log("b")
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log("c")
|
|
||||||
|
|
||||||
const res = await fetch(WEBHOOK_URL, {
|
const res = await fetch(WEBHOOK_URL, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
@@ -139,8 +145,6 @@ console.log("c")
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
console.log("ASS")
|
|
||||||
|
|
||||||
confirmation.style.display = "block";
|
confirmation.style.display = "block";
|
||||||
form.reset();
|
form.reset();
|
||||||
document.getElementById("buyNowModal").style.display = "none";
|
document.getElementById("buyNowModal").style.display = "none";
|
||||||
|
|||||||
Reference in New Issue
Block a user