Update index.html
Browse files- index.html +40 -121
index.html
CHANGED
|
@@ -39,131 +39,50 @@
|
|
| 39 |
<img src="SumUp logo.png" alt="SumUp logo" class="logo" />
|
| 40 |
|
| 41 |
<script>
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
const
|
| 46 |
-
const
|
| 47 |
-
const bookBtn = document.getElementById("bookBtn");
|
| 48 |
-
const statusEl = document.getElementById("status");
|
| 49 |
-
const spinner = document.getElementById("spinner");
|
| 50 |
-
|
| 51 |
-
function showSpinner() {
|
| 52 |
-
spinner.style.display = "block";
|
| 53 |
-
}
|
| 54 |
-
|
| 55 |
-
function hideSpinner() {
|
| 56 |
-
spinner.style.display = "none";
|
| 57 |
-
}
|
| 58 |
-
|
| 59 |
-
function setStatus(message, type = "info") {
|
| 60 |
-
statusEl.className = "";
|
| 61 |
-
statusEl.classList.add(`status-${type}`);
|
| 62 |
-
statusEl.innerText = message;
|
| 63 |
-
statusEl.style.display = "block";
|
| 64 |
-
}
|
| 65 |
-
|
| 66 |
-
form.addEventListener("submit", async (e) => {
|
| 67 |
-
e.preventDefault();
|
| 68 |
-
const name = document.getElementById("name").value;
|
| 69 |
-
const email = document.getElementById("email").value;
|
| 70 |
-
|
| 71 |
-
if (!name || !email) {
|
| 72 |
-
setStatus("Please enter your name and email.", "error");
|
| 73 |
-
return;
|
| 74 |
-
}
|
| 75 |
-
|
| 76 |
-
showSpinner();
|
| 77 |
-
setStatus("Checking availability...", "info");
|
| 78 |
-
|
| 79 |
-
try {
|
| 80 |
-
const res = await fetch(`/available?name=${encodeURIComponent(name)}&email=${encodeURIComponent(email)}`);
|
| 81 |
-
const data = await res.json();
|
| 82 |
-
hideSpinner();
|
| 83 |
-
|
| 84 |
-
if (data.error) {
|
| 85 |
-
setStatus(data.error, "error");
|
| 86 |
-
return;
|
| 87 |
-
}
|
| 88 |
-
|
| 89 |
-
repEmail = data.repEmail;
|
| 90 |
-
const slots = data.slots;
|
| 91 |
-
slotsDropdown.innerHTML = "";
|
| 92 |
-
|
| 93 |
-
if (slots.length === 0) {
|
| 94 |
-
setStatus("No available time slots found.", "error");
|
| 95 |
-
return;
|
| 96 |
-
}
|
| 97 |
-
|
| 98 |
-
slots.forEach(slot => {
|
| 99 |
-
const option = document.createElement("option");
|
| 100 |
-
option.value = slot.start;
|
| 101 |
-
option.text = new Date(slot.start).toLocaleString();
|
| 102 |
-
slotsDropdown.appendChild(option);
|
| 103 |
-
});
|
| 104 |
-
|
| 105 |
-
slotsDropdown.style.display = "block";
|
| 106 |
-
bookBtn.style.display = "inline-block";
|
| 107 |
-
setStatus("Select a time slot to book.", "success");
|
| 108 |
-
|
| 109 |
-
} catch (error) {
|
| 110 |
-
hideSpinner();
|
| 111 |
-
setStatus("Failed to retrieve availability.", "error");
|
| 112 |
-
}
|
| 113 |
-
});
|
| 114 |
-
|
| 115 |
-
bookBtn.addEventListener("click", async () => {
|
| 116 |
-
const name = document.getElementById("name").value;
|
| 117 |
-
const email = document.getElementById("email").value;
|
| 118 |
-
const selectedSlot = slotsDropdown.value;
|
| 119 |
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
}
|
| 124 |
|
|
|
|
|
|
|
| 125 |
showSpinner();
|
| 126 |
-
setStatus("
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
});
|
| 139 |
-
|
| 140 |
-
const resultText = await res.text();
|
| 141 |
-
hideSpinner();
|
| 142 |
-
|
| 143 |
-
setStatus("", "success");
|
| 144 |
-
|
| 145 |
-
// 🔥 Apply fade-in effect
|
| 146 |
-
const confirmationPanel = document.getElementById("confirmation");
|
| 147 |
-
confirmationPanel.classList.add("visible");
|
| 148 |
-
|
| 149 |
-
document.getElementById("conf-name").innerText = name;
|
| 150 |
-
document.getElementById("conf-email").innerText = email;
|
| 151 |
-
document.getElementById("conf-slot").innerText = new Date(selectedSlot).toLocaleString();
|
| 152 |
-
|
| 153 |
-
slotsDropdown.style.display = "none";
|
| 154 |
-
bookBtn.style.display = "none";
|
| 155 |
-
form.reset();
|
| 156 |
-
|
| 157 |
-
// Optional: hide status after a few seconds
|
| 158 |
-
setTimeout(() => {
|
| 159 |
-
statusEl.style.display = "none";
|
| 160 |
-
}, 3000);
|
| 161 |
-
|
| 162 |
-
} catch (error) {
|
| 163 |
-
hideSpinner();
|
| 164 |
-
setStatus("Booking failed. Please try again.", "error");
|
| 165 |
-
}
|
| 166 |
-
});
|
| 167 |
|
| 168 |
</script>
|
| 169 |
</body>
|
|
|
|
| 39 |
<img src="SumUp logo.png" alt="SumUp logo" class="logo" />
|
| 40 |
|
| 41 |
<script>
|
| 42 |
+
// Read query parameters from URL
|
| 43 |
+
const urlParams = new URLSearchParams(window.location.search);
|
| 44 |
+
const leadName = urlParams.get("ln") || "";
|
| 45 |
+
const leadEmail = urlParams.get("le") || "";
|
| 46 |
+
const salesRepEmailParam = urlParams.get("oe") || "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
+
// Pre-fill the form
|
| 49 |
+
document.getElementById("name").value = leadName;
|
| 50 |
+
document.getElementById("email").value = leadEmail;
|
|
|
|
| 51 |
|
| 52 |
+
// If all parameters exist, auto-fetch available slots
|
| 53 |
+
if (leadName && leadEmail && salesRepEmailParam) {
|
| 54 |
showSpinner();
|
| 55 |
+
setStatus("Loading available slots...", "info");
|
| 56 |
+
fetch(`/available?name=${encodeURIComponent(leadName)}&email=${encodeURIComponent(leadEmail)}&salesRepEmail=${encodeURIComponent(salesRepEmailParam)}`)
|
| 57 |
+
.then(res => res.json())
|
| 58 |
+
.then(data => {
|
| 59 |
+
hideSpinner();
|
| 60 |
+
if (data.error) {
|
| 61 |
+
setStatus(data.error, "error");
|
| 62 |
+
return;
|
| 63 |
+
}
|
| 64 |
+
repEmail = data.repEmail;
|
| 65 |
+
const slots = data.slots;
|
| 66 |
+
slotsDropdown.innerHTML = "";
|
| 67 |
+
if (slots.length === 0) {
|
| 68 |
+
setStatus("No available time slots found.", "error");
|
| 69 |
+
return;
|
| 70 |
+
}
|
| 71 |
+
slots.forEach(slot => {
|
| 72 |
+
const option = document.createElement("option");
|
| 73 |
+
option.value = slot.start;
|
| 74 |
+
option.text = new Date(slot.start).toLocaleString();
|
| 75 |
+
slotsDropdown.appendChild(option);
|
| 76 |
+
});
|
| 77 |
+
slotsDropdown.style.display = "block";
|
| 78 |
+
bookBtn.style.display = "inline-block";
|
| 79 |
+
setStatus("Select a time slot to book.", "success");
|
| 80 |
+
})
|
| 81 |
+
.catch(err => {
|
| 82 |
+
hideSpinner();
|
| 83 |
+
setStatus("Failed to fetch available slots.", "error");
|
| 84 |
});
|
| 85 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
</script>
|
| 88 |
</body>
|