From 53204119a1c0a4764dfd7e511f8610d274011435 Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 3 Oct 2025 10:07:18 -0300 Subject: [PATCH] changes --- public/buyModal.js | 103 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 86 insertions(+), 17 deletions(-) diff --git a/public/buyModal.js b/public/buyModal.js index 5d18087..9cc7831 100644 --- a/public/buyModal.js +++ b/public/buyModal.js @@ -8,38 +8,105 @@ function createModal() { modal.style.left = "0"; modal.style.width = "100%"; modal.style.height = "100%"; - modal.style.backgroundColor = "rgba(0,0,0,0.5)"; + 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

-

- -
- - - - +
+ × + +

Order Details

+

+ + + + + + +
- - + +
- + + + - + + + +
+

Thank you for your purchase! 🎉

+ +
`; document.body.appendChild(modal); + + // Close modal document.getElementById("closeModal").onclick = () => { modal.style.display = "none"; }; modal.onclick = (e) => { if (e.target === modal) modal.style.display = "none"; }; + + // Close confirmation + modal.querySelector("#closeConfirmation").onclick = () => { + modal.style.display = "none"; + document.getElementById("buyForm").style.display = "flex"; + document.getElementById("confirmation").style.display = "none"; + }; + return modal; } @@ -62,6 +129,8 @@ function openModal(productHref) { function handleFormSubmit() { const form = document.getElementById("buyForm"); + const confirmation = document.getElementById("confirmation"); + form.addEventListener("submit", async (e) => { e.preventDefault(); const data = {}; @@ -75,9 +144,9 @@ function handleFormSubmit() { }); if (res.ok) { - alert("Form submitted successfully!"); + form.style.display = "none"; + confirmation.style.display = "block"; form.reset(); - document.getElementById("buyNowModal").style.display = "none"; } else { alert("Failed to submit form."); }