Files
date-wizard/checkout.js
T

54 lines
1.8 KiB
JavaScript

// Checkout & Bestätigungsseite
(function () {
const backLink = document.getElementById("backLink");
const summarySection = document.getElementById("summarySection");
const confirmationSection = document.getElementById("confirmationSection");
const summaryActivity = document.getElementById("summaryActivity");
const summaryDate = document.getElementById("summaryDate");
const summaryName = document.getElementById("summaryName");
const activityIcon = document.getElementById("activityIcon");
const checkoutBtn = document.getElementById("checkoutBtn");
const selectedActivity = localStorage.getItem("selectedActivity");
const selectedDate = localStorage.getItem("selectedDate");
const selectedName = localStorage.getItem("selectedName");
if (!selectedActivity || !selectedDate || !selectedName) {
window.location.href = "index.html";
return;
}
summaryActivity.textContent = selectedActivity;
summaryName.textContent = selectedName;
const dateObj = new Date(`${selectedDate}T00:00:00`);
const formattedDate = dateObj.toLocaleDateString("de-DE", {
weekday: "long",
day: "numeric",
month: "long",
year: "numeric",
});
summaryDate.textContent = formattedDate;
// Icon aus appsettings.json laden, falls verfügbar
fetch("appsettings.json")
.then((res) => res.json())
.then((settings) => {
const match = (settings.activities || []).find((a) => a.name === selectedActivity);
if (match && match.icon) {
activityIcon.textContent = match.icon;
}
})
.catch(() => {});
checkoutBtn.addEventListener("click", () => {
// Später: API / Mail-Versand / Kalendereintrag ausführen
summarySection.classList.add("hidden");
if (backLink) {
backLink.classList.add("hidden");
}
confirmationSection.classList.remove("hidden");
});
})();