Improved authorization, added link to event cards

This commit is contained in:
thoenykaroli committed 2026-06-01 13:14:47 +02:00
1 parent 43246d30a3
commit da0cac463b
8 files changed
+130 -15

No files matched your search

BIN
View File
Binary file not shown.
+24
View File
@@ -16,6 +16,7 @@ import { createEventCard } from "./ui/eventCard.js";
// =========================
let currentUser = null;
let currentPassword = null;
let lastRenderedEvents = [];
window.currentUser = null;
window.currentPassword = null;
@@ -120,8 +121,11 @@ modalLoginBtn.addEventListener("click", async () => {
userArea.classList.remove("d-none");
userNameEl.textContent = `👤 ${username}`;
navEvents.classList.remove("d-none");
navSaved.classList.remove("d-none");
navInv.classList.remove("d-none");
refreshVisibleEventCards();
} else {
loginError.textContent = "Login fehlgeschlagen. Bitte Zugangsdaten prüfen.";
loginError.hidden = false;
@@ -203,10 +207,12 @@ logoutBtn.addEventListener("click", () => {
authArea.classList.remove("d-none");
userArea.classList.add("d-none");
navEvents.classList.add("d-none");
navSaved.classList.add("d-none");
navInv.classList.add("d-none");
showSection("events");
refreshVisibleEventCards();
});
// =========================
@@ -235,6 +241,7 @@ async function handleSearch() {
try {
const events = await getEvents(city);
const filtered = applyFilters(events, dateFrom, dateTo, category);
lastRenderedEvents = filtered;
renderEventList(filtered, eventListEl);
} catch (err) {
showError(eventListEl, "Fehler beim Laden der Events. Bitte erneut versuchen.");
@@ -287,6 +294,13 @@ navInv.addEventListener("click", (e) => {
loadInvitations();
});
function refreshVisibleEventCards() {
if (!eventsSection.classList.contains("d-none") && lastRenderedEvents.length > 0) {
renderEventList(lastRenderedEvents, eventListEl);
}
}
function showSection(section) {
searchSection.classList.add("d-none");
eventsSection.classList.add("d-none");
@@ -393,6 +407,16 @@ function renderInvitation(inv, container) {
text.append(strong, " hat dich zu ", em, " eingeladen.");
card.appendChild(text);
if (inv.eventUrl) {
const link = document.createElement("a");
link.href = inv.eventUrl;
link.target = "_blank";
link.rel = "noopener noreferrer";
link.className = "btn btn-outline-primary btn-sm mb-2";
link.textContent = "Event öffnen";
card.appendChild(link);
}
if (inv.status !== "pending") {
const status = document.createElement("p");
status.className = inv.status === "accepted" ? "text-success" : "text-muted";
+3 -2
View File
@@ -8,7 +8,7 @@ import { fetchEvents } from "../api/ticketmaster.js";
/**
* Lädt und transformiert Events für eine gegebene Stadt.
* @param {string} city - Stadtname
* @returns {Promise<Array<{id, name, date, time, venue, category}>>}
* @returns {Promise<Array<{id, name, date, time, venue, category, url}>>}
*/
export async function getEvents(city) {
const events = await fetchEvents(city);
@@ -20,9 +20,10 @@ export async function getEvents(city) {
date: event.dates?.start?.localDate || null,
time: event.dates?.start?.localTime || null,
venue: event._embedded?.venues?.[0]?.name || "Unbekannter Ort",
url: event.url || null,
// Kategorie aus dem ersten Klassifizierungs-Segment extrahieren (z.B. "Music", "Sports")
category: event.classifications?.[0]?.segment?.name
? event.classifications[0].segment.name.toLowerCase()
: null
}));
}
}
+17 -1
View File
@@ -41,6 +41,21 @@ export function createEventCard(event) {
article.append(title, date, venue);
if (event.url) {
const link = document.createElement("a");
link.href = event.url;
link.target = "_blank";
link.rel = "noopener noreferrer";
link.className = "btn btn-outline-secondary btn-sm mt-2";
link.textContent = "Event ansehen";
article.appendChild(link);
}
// Gäste sehen nur Event-Informationen. Speichern und Einladen sind Login-Funktionen.
if (!window.currentUser) {
return article;
}
// --- BUTTON-GRUPPE ---
const buttonContainer = document.createElement("div");
buttonContainer.className = "d-flex gap-2 mt-2 flex-wrap";
@@ -154,7 +169,8 @@ function createInviteForm(event, card) {
body: JSON.stringify({
toUser,
eventId: event.id,
eventName: event.name
eventName: event.name,
eventUrl: event.url || null
})
});